How to use python turtle Library to draw Christmas Tree
This article mainly explains "how to draw a Christmas tree with python turtle library". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to draw a Christmas tree with the python turtle library.
First of all, our goal is as follows:
So what's his ingredient? There are Christmas tree bodies, large and small bows, stars, Christmas hats and socks.
First of all, let's draw the body of the Christmas tree.
1. The Noumenon of Christmas Tree
The body of the Christmas tree looks like this:
Code:
Class TreeBackBone (): def _ init__ (self): pencolor ("pink") pensize (10) self.layer1 () self.layer2 () self.layer3 () self.layer4 () self.trunk () def layer1 (self): penup () hideturtle () goto (0) Showturtle () pendown () shape (name= "classic") seth (- 120) for i in range (10): fd (12) right (2) penup () goto (0) Seth (- 60) pendown () for i in range (10): fd (12) left (2) seth (- 150) penup () fd (10) pendown () for i in range (5): fd (10) right (15) seth (- Penup () fd (8) pendown () for i in range (5): fd (10) right (15) seth (- 155) penup () fd (5) pendown () for i in range (5): fd (7) right (15) Def layer2 (self): penup () goto (- 55 34) pendown () seth (- 120) for i in range (10): fd (8) right (5) penup () goto (50) 35) seth (- 60) pendown () for i in range (10): fd (8) left (5) seth (- 120) penup () fd (10) seth (- 145) pendown () for i in range (5): fd (10) right ( 15) penup () fd (10) seth (- 145) pendown () for i in range (5): fd (12) right (15) penup () fd (8) seth (- 145) pendown () for i in range (5): fd (10) Right (15) penup () seth (- 155) fd (8) pendown () for i in range (5): fd (11) right (15) def layer3 (self): penup () goto (- 100) -40) seth (- 120) pendown () for i in range (10): fd (6) right (3) penup () goto (80) -39) seth (- 50) pendown () for i in range (10): fd (6) left (3) seth (- 155) penup () fd (10) pendown () for i in range (5): fd (8) right (10) penup () fd (8) seth (- 145) pendown () for i in range (7): fd (8) right (10) penup () fd (8) seth (- 145) pendown () for i in range (7): fd (7) right (10) ) penup () fd (8) seth (- 145) pendown () for i in range (7): fd (7) right (10) penup () fd (8) seth (- 140) pendown () for i in range (7): fd (6) Right (10) def layer4 (self): penup () goto -95) seth (- 130) pendown () for i in range (7): fd (10) right (5) penup () goto (100) -95) seth (- 50) pendown () for i in range (7): fd (10) left (5) penup () seth (- 120) fd (10) seth (- 155) pendown () for i in range (6): fd (8) Right (10) penup () seth (- 160) fd (10) seth (- 155) pendown () for i in range (6): fd (8) right (10) penup () seth (- 160) fd (10) seth (- 155) pendown () For i in range (6): fd (8) right (10) penup () seth (- 160C) fd (10) seth (- 160C) pendown () for i in range (6): fd (8) right (10) penup () seth (- 160C) Fd (10) seth (- 160) pendown () for i in range (6): fd (8) right (10) penup () seth (- 160) fd (10) seth (- 165) pendown () for i in range (5): fd (10) Right (11) def trunk (self): penup () goto (- 70 Seth (- 85) pendown () for i in range (3): fd (5) left (3) penup () goto (70) Seth (- 95) pendown () for i in range (3): fd (5) right (3) seth (- 170) penup () fd (10) pendown () pendown () for i in range (10): fd (12) right ( 2) penup () goto (70 Pendown () seth (- 90) pensize (8) pencolor ("# de8891") circle (- 20,90) penup () goto (30,185) pendown () seth (- 180) pensize (8) pencolor ("# de8891") fd (40) penup () goto (- 5) Pendown () seth (- 180) pensize (8) pencolor ("# de8891") fd (35) right_up (- 70,150,160) right_up (100,150,160) right_down (110,110,50) right_up (160,140,150) clockwise (80,120) Right_up (70,-85,165) right_up (- 40,85,165) right_down (90,-50,50) right_up (130,80,150) pencolor ("pink") clockwise (- 40,60,180) pencolor ('# de8891') clockwise (80,-30) Pencolor ("pink") clockwise (40,10,180) pencolor ("# de8891") right_up (- 60,30,120) right_up (- 20,150) right_down (45,40,60) right_up (- 30,40,170) right_up (- 30,110,115) right_down (40,90) 60) right_up (80,50,160) pencolor ("# de8891") 2. Bow knot
Next, let's draw a small bow as a decoration, and each bow grows this sub-son.