Websites Navigation: Airbit | Shop | m-shell.net
Languages: EN | DE
Welcome Guest Search | Active Topics | Members | Log In | Register

graph.put() and colors Options
arwu
Posted: Wednesday, July 28, 2010 4:23:23 PM
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 :) ?
.
ttomus90
Posted: Friday, July 30, 2010 2:01:37 PM
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
arwu
Posted: Saturday, July 31, 2010 12:16:07 AM
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
ttomus90
Posted: Thursday, August 12, 2010 11:09:03 AM
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 ;)
airbit
Posted: Thursday, August 12, 2010 5:54:55 PM
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.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.109 seconds.

mShell Home  > Forum