Mechraf

Currently in /2019/01/25/83/


1    from turtle import *
2    
3   
4
5    
6    
7    def Ying(radius, color1, color2):
8        'this whole function block draws just one fish'
9        width(3)  # the width of the pen. From 1 to 3.
10       color("black", color1)  # now, this defines the color of the fish's body
11       begin_fill()
12       circle(radius / 2, 180)  # a circle with half the defined radius and a half arc (essentially the fish's head)
13       circle(radius, 180)
14       left(180)  # turn the pen's head anticlockwise by 180 degrees
15       circle(-radius / 2, 180)  # the smaller body circle
16       end_fill()
17       color(color1, color2)  # this defines that of its eyes
18       begin_fill()
19       right(-90)
20       penup()
21       forward(radius / 1.3)
22       pendown()
23       right(-90)
24       circle(radius / 5)
25       end_fill()
26       right(-90)
27       penup()
28       forward(radius / 1.3)
29       pendown()
30       right(90)
31       hideturtle()
32   
33   
34   Ying(120, "black", "white")  # the first fish
35   
36   Ying(120, "white", "black")  # the second fish