[Squeakland] sketch's color
Bert Freudenberg
bert at impara.de
Thu Jun 23 06:32:05 PDT 2005
Am 23.06.2005 um 04:40 schrieb Randy Heiland:
> Thanks Andreas,
>
> Honestly, I'm not sure. For starters, the world/fixSketches script
> is a bit of magic I don't understand, not to mention that it's
> apparently a text-only script. However, I don't think this addresses
> one of my wishes - which is to be able to set the color of a sketch's
> stamp (multiple stamps, multiple colors, assigned by an RGB vector).
The stamp in Andreas' example has the right color, doesn't it?
So what you need is setting the color from RGB. There is a nice
apparatus for visualizing the RGB color model: the color cube. You
can even buy on at
http://www.colorcube.com/puzzle/puzzle.htm
It's made by arranging tiny cubes in a three-dimensional grid
according to their colors. Black is at the origin (0,0,0), white at
the opposite corner (1,1,1).
This cube can be simulated with an etoy project, and thus positions
converted into colors. Here's how:
1) Make images of the color cube sliced into layers. Just drop the
attached images into a holder:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Slice0.png
Type: image/png
Size: 1243 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20050623/e6ab4596/Slice0.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Slice1.png
Type: image/png
Size: 1241 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20050623/e6ab4596/Slice1.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Slice2.png
Type: image/png
Size: 1242 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20050623/e6ab4596/Slice2.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Slice3.png
Type: image/png
Size: 1242 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20050623/e6ab4596/Slice3.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Slice4.png
Type: image/png
Size: 1242 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20050623/e6ab4596/Slice4.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Slice5.png
Type: image/png
Size: 1242 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20050623/e6ab4596/Slice5.png
-------------- next part --------------
2) Make an object "cube" showing the current slice (as in an holder
animation)
2) Get an Ellipse, and give it three variables named "r", "g", and
"b", place it on top of the cube
3) Make a ticking script that maps r, g, and b:
- the slice is selected according to r (set holder's cursor to r, and
cube's graphic to holder's graphic-at-cursor)
- the ellipse is moved according to g and b ("g" moves on the x-
direction, "b" in y)
4) set "Ellipse's color" to "Ellipse's colorUnder"
5) now changing r, g, and b in the (0...5) interval sets the ellipses
color.
Here is a project to demonstrate this:
http://www.squeakland.org/project.jsp?http://impara.de/
~bert/RGBColors.002.pr
And here's an older version using a slightly different approach to
convert 3D-2D:
http://www.squeakland.org/project.jsp?http://impara.de/
~bert/RGBColors.001.pr
A much less etoys-like approach is this: make a tile that directly
converts RGB numbers into a color:
1) make a variable "col", set its type to Color
2) make variables "r", "g", "b"
3) drag out the arrow to assign to "col", this makes a new script
4) switch to text mode
5) use this to assign the color from r, g, and b:
script1
self
setCol: (Color
r: self getR
g: self getG
b: self getB)
6) set r to 1, g to 1, b to 0, run the script, col will be yellow.
> Another wish is to be able to dynamically set the color of a pen
> trail, again via RGB.
Andreas' hack could eventually be used to recolor pen trails (that
is, all of them at once).
- Bert -
More information about the Squeakland
mailing list