Tuesday, November 20, 2007

Logo colors galore

Last week we talked about how colors are made: a familiar topic, since we had looked at binary numbers and RGB before. The syntax of Logo requires a list of three values in the range [0, 255] for each color component: for example,

      setpc [255 0 0]

to set pencolor all red, no green, no blue.

We also talked about writing subprograms, such as:


to square :n
repeat 4 [
fd :n
rt 90
]
end


Page 16 of the handout tells us how to write a procedure that allows us to use color names of our own choosing:


to blue
op [0 0 255]
end


With this, we can say, setpc blue rather than setpc [0 0 255]. This excellent technique is one of many great things offered by Simone Rudge here.

I encourage you to make a palette of your own pet colors.

You can see my variations on the Rudge technique in these files — one, two.

No comments: