generated from mwc/project_drawing
	For the last stage of my drawing project, I got stuck on the animation. I am not sure if I did something wrong or followed the wrong steps, but I was unable to animate my drawing which made me quite sad! I tried a few variations of animation such as translate and rotate, but none worked the way I intended. I am still happy with my drawing though. I wish we had more visual tutorials and maybe even class workshop times to come together and discuss these things because asking for help when everyone is working at their own pace and hours make it very awkward and inconvenient to reach out to others. I would eventually love to learn animation but I think timing of this project was not it.
		
			
				
	
	
		
			114 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
# drawing.py
 | 
						|
# ----------
 | 
						|
# By Challa Zirek
 | 
						|
#
 | 
						|
# (This project draws two ghosts, in theme of Halloween.)
 | 
						|
 | 
						|
import superturtle
 | 
						|
from superturtle import *
 | 
						|
from superturtle.animation import *
 | 
						|
import turtle
 | 
						|
from turtle import *
 | 
						|
import bezier
 | 
						|
import numpy as np
 | 
						|
 | 
						|
TurtleScreen=turtle.Screen
 | 
						|
turtle.bgcolor("#B04021")
 | 
						|
turtle.pensize(4)
 | 
						|
 | 
						|
def ghostie(length,x,y):
 | 
						|
    turtle.pencolor("#3C025E")
 | 
						|
    turtle.fillcolor("#B8B8B8")
 | 
						|
    penup()
 | 
						|
    turtle.goto(x,y)
 | 
						|
    pendown()
 | 
						|
    #Starts drawing the left side of the outline
 | 
						|
    turtle.begin_fill()
 | 
						|
    left(180)
 | 
						|
    circle(2*length, 90)
 | 
						|
    forward(3*length)
 | 
						|
    circle(-6*length,30)
 | 
						|
    left(170)
 | 
						|
    circle(5*length,30)
 | 
						|
    circle(-0.2*length,180)
 | 
						|
    print(pos())
 | 
						|
 | 
						|
    #Starts drawing the middle frill
 | 
						|
    xpos, ypos = turtle.pos()
 | 
						|
    points=np.array([
 | 
						|
        [xpos, (xpos+30), (xpos-70), (xpos+70), xpos],
 | 
						|
        [ypos, (ypos-48), (ypos-88), (ypos-148), (ypos-218)]
 | 
						|
    ])
 | 
						|
    curve = bezier.Curve(points, 4)  
 | 
						|
    s_vals = np.linspace(0,1,100)
 | 
						|
    bezierpoints= curve.evaluate_multi(s_vals)
 | 
						|
    for n in range(1, bezierpoints.shape[1]):
 | 
						|
        turtle.goto(bezierpoints[0][n], bezierpoints[1][n])
 | 
						|
    left(180)
 | 
						|
    points2=np.array([
 | 
						|
        [xpos, (xpos+90), (xpos+10), (xpos+40), (xpos+50)],
 | 
						|
        [(ypos-218), (ypos-178), (ypos-58), (ypos-28), ypos]
 | 
						|
    ])
 | 
						|
    curve2 = bezier.Curve(points2, 4)
 | 
						|
    s_vals = np.linspace(0,1,100)
 | 
						|
    bezierpoints2= curve2.evaluate_multi(s_vals)
 | 
						|
    for n in range(1, bezierpoints2.shape[1]):
 | 
						|
        turtle.goto(bezierpoints2[0][n], bezierpoints2[1][n])
 | 
						|
    
 | 
						|
    #Starts drawing the right side of the outline
 | 
						|
    circle(-0.2*length,180)
 | 
						|
    left(10)
 | 
						|
    circle(5*length,30)
 | 
						|
    left(171)
 | 
						|
    circle(-6*length,30)
 | 
						|
    forward(3*length)
 | 
						|
    circle(2*length, 90)
 | 
						|
    turtle.end_fill()
 | 
						|
 | 
						|
    #Starts drawing the face
 | 
						|
    def ghostieface(length,x,y):
 | 
						|
        turtle.fillcolor("#161616")
 | 
						|
        penup()
 | 
						|
        turtle.goto(x-20, y-50)
 | 
						|
        pendown()
 | 
						|
        turtle.begin_fill()
 | 
						|
        turtle.shape("circle")
 | 
						|
        turtle.stamp()
 | 
						|
        turtle.end_fill()
 | 
						|
        penup()
 | 
						|
        turtle.goto(x+20, y-50)
 | 
						|
        pendown()
 | 
						|
        turtle.begin_fill()
 | 
						|
        turtle.shape("circle")
 | 
						|
        turtle.stamp()
 | 
						|
        turtle.end_fill()
 | 
						|
        penup()
 | 
						|
        turtle.goto(x-5, y-90)
 | 
						|
        pendown()
 | 
						|
        left(95)
 | 
						|
        turtle.begin_fill()
 | 
						|
        turtle.shape("circle")
 | 
						|
        turtle.shapesize(stretch_len=2)
 | 
						|
        turtle.stamp()
 | 
						|
        turtle.shape("classic")
 | 
						|
        turtle.shapesize(1,1)
 | 
						|
        turtle.end_fill()          
 | 
						|
    ghostieface(length,x,y)
 | 
						|
 | 
						|
 | 
						|
ghostie(30, -150, 250)
 | 
						|
penup()
 | 
						|
turtle.home()
 | 
						|
pendown()
 | 
						|
ghostie (30, 150, 250)
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
turtle.done()
 |