Python Turtle Opacity

Python Turtle Opacity?

Python Turtle Opacity?

Its not possible to do that, but you could define your colors, and then a light equivalent, and use those.

Red = (255,0,0,0)
LRed = (100,0,0)

I think that would achieve similar effects. You could then just use a lighter color when you want it semi-transparent.

This python turtle example fades out the text while keeping the original turtle stamps unmodified:

import turtle
import time

alex = turtle.Turtle()
alex_text = turtle.Turtle()
alex_text.goto(alex.position()[0], alex.position()[1])

alex_text.pencolor((0, 0, 0))       #black
alex_text.write(hello)
time.sleep(1)
alex_text.clear()

alex_text.pencolor((.1, .1, .1))       #dark grey
alex_text.write(hello)
time.sleep(1)

alex_text.pencolor((.5, .5, .5))       #Grey
alex_text.write(hello)
time.sleep(1)

alex_text.pencolor((.8, .8, .8))       #Light grey
alex_text.write(hello)
time.sleep(1)

alex_text.pencolor((1, 1, 1))          #white
alex_text.write(hello)
time.sleep(1)

alex_text.clear()                      #gone
time.sleep(1)

The text simulates an opacity increase to maximum. Alexs stamps are unmodified.

Python Turtle Opacity?

You can by doing

import turtle
turtle = turtle.Turtle()
r = 100
g = 100
b = 100
a = 0.5
turtle.color(r,g,b,a)

(well, maybe it only works for repl.it)

Related posts on Python  :

Leave a Reply

Your email address will not be published.