generated from mwc/project_drawing
Here i wrote the code for drawing the full butterfly by calling the other functions. I just put temprorary values to just get the program to work for now. I will be asjusting it next submit. I also realized why it wasnt working before..i never called any function! The program now works, but need adjustments. I struggled with the bakground color so i simply looked up how to choose a background color on python on google and found an easy solution.
55 lines
922 B
Python
55 lines
922 B
Python
# drawing.py
|
|
# ----------
|
|
# By Mishaal
|
|
#
|
|
# The program draws a butterfly
|
|
|
|
from turtle import *
|
|
|
|
from turtle import forward, right
|
|
from superturtle.movement import fly, no_delay
|
|
|
|
import turtle
|
|
|
|
screen = turtle.Screen()
|
|
screen.bgcolor("cadetblue")
|
|
|
|
def draw_oval(width, height, color):
|
|
fillcolor(color)
|
|
begin_fill()
|
|
for i in range(2):
|
|
circle(width, 90)
|
|
circle(height, 90)
|
|
end_fill()
|
|
|
|
def draw_wing(x, y, width, height, color, angle):
|
|
penup()
|
|
goto(x, y)
|
|
setheading(angle)
|
|
pendown()
|
|
draw_oval(width, height, color)
|
|
|
|
|
|
def draw_body():
|
|
penup()
|
|
goto(0,-100)
|
|
setheading(90)
|
|
pendown()
|
|
draw_oval(10,45,"black")
|
|
|
|
def draw_butterfly():
|
|
draw_body()
|
|
|
|
draw_wing(-10,-60, 60, 120, "purple",120)
|
|
draw_wing(-10,-40, 40, 60, "pink", 130)
|
|
|
|
draw_wing(10,-60, 60, 120, "purple",120)
|
|
draw_wing(10,-40, 40, 60, "pink", 130)
|
|
|
|
|
|
draw_butterfly()
|
|
|
|
|
|
|
|
|
|
input() |