Skip to content

Instantly share code, notes, and snippets.

@doctorlove
Last active December 15, 2017 12:44
Show Gist options
  • Save doctorlove/5bdd289e60a1c250fd61b05e16aa1895 to your computer and use it in GitHub Desktop.
Save doctorlove/5bdd289e60a1c250fd61b05e16aa1895 to your computer and use it in GitHub Desktop.
#https://imgur.com/r/Python/YeHqZ
import turtle
import random
def mandala():
window= turtle.Screen()
window.bgcolor ("black")
t = turtle.Turtle()
t.color("red")
t.pensize (0.2)
t.speed (0)
x=2
y=1
z=1
i=0
print (y)
while i < 2200:
z=(z+1)
t.forward (10)
t.right (x)
x=(z*(x/z)-z)
while x > 359:
x=x-360
print (x, y, i, t.position())
i += 1
t.hideturtle()
t.up()
t.goto(-100, 250)
t.write(" __ __ __", font=("Courier", 16, "normal"))
t.goto(-100, 225)
t.write(" / | / / / |", font=("Courier", 16, "normal"))
t.goto(-100, 200)
t.write("(___|( ( ( |", font=("Courier", 16, "normal"))
t.goto(-100, 175)
t.write("| )| )| )| )", font=("Courier", 16, "normal"))
t.goto(-100, 150)
t.write("| / |__/ |__/ |__/", font=("Courier", 16, "normal"))
turtle.mainloop()
###
# xart ACCU -f Weird
# __ __ __
# / | / / / |
#(___|( ( ( |
#| )| )| )| )
#| / |__/ |__/ |__/
###
def dragon():
#https://trinket.io/python/c06f77c8e6
# Dragon curve using L-system
# Authour:Alan Richmond, Python3.codes
# https://en.wikipedia.org/wiki/L-system
def X(n):
if n>0: L("X+YF+",n)
def Y(n):
if n>0: L("-FX-Y",n)
def L(s,n):
for c in s:
if c=='-': turtle.lt(90)
elif c=='+': turtle.rt(90)
elif c=='X': X(n-1)
elif c=='Y': Y(n-1)
elif c=='F': turtle.fd(12)
print turtle.position()
turtle.bgcolor('black')
turtle.pencolor('red')
turtle.up()
turtle.goto(-20, 120)
turtle.down()
X(10)
turtle.hideturtle()
turtle.mainloop()
def draw_a(t, h):
t.goto(-95, h)
t.goto(-75, h+20)
t.goto(-55, h)
t.goto(100, h)
def draw_c(t, x, h):
t.up()
t.goto(x, h)
t.down()
t.goto(x-40, h+10)
t.goto(x, h+20)
def draw_u(t, h):
t.up()
t.goto(55, h+20)
t.down()
t.goto(75, h)
t.goto(95, h+20)
def draw_date(t, h):
t.up()
t.goto(-95, h)
t.down()
t.goto(-55, h+10)
t.goto(-75, h+20)
t.goto(-95, h+10)
t.up()
t.goto(-25, h)
t.down()
t.goto(-45, h+10)
t.goto(-25, h+20)
t.goto(-5, h+10)
t.goto(-25, h)
t.up()
t.goto(25, h)
t.down()
t.goto(25, h+20)
t.up()
t.goto(75, h)
t.down()
t.goto(55, h+5)
t.goto(95, h+15)
t.goto(75, h+20)
t.goto(55, h+15)
t.goto(95, h+5)
t.goto(75, h)
def bubbles(t, h):
for i in range(-90, 91, 5):
t.up()
diff = random.random()-0.5
t.goto(i, h-5-diff)
t.down()
shape = random.choice([0,1])
diff = random.random()-0.5
if shape==0:
t.circle(3+diff)
else:
t.dot(8+diff*5)
def stars(t, h):
for i in range(-95, 91, 10):
t.up()
diff = random.random()-0.5
t.goto(i, h+2*diff)
t.left(random.randint(0, 180))
t.down()
diff = random.random()-0.5
for i in range(5):
t.forward(10+2*diff)
t.left(144)
t.setheading(0)
def lines():
turtle.setworldcoordinates(-110, -150, 110, 110)
turtle.bgcolor('black')
t = turtle.Turtle()
t.color("red")
t.pensize (3.)
draw_date(t, -100)
for i in range(-140, -70, 20):
t.up()
t.goto(-100, i)
t.down()
t.forward(200)
bubbles(t, -130)
stars(t, 80)
t.up()
t.goto(-100, -60)
t.down()
draw_a(t,-60)
t.up()
t.goto(-100, -40)
t.down()
draw_a(t,-40)
draw_c(t,-5,-40)
t.up()
t.goto(-100, -20)
t.down()
draw_a(t,-20)
draw_c(t,-5,-20)
draw_c(t,45,-20)
t.up()
t.goto(-100, 0)
t.down()
draw_a(t,0)
draw_c(t,-5,0)
draw_c(t,45,0)
draw_u(t,0)
for i in range(20, 61, 20):
t.up()
t.goto(-100, i)
t.down()
t.forward(200)
t.ht()
turtle.hideturtle()
turtle.mainloop()
if __name__ == '__main__':
#mandala()
#dragon()
lines()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment