Reputation: 188
I am a beginner to Python, and I have just started reading about turtle. I came across a bit of code ( forgot ) and I would like to know, what is the purpose of turtle.colormode(255)
? Thanks!
Upvotes: 4
Views: 8571
Reputation: 27577
turtle.colormode(cmode=None)
basically lets the programmer choose how they would like python to interpret the number passed into the brackets for the colors.
There are these options for cmode
: 1
and 255
.
For the 1
mode, the programmer can only use numbers between 0
and 1
to represent the rgb
scale, otherwise, a TurtleGraphicsError
will be raised.
For the 255
option, the programmer can use numbers between 0
and 255
. When using the 1
option, the color
(0.33, 0.33, 0.33)
will be the equivalent of
(85, 85, 85) #(255*0.33, 255*0.33, 255*0.33)
when using the 255
mode.
For more information, see the documentation for turtle.colormode()
.
Upvotes: 2