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!
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().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With