generated from mwc/project_drawing
I chnaged my entire code to add superturle animation.
I couldn't draw the windows to my skyscrapers so, i though of using superturtle animation.However, I'm having trouble installing superturle. I did text my professor using discord about this issue. I have a feeling that I might have to change my intial project idea to something simple.
This commit is contained in:
11
animation.py
Normal file
11
animation.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from superturtle.animation import animate
|
||||||
|
from turtle import forward, right
|
||||||
|
|
||||||
|
def square(side_length):
|
||||||
|
for side in range(4):
|
||||||
|
forward(side_length)
|
||||||
|
right(90)
|
||||||
|
|
||||||
|
for frame in animate(40, loop=True):
|
||||||
|
size = frame.interpolate(50, 100, mirror=True)
|
||||||
|
square(size)
|
||||||
47
drawing.py
47
drawing.py
@@ -3,29 +3,38 @@
|
|||||||
# By Jannatun Uddin
|
# By Jannatun Uddin
|
||||||
#
|
#
|
||||||
# (Briefly describe what this program does.)
|
# (Briefly describe what this program does.)
|
||||||
|
from superturtle.animation import animate
|
||||||
|
from turtle import forward, left, penup, pendown, fillcolor, begin_fill, end_fill
|
||||||
|
|
||||||
import turtle
|
def draw_building(width, height, color="gray"):
|
||||||
def draw_building(width, height):
|
fillcolor(color)
|
||||||
|
begin_fill()
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
turtle.forward(width)
|
forward(width)
|
||||||
turtle.left(90)
|
left(90)
|
||||||
turtle.forward(height)
|
forward(height)
|
||||||
turtle.left(90)
|
left(90)
|
||||||
turtle.penup()
|
end_fill()
|
||||||
turtle.backward(90)
|
|
||||||
turtle.pendown()
|
|
||||||
|
|
||||||
draw_building(60,150)
|
# Animation loop
|
||||||
|
for frame in animate(40, loop=True):
|
||||||
|
brightness = int(frame.interpolate(100, 200, mirror=True))
|
||||||
|
|
||||||
turtle.penup()
|
|
||||||
turtle.forward(90)
|
|
||||||
turtle.pendown()
|
|
||||||
|
|
||||||
draw_building(40,100)
|
# First building
|
||||||
|
penup()
|
||||||
|
pendown()
|
||||||
|
draw_building(60, 100, color)
|
||||||
|
|
||||||
turtle.penup()
|
# Second building
|
||||||
turtle.forward(30)
|
penup()
|
||||||
turtle.pendown()
|
forward(80)
|
||||||
|
pendown()
|
||||||
|
draw_building(50, 120, color)
|
||||||
|
|
||||||
draw_building(50,150)
|
# Third building
|
||||||
turtle.done()
|
penup()
|
||||||
|
forward(70)
|
||||||
|
pendown()
|
||||||
|
draw_building(70, 90, color)
|
||||||
|
input()
|
||||||
Reference in New Issue
Block a user