Author Topic: Simple Random Color Selection  (Read 2606 times)

Offline WPShadow

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1667
    • View Profile
    • http://lostrevenant.blogspot.com
Simple Random Color Selection
« on: 2013-Apr-27 »
Hi,

university was very, very boring today, so here's the result of the last 15 minutes...

Use SPACE to create new colors...

well, that's it  =D


Code: (glbasic) [Select]
// --------------------------------- //
// Project: chaoscolor
// Start: Saturday, April 27, 2013
// IDE Version: 11.171


// SETCURRENTDIR("Media") // go to media files

TYPE color
x
red
green
blue
ENDTYPE

GLOBAL c[] AS color, x, y, b1, b2, col_r, col_g, col_b

main()


FUNCTION main:

SYSTEMPOINTER TRUE

WHILE TRUE

MOUSESTATE x, y, b1, b2
DRAWLINE x, 0, x, 610, RGB(255, 255, 255)

IF KEY(57) =1 THEN add_color()
show_color()

PRINT "RED:   " + col_r, 100, 620
PRINT "GREEN: " + col_g, 100, 650
PRINT "BLUE:  " + col_b, 100, 680

DRAWRECT 200, 620, 100, 720, RGB(col_r, col_g, col_b)


SHOWSCREEN
WEND

ENDFUNCTION

FUNCTION add_color:
LOCAL col AS color

col.red = RND(255)
col.green = RND(255)
col.blue = RND(255)
col.x = 0

IF LEN(c[]) > 0
FOREACH co IN c[]
INC co.x, 1
NEXT
ENDIF

DIMPUSH c[], col

ENDFUNCTION

FUNCTION show_color:
LOCAL count

IF LEN(c[]) > 0
FOREACH col IN c[]
DRAWLINE col.x, 200, col.x, 600, RGB(col.red, col.green, col.blue)

IF x = col.x
col_r = col.red
col_g = col.green
col_b = col.blue
ENDIF

IF col.x > 1024 THEN DELETE col
NEXT
ENDIF

ENDFUNCTION
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5111
  • O Rly?
    • View Profile
Re: Simple Random Color Selection
« Reply #1 on: 2013-Apr-28 »
Was nimmst du bitte für Drogen?! :D
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3375
  • Integrated Brain
    • View Profile
Re: Simple Random Color Selection
« Reply #2 on: 2013-Apr-28 »
JAJAJA  :D :D