COLOR


 color(number)
 

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.

Example:

color(8) --set color to red
print("hello world")

the text hello world in red

The above is the same as:

print("hello world",0,0,8)
 

the text hello world in red



print("hello",0,0,8)  --red
oval(30,2,50,12)
color(7) --white
print("world")
rect(60,2,80,12)

the text hello world in red

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.



Images in this Guide by NerdyTeachers is licensed under CC BY-SA 4.0

1120

19 Mar 2023

Font