generated from mwc/project_drawing
I got stuck on super turtle animuation. Everytime I try to open drawing.py it wouldn't open. Then, my instructor helped me by telling me to type poetry shell and it worked. Additionally, I want to learn more about superturtle because i was a little confused about the codes.
53 lines
1.0 KiB
Python
53 lines
1.0 KiB
Python
# drawing.py
|
|
# ----------
|
|
# By Jannatun Uddin
|
|
#
|
|
# (It makes 3 buildings that flicker from dark gray and gets dimmer.Also, if tou look closely at the buildings you can see it get closer too.)
|
|
from superturtle.animation import animate
|
|
from turtle import forward, left, right, backward, penup, pendown, begin_fill, end_fill, pencolor, fillcolor
|
|
|
|
def draw_building(width, height, color="gray"):
|
|
pencolor(color)
|
|
fillcolor(color)
|
|
begin_fill()
|
|
for i in range(2):
|
|
forward(width)
|
|
left(90)
|
|
forward(height)
|
|
left(90)
|
|
end_fill()
|
|
|
|
# This is an Animation
|
|
for frame in animate(40, loop=True):
|
|
shade = int(frame.interpolate(100, 200, mirror=True))
|
|
color = f"#{shade:02x}{shade:02x}{shade:02x}"
|
|
|
|
penup()
|
|
backward(200)
|
|
pendown()
|
|
|
|
# Building 1
|
|
draw_building(60, 200, color)
|
|
|
|
# Building 2
|
|
penup()
|
|
forward(80)
|
|
pendown()
|
|
draw_building(50, 120, color)
|
|
|
|
# Building 3
|
|
penup()
|
|
forward(70)
|
|
pendown()
|
|
draw_building(90, 300, color)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|