python-coder12345
python-coder12345

Reputation: 188

What is turtle.colormode(255) for?

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

Answers (1)

Red
Red

Reputation: 27577

What is the purpose of turtle.colormode(255)?

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

Related Questions