This will set the color to be used in the next draw call, such as:
print() circ() rect() line() oval()
If those draw functions do not use the optional color setting, then whatever color was last set will be used. By using the optional color settings in functions that have them, it sets that color to be the currently selected color.
color(8) --set color to red print("hello world")
The above is the same as:
print("hello",0,0,8) --red oval(30,2,50,12) color(7) --white print("world") rect(60,2,80,12)
Notice that the oval is red even though we don't tell it to be nor did we use
color(8). This happened because setting the color to red in print actually sets the draw color the same way as using
color() would. Then we do use
color(7) to change the draw color to white, and this applies the color to the next print and rectangle draws.
19 Mar 2023