ยปCore Development>Code coverage>Lib/turtledemo/colormixer.py

# Python code coverage for Lib/turtledemo/colormixer.py

#countcontent
1n/a# colormixer
2n/a
3n/afrom turtle import Screen, Turtle, mainloop
4n/a
5n/aclass ColorTurtle(Turtle):
6n/a
7n/a def __init__(self, x, y):
8n/a Turtle.__init__(self)
9n/a self.shape("turtle")
10n/a self.resizemode("user")
11n/a self.shapesize(3,3,5)
12n/a self.pensize(10)
13n/a self._color = [0,0,0]
14n/a self.x = x
15n/a self._color[x] = y
16n/a self.color(self._color)
17n/a self.speed(0)
18n/a self.left(90)
19n/a self.pu()
20n/a self.goto(x,0)
21n/a self.pd()
22n/a self.sety(1)
23n/a self.pu()
24n/a self.sety(y)
25n/a self.pencolor("gray25")
26n/a self.ondrag(self.shift)
27n/a
28n/a def shift(self, x, y):
29n/a self.sety(max(0,min(y,1)))
30n/a self._color[self.x] = self.ycor()
31n/a self.fillcolor(self._color)
32n/a setbgcolor()
33n/a
35n/a screen.bgcolor(red.ycor(), green.ycor(), blue.ycor())
36n/a
38n/a global screen, red, green, blue
39n/a screen = Screen()
40n/a screen.delay(0)
41n/a screen.setworldcoordinates(-1, -0.3, 3, 1.3)
42n/a
43n/a red = ColorTurtle(0, .5)
44n/a green = ColorTurtle(1, .5)
45n/a blue = ColorTurtle(2, .5)
46n/a setbgcolor()
47n/a
48n/a writer = Turtle()
49n/a writer.ht()
50n/a writer.pu()
51n/a writer.goto(1,1.15)
52n/a writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
53n/a return "EVENTLOOP"
54n/a
55n/aif __name__ == "__main__":
56n/a msg = main()
57n/a print(msg)
58n/a mainloop()