|
|
Rank: Member Groups: Member
Joined: 8/12/2009 Posts: 29 Location: Poland
|
. Hi :) I need a little help . graph.put(x,y, g.black) produce a black dot in x,y location but I need something more and I dont know how to solve this: . c1=math.random()*1 c2=math.random()*1 c3=math.random()*1 color=[c1,c2,c3] graph.put(x,y, color) . So, I need to produce a random color, but last line above always draw a black dot (for example). Is any way to change my variable "color" to hex ? Or maybe is another method to do this :) ? .
|
|
Rank: Member Groups: Member
Joined: 10/22/2008 Posts: 21 Location: Biała Podlaska, Poland
|
As easy as an ABC ;) [Here was something not true ;p] Hex: Link <- if you looked here, you would see there is a way to use hexadecimal values. In short: colour = 0xRRGGBB. PS Pisze się "Is _there_ any way [...]" ;p
|
|
Rank: Member Groups: Member
Joined: 8/12/2009 Posts: 29 Location: Poland
|
This is not helping me. Command graph.put() recognize only a color in hex format, so table ( g.put(x,y, [c1,c2,c3]) ) do not produce a random color . If we use this table as graph.pen([c1,c2,c3]) then color become a random.. But how to solve this ? Ps: programujesz coś w m ? ;) to dawaj gg :D
|
|
Rank: Member Groups: Member
Joined: 10/22/2008 Posts: 21 Location: Biała Podlaska, Poland
|
I guess you're right! Documentation says it should work, but it's not so we have a bug ;)
|
|
Rank: Administration Groups: Administration
, Member
Joined: 4/3/2008 Posts: 105 Location: Herrliberg/Switzerland
|
Try this: Code:/* fill screen with randomly colored dots */ use graph as g, math, ui
sz=g.size(); ui.menu("rndcolor", ["exit"]); g.bg(g.black); g.clear() do g.put(math.trunc(sz[0]*math.random()), math.trunc(sz[1]*math.random()), math.trunc(255*math.random()) shl 16|math.trunc(255*math.random()) shl 8|math.trunc(255*math.random())); g.show(); cmd=ui.cmd(0) until cmd="exit" Please carefully read the documentation for graph.put(x, y, color) it says: Quote:- If color is a number, sets the pixel at (x,y) to the color color. - If color is an array of numbers, sets the pixels from (x,y) to (x+len(color)-1,y) to the colors in color.
|
|
|
Guest |