# colormixer
from turtle import Screen, Turtle, mainloop
class ColorTurtle(Turtle):
def __init__(self, x, y):
Turtle.__init__(self)
self.shape("turtle")
self.resizemode("user")
self.shapesize(3,3,5)
self.pensize(10)
self._color = [0,0,0]
self.x = x
self._color[x] = y
self.color(self._color)
self.speed(0)
self.left(90)
self.pu()
self.goto(x,0)
self.pd()
self.sety(1)
self.pu()
self.sety(y)
self.pencolor("gray25")
self.ondrag(self.shift)
def shift(self, x, y):
self.sety(max(0,min(y,1)))
self._color[self.x] = self.ycor()
self.fillcolor(self._color)
setbgcolor()
def setbgcolor():
screen.bgcolor(red.ycor(), green.ycor(), blue.ycor())
def main():
global screen, red, green, blue
screen = Screen()
screen.delay(0)
screen.setworldcoordinates(-1, -0.3, 3, 1.3)
red = ColorTurtle(0, .5)
green = ColorTurtle(1, .5)
blue = ColorTurtle(2, .5)
setbgcolor()
writer = Turtle()
writer.ht()
writer.pu()
writer.goto(1,1.15)
writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
return "EVENTLOOP"
if __name__ == "__main__":
msg = main()
print(msg)
mainloop()
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 314 B | 0644 |
|
| __main__.py | File | 15.01 KB | 0755 |
|
| bytedesign.py | File | 4.15 KB | 0755 |
|
| chaos.py | File | 951 B | 0644 |
|
| clock.py | File | 3.23 KB | 0755 |
|
| colormixer.py | File | 1.31 KB | 0644 |
|
| forest.py | File | 2.9 KB | 0755 |
|
| fractalcurves.py | File | 3.39 KB | 0755 |
|
| lindenmayer.py | File | 2.38 KB | 0755 |
|
| minimal_hanoi.py | File | 2 KB | 0755 |
|
| nim.py | File | 6.36 KB | 0644 |
|
| paint.py | File | 1.26 KB | 0755 |
|
| peace.py | File | 1.04 KB | 0755 |
|
| penrose.py | File | 3.3 KB | 0755 |
|
| planet_and_moon.py | File | 2.76 KB | 0755 |
|
| rosette.py | File | 1.33 KB | 0644 |
|
| round_dance.py | File | 1.76 KB | 0644 |
|
| sorting_animate.py | File | 4.93 KB | 0755 |
|
| tree.py | File | 1.37 KB | 0755 |
|
| turtle.cfg | File | 160 B | 0644 |
|
| two_canvases.py | File | 1.09 KB | 0644 |
|
| yinyang.py | File | 821 B | 0755 |
|