Search code examples
pythonpython-turtle

How to change RGB values from colormode(255) to colormode(1)?


import turtle

turtle.colormode(255)

turtle.color(130, 50, 50)

If I set the color mode to 1: turtle.colormode(1), what are the RGB values should I put here? turtle.color(?, ?, ?)

Thanks.


Solution

  • Setting it to 1.0 means the rgb values should be in the range [0, 1.0], which you can get by dividing each component in 255 mode by 255:

    import turtle
    
    turtle.colormode(1.0)
    
    turtle.color(130/255, 50/255, 50/255)