Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

text animation python

import turtle
 ​
 window = turtle.Screen()
 window.bgcolor("black")
 ​
 # Whole pumpkin
 pumpkin = turtle.Turtle()
 pumpkin.hideturtle()
 pumpkin.color("orange")
 pumpkin.dot(200)
 ​
 # The turtle to "carve" the pumpkin
 carver = turtle.Turtle()
 ​
 # "Flatten" the lower part of the pumpkin
 carver.penup()
 carver.setposition(-200, -100)
 carver.pensize(60)
 carver.pendown()
 carver.forward(600)
 carver.pensize(2)
 ​
 def carve_pumpkin(colour):
     carver.color(colour)
 ​
     # Make eyes
     def make_eye(start, orientation):
         carver.setheading(0)
         carver.penup()
         carver.setposition(*start)
         carver.pendown()
         carver.begin_fill()
         carver.forward(orientation * 40)
         carver.setheading(orientation * 135)
         carver.forward(orientation * 70)
         carver.end_fill()
 ​
     make_eye((-50, 20), 1)
     make_eye((50, 20), -1)
 ​
     # Make mouth
     carver.penup()
     carver.setposition(-50, -30)
     carver.setheading(45)
     carver.pendown()
     carver.pensize(1)
     carver.begin_fill()
     for _ in range(5):
         carver.forward(15)
         carver.right(90)
         carver.forward(15)
         carver.left(90)
     carver.setheading(260)
     carver.forward(20)
     carver.setheading(180)
     carver.forward(99)
     carver.end_fill()
 ​
     # Make nose
     carver.penup()
     carver.setposition(0, 0)
     carver.setheading(90)
     carver.shape("triangle")
     carver.stamp()
 ​
 carve_pumpkin("black")
 ​
 turtle.done()
Comment

PREVIOUS NEXT
Code Example
Python :: Reverse an string Using Stack in Python 
Python :: Check status code urllib 
Python :: sqlalchemy convert row to dict 
Python :: read ms word with python 
Python :: how to not create a new line in python 
Python :: foreignkey as users from a user group django 
Python :: display multiple dataframe as table jupyter notebook 
Python :: how to convert python to exe 
Python :: py string in list 
Python :: skip to next iteration python 
Python :: iterating index array python 
Python :: python all permutations of a string 
Python :: decode multipart/form-data python lambda 
Python :: pytest - parameterizing tests 
Python :: raspi setup gpio 
Python :: how to go up levels in path python 
Python :: pythagorean theorem python 
Python :: how to define a class in python 
Python :: count no of nan in a 2d array python 
Python :: Use CSS in PHP Echo with Style Attribute 
Python :: how to read linux environment variable in python 
Python :: virtual env pyhton 
Python :: box plot python 
Python :: dict comprehension 
Python :: time.sleep() python 
Python :: python sort algorithm 
Python :: name, *line = input().split() 
Python :: try except 
Python :: series astype 
Python :: pandas if python 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =