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 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
color(7) --white

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


19 Mar 2023