generated from mwc/project_drawing
	Somewhere I got stuck was: - I struggled setting up the bezier function. It took some time researching to understand what was happening. Something I figured out was: The bezier function. It looks so smooth! A strategy I used: Reading online forums for help, such as stackoverflow, various Python guide websites, etc. Something I'm wondering: I was wondering on how to parameterize the bezier control points, but thanks to Varun, I know now. Something I want to learn: Nothing specific at the moment. An idea for future: No new ideas at the moment.
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
# drawing.py
 | 
						|
# ----------
 | 
						|
# By Challa Zirek
 | 
						|
#
 | 
						|
# (Briefly describe what this program does.)
 | 
						|
 | 
						|
import turtle
 | 
						|
from turtle import *
 | 
						|
import bezier
 | 
						|
import numpy as np
 | 
						|
 | 
						|
def ghostie(length,x,y):
 | 
						|
    penup()
 | 
						|
    turtle.goto(-150,250)
 | 
						|
    pendown()
 | 
						|
    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())
 | 
						|
#How can I determine these points directly with respect to my starting point?
 | 
						|
    points=np.array([
 | 
						|
        [-189.48, -160, -260, -120, -189.48],
 | 
						|
        [78, 30, -10, -70, -140]
 | 
						|
    ])
 | 
						|
    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([
 | 
						|
        [-189.48, -100, -180, -150, -140],
 | 
						|
        [-140, -100, 20, 50, 78]
 | 
						|
    ])
 | 
						|
    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])
 | 
						|
    
 | 
						|
    circle(-0.2*length,180)
 | 
						|
    left(10)
 | 
						|
    circle(5*length,30)
 | 
						|
    left(170)
 | 
						|
    circle(-6*length,30)
 | 
						|
    forward(3*length)
 | 
						|
    circle(2*length, 90)
 | 
						|
 | 
						|
ghostie(30)
 | 
						|
penup()
 | 
						|
turtle.goto(0,0)
 | 
						|
turtle.done()
 |