initial commit
This commit is contained in:
commit
39f56a3b10
83 files changed
+3583
No files matched your search
@@ -0,0 +1,183 @@
|
||||
from turtle import Turtle
|
||||
|
||||
|
||||
def broken_line(length, pause, lines):
|
||||
for x in range(lines):
|
||||
sophia.forward(length)
|
||||
sophia.penup()
|
||||
sophia.forward(pause)
|
||||
sophia.pendown()
|
||||
|
||||
def circles(y):
|
||||
for x in range(150):
|
||||
sophia.circle(y)
|
||||
y = y+5
|
||||
sophia.right(10)
|
||||
|
||||
def draw_square(t,length,width,color):
|
||||
t.color(color)
|
||||
for x in range(2):
|
||||
t.forward(width)
|
||||
t.left(90)
|
||||
t.forward(length)
|
||||
t.left(90)
|
||||
|
||||
def filled_square(t,length,width,color):
|
||||
t.fillcolor(color)
|
||||
t.color(color)
|
||||
t.begin_fill()
|
||||
for x in range(2):
|
||||
t.forward(width)
|
||||
t.left(90)
|
||||
t.forward(length)
|
||||
t.left(90)
|
||||
t.end_fill()
|
||||
|
||||
def filled_circle(t,y,color):
|
||||
t.fillcolor(color)
|
||||
t.color(color)
|
||||
t.begin_fill()
|
||||
t.circle(y)
|
||||
t.end_fill()
|
||||
|
||||
def draw_mandala(t,y,color):
|
||||
for x in range(18):
|
||||
draw_square(t,y,color)
|
||||
t.left(20)
|
||||
|
||||
def draw_triangle(t,y):
|
||||
for x in range(3):
|
||||
t.left(120)
|
||||
t.forward(y)
|
||||
|
||||
def draw_target(t,y):
|
||||
r = y
|
||||
for x in range(2):
|
||||
filled_circle(sophia, y,"red")
|
||||
y = y - 30
|
||||
t.left(90)
|
||||
t.forward(r-y)
|
||||
r = r - 30
|
||||
print("r=",r)
|
||||
print("y=",y)
|
||||
t.left(270)
|
||||
filled_circle(sophia, y,"white")
|
||||
y = y - 30
|
||||
t.left(90)
|
||||
t.forward(r-y)
|
||||
r = r - 30
|
||||
print("r=",r)
|
||||
print("y=",y)
|
||||
t.left(270)
|
||||
filled_circle(sophia, y,"red")
|
||||
|
||||
def ampel(t,y):
|
||||
t.backward(70/2)
|
||||
length = y
|
||||
filled_square(t,length,70,"black")
|
||||
t.penup()
|
||||
t.forward(70/2)
|
||||
t.left(90)
|
||||
t.forward(6)
|
||||
t.right(90)
|
||||
filled_circle(t, 25, "green")
|
||||
t.left(90)
|
||||
t.forward(y / 3)
|
||||
t.right(90)
|
||||
filled_circle(t, 25, "yellow")
|
||||
t.left(90)
|
||||
t.forward(y / 3)
|
||||
t.right(90)
|
||||
filled_circle(t, 25, "red")
|
||||
|
||||
def skyscraper(t):
|
||||
t.penup()
|
||||
for x in range(5):
|
||||
t.backward(100)
|
||||
t.left(90)
|
||||
t.forward(30)
|
||||
t.right(90)
|
||||
filled_square(t,42,100,"black")
|
||||
t.forward(10)
|
||||
t.left(90)
|
||||
t.forward(10)
|
||||
t.right(90)
|
||||
for x in range(3):
|
||||
filled_square(t,30,20,"yellow")
|
||||
t.forward(30)
|
||||
t.backward(100)
|
||||
t.left(90)
|
||||
t.forward(30)
|
||||
t.right(90)
|
||||
filled_square(t,8,100,"black")
|
||||
|
||||
def draw_flag(t,color1,color2,color3):
|
||||
t.screen.bgcolor("black")
|
||||
filled_square(t,120,60, color1)
|
||||
t.forward(60)
|
||||
filled_square(t, 120, 60, color2)
|
||||
t.forward(60)
|
||||
filled_square(t, 120, 60, color3)
|
||||
|
||||
def draw_segment(t,r,a,color):
|
||||
t.color(color)
|
||||
t.fillcolor(color)
|
||||
t.begin_fill()
|
||||
t.circle(r,a)
|
||||
t.left(90)
|
||||
t.forward(r)
|
||||
t.end_fill()
|
||||
t.backward(r)
|
||||
t.right(90)
|
||||
|
||||
def pie_chart(t,r):
|
||||
a = 240
|
||||
draw_segment(t,r,a,"red")
|
||||
a = 90
|
||||
draw_segment(t, r, a, "blue")
|
||||
a = 30
|
||||
draw_segment(t, r, a, "green")
|
||||
|
||||
def yin(r):
|
||||
sophia.begin_fill()
|
||||
sophia.circle(r/2, -180)
|
||||
sophia.end_fill()
|
||||
sophia.left(90)
|
||||
sophia.forward(r / 2.5)
|
||||
sophia.right(90)
|
||||
filled_circle(sophia, r / 10, "black")
|
||||
|
||||
def yang(r):
|
||||
zoe.penup()
|
||||
zoe.circle(r, -180)
|
||||
zoe.pendown()
|
||||
zoe.begin_fill()
|
||||
zoe.circle(r / 2, -180)
|
||||
zoe.end_fill()
|
||||
zoe.left(90)
|
||||
zoe.forward(r/2.5)
|
||||
zoe.right(90)
|
||||
filled_circle(zoe,r/10,"white")
|
||||
|
||||
def yin_yang(r):
|
||||
sophia.screen.bgcolor("grey")
|
||||
sophia.color("white")
|
||||
sophia.fillcolor("white")
|
||||
zoe.fillcolor("black")
|
||||
zoe.color("black")
|
||||
sophia.begin_fill()
|
||||
sophia.circle(r, -180)
|
||||
sophia.end_fill()
|
||||
zoe.begin_fill()
|
||||
zoe.circle(r, 180)
|
||||
zoe.end_fill()
|
||||
yang(r)
|
||||
yin(r)
|
||||
|
||||
Turtle.target = draw_target
|
||||
sophia = Turtle()
|
||||
sophia.hideturtle()
|
||||
sophia.speed(0)
|
||||
zoe = Turtle()
|
||||
zoe.hideturtle()
|
||||
zoe.speed(0)
|
||||
Reference in new issue
Block a user