├── Images ├── Tesla.PNG ├── Doraemon.PNG ├── Pikachu.PNG ├── ironman.PNG ├── SpiralDesign.PNG ├── VibrantCircle.PNG ├── haxagonSpiral.PNG ├── rainbowstar.PNG └── Square Spirograph.PNG ├── HexagonSpiral.py ├── Square Spirograph.py ├── VibrantCircle.py ├── rainbowstar.py ├── LICENSE ├── ironman.py ├── README.md ├── Tesla.py ├── SpiralDesign.py ├── Doraemon.py └── Pikachu.py /Images/Tesla.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/Tesla.PNG -------------------------------------------------------------------------------- /Images/Doraemon.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/Doraemon.PNG -------------------------------------------------------------------------------- /Images/Pikachu.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/Pikachu.PNG -------------------------------------------------------------------------------- /Images/ironman.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/ironman.PNG -------------------------------------------------------------------------------- /Images/SpiralDesign.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/SpiralDesign.PNG -------------------------------------------------------------------------------- /Images/VibrantCircle.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/VibrantCircle.PNG -------------------------------------------------------------------------------- /Images/haxagonSpiral.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/haxagonSpiral.PNG -------------------------------------------------------------------------------- /Images/rainbowstar.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/rainbowstar.PNG -------------------------------------------------------------------------------- /Images/Square Spirograph.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insanecodes/Python-Turtle-Programs/HEAD/Images/Square Spirograph.PNG -------------------------------------------------------------------------------- /HexagonSpiral.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | colors = ['red', 'purple', 'blue', 'green', 'yellow', 'white'] 3 | speed(0) 4 | bgcolor('black') 5 | for x in range(200): 6 | pencolor(colors[x % 6]) 7 | width(2) 8 | forward(x*1.2) 9 | left(59) 10 | -------------------------------------------------------------------------------- /Square Spirograph.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | import turtle 3 | speed(0) 4 | bgcolor("black") 5 | pensize(3) 6 | for x in range (5): 7 | for colors in ["red","pink","blue","cyan","green","yellow","white"]: 8 | color(colors) 9 | left(12) 10 | for i in range(4): 11 | forward(200) 12 | left(90) 13 | turtle.done() -------------------------------------------------------------------------------- /VibrantCircle.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | t = turtle.Turtle() 4 | s = turtle.Screen() 5 | s.bgcolor("black") 6 | t.pencolor("red") 7 | 8 | a = 0 9 | b = 0 10 | t.speed(0) 11 | t.penup() 12 | t.goto(0, 200) 13 | t.pendown() 14 | while(True): 15 | t.forward(a) 16 | t.right(b) 17 | a+=3 18 | b+=1 19 | if b == 210: 20 | break 21 | t.hideturtle() 22 | 23 | turtle.done() -------------------------------------------------------------------------------- /rainbowstar.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | length=100 4 | size=400 5 | 6 | colors=['red','orange','yellow','green','blue','Indigo','violet'] 7 | 8 | turtle.speed(7) 9 | turtle.pensize(10) 10 | 11 | for i in colors: 12 | size=500 13 | turtle.penup() 14 | turtle.goto(-size/2,size/10) 15 | turtle.pendown() 16 | turtle.color(i) 17 | turtle.begin_fill() 18 | 19 | for j in range(5): 20 | turtle.fd(size) 21 | turtle.rt(144) 22 | turtle.end_fill() 23 | 24 | turtle.mainloop() 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Insanecodes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ironman.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | piece1=[[(-40, 120), (-70, 260), (-130, 230), (-170, 200), (-170, 100), (-160, 40), (-170, 10), (-150, -10), (-140, 10), (-40, -20), (0, -20)],[(0, -20), (40, -20), (140, 10), (150, -10), (170, 10), (160, 40), (170, 100), (170, 200), (130, 230), (70, 260), (40, 120), (0, 120)]] 3 | piece2=[[(-40, -30), (-50, -40), (-100, -46), (-130, -40), (-176, 0), (-186, -30), (-186, -40), (-120, -170), (-110, -210), (-80, -230), (-64, -210), (0, -210)],[(0, -210), (64, -210), (80, -230), (110, -210), (120, -170), (186, -40), (186, -30), (176, 0), (130, -40), (100, -46), (50, -40), (40, -30), (0, -30)]] 4 | piece3=[[(-60, -220), (-80, -240), (-110, -220), (-120, -250),(-90, -280), (-60, -260), (-30, -260), (-20, -250), (0, -250)],[(0, -250), (20, -250), (30, -260), (60, -260), (90, -280), (120, -250),(110, -220), (80, -240), (60, -220), (0, -220)]] 5 | turtle.hideturtle() 6 | turtle.bgcolor('black') 7 | turtle.setup(500,600) 8 | turtle.title("Ironman") 9 | piece1Goto=(0,120) 10 | piece2Goto=(0,-30) 11 | piece3Goto=(0,-220) 12 | turtle.speed(2) 13 | def draw_piece(piece,pieceGoto): 14 | turtle.penup() 15 | turtle.goto(pieceGoto) 16 | turtle.pendown() 17 | turtle.color('red') 18 | turtle.begin_fill() 19 | for i in range(len(piece[0])): 20 | x,y=piece[0][i] 21 | turtle.goto(x,y) 22 | 23 | for i in range(len(piece[1])): 24 | x,y=piece[1][i] 25 | turtle.goto(x,y) 26 | turtle.end_fill() 27 | draw_piece(piece1,piece1Goto) 28 | draw_piece(piece2,piece2Goto) 29 | draw_piece(piece3,piece3Goto) 30 | turtle.hideturtle() 31 | turtle.done() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Turtle Programs [![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com) 2 | ![](https://visitor-badge.glitch.me/badge?page_id=insanecodes.Python-Turtle-Programs) 3 | [![Stars](https://img.shields.io/github/stars/insanecodes/Python-Turtle-Programs)](https://github.com/insanecodes/Python-Turtle-Programs) 4 | [![Forks](https://img.shields.io/github/forks/insanecodes/Python-Turtle-Programs)](https://github.com/insanecodes/Python-Turtle-Programs/fork) 5 |
6 | Hi guys, This repository contains all of the source code of turtle programs. 7 | 8 | ## Table of Contents 9 | 10 | 1. [Introduction](#introduction) 11 | 2. [Pikachu](#pikachu) 12 | 3. [Rainbow Star](#rainbowstar) 13 | 4. [Hexagon Spiral](#hexagonspiral) 14 | 5. [Spiral Design](#spiraldesign) 15 | 6. [Vibrant Circle](#vibrantcircle) 16 | 7. [Square Spirograph](#squarespirograph) 17 | 8. [Tesla](#tesla) 18 | 9. [Doraemon](#doraemon) 19 | 10. [Ironman](#ironman) 20 | 21 | 22 | 23 | 24 | 25 | ## Introduction 26 | 27 | Turtle graphics is a popular way for introducing programming to kids. Virtual turtles can be programmed to move around the screen. The turtle draws lines as it moves. The "turtle" could look like the turtle animal, an arrow, or be invisibile. The user can write turtle programs that draw beautiful shapes and learn to program at the same time. 28 | 29 | The original Turtle software was developed by Wally Feurzig and Seymour Papert in 1966. 30 | 31 | ## Pikachu 32 | 33 | 34 | 35 | ## RainbowStar 36 | 37 | 38 | 39 | ## HexagonSpiral 40 | 41 | 42 | 43 | ## SpiralDesign 44 | 45 | 46 | 47 | ## VibrantCircle 48 | 49 | 50 | 51 | ## SquareSpirograph 52 | 53 | 54 | 55 | ## Tesla 56 | 57 | 58 | 59 | ## Doraemon 60 | 61 | 62 | 63 | ## Ironman 64 | 65 | 66 | 67 |
68 | 69 | ### Show some ❤️ by starring the repository! 70 | 71 |
72 | -------------------------------------------------------------------------------- /Tesla.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | t = turtle.Turtle() 4 | 5 | t.getscreen().bgcolor("red") 6 | t.pencolor("black") 7 | t.speed(10) 8 | 9 | t.color("white") 10 | t.penup() 11 | t.goto(-160,160) 12 | t.pendown() 13 | 14 | t.begin_fill() 15 | t.left(18) 16 | t.circle(-500,40) 17 | t.right(90) 18 | t.forward(17) 19 | 20 | t.right(89.5) 21 | t.circle(500,39) 22 | t.right(90) 23 | t.forward(17) 24 | t.end_fill() 25 | 26 | 27 | t.penup() 28 | t.goto(-155,133) 29 | t.pendown() 30 | 31 | t.begin_fill() 32 | t.right(90.5) 33 | t.circle(-500,38) 34 | t.right(70) 35 | t.circle(-30,80) 36 | t.left(90) 37 | t.circle(-20,-70) 38 | t.right(10) 39 | t.circle(-300,-15) 40 | t.right(93) 41 | t.forward(280) 42 | t.right(160) 43 | t.forward(280) 44 | t.left(80) 45 | t.circle(300,15) 46 | t.circle(20,70) 47 | t.left(80) 48 | t.circle(30,-80) 49 | t.end_fill() 50 | 51 | t.penup() 52 | t.goto(-20,155) 53 | t.pendown() 54 | t.pencolor("black") 55 | t.color("red") 56 | t.begin_fill() 57 | t.left(30) 58 | t.forward(60) 59 | t.left(130) 60 | t.forward(65) 61 | t.end_fill() 62 | 63 | #T 64 | t.pencolor("white") 65 | t.penup() 66 | t.goto(-200,-180) 67 | t.pendown() 68 | t.right(66) 69 | 70 | t.pensize(15) 71 | t.forward(60) 72 | t.back(30) 73 | t.right(90) 74 | t.forward(70) 75 | 76 | #E 77 | t.penup() 78 | t.goto(-115,-180) 79 | t.pendown() 80 | t.left(90) 81 | t.forward(60) 82 | t.penup() 83 | t.goto(-115,-215) 84 | t.pendown() 85 | t.forward(60) 86 | t.penup() 87 | t.goto(-115,-250) 88 | t.pendown() 89 | t.forward(60) 90 | 91 | #S 92 | t.penup() 93 | t.goto(-20,-180) 94 | t.pendown() 95 | t.forward(60) 96 | t.backward(60) 97 | t.right(90) 98 | t.forward(34) 99 | t.left(90) 100 | t.forward(60) 101 | t.right(90) 102 | t.forward(34) 103 | t.right(90) 104 | t.forward(60) 105 | 106 | #L 107 | 108 | t.penup() 109 | t.goto(70,-180) 110 | t.pendown() 111 | t.left(90) 112 | t.forward(70) 113 | t.left(90) 114 | t.forward(60) 115 | 116 | #A 117 | 118 | t.penup() 119 | t.goto(155,-180) 120 | t.pendown() 121 | t.forward(60) 122 | 123 | t.penup() 124 | t.goto(155,-250) 125 | t.pendown() 126 | t.left(90) 127 | t.forward(32.5) 128 | t.right(90) 129 | t.forward(60) 130 | t.right(90) 131 | t.forward(32.5) 132 | 133 | turtle.done() -------------------------------------------------------------------------------- /SpiralDesign.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | turtle.setup(width=600, height=500) 3 | turtle.reset() 4 | turtle.hideturtle() 5 | turtle.title("Spiral Design Pattern") 6 | turtle.speed(0) 7 | 8 | turtle.bgcolor('black') 9 | 10 | c = 0 11 | x = 0 12 | 13 | colors = [ 14 | #red 15 | (1.00, 0.00, 0.00),(1.00, 0.03, 0.00),(1.00, 0.05, 0.00),(1.00, 0.07, 0.00),(1.00, 0.10, 0.00),(1.00, 0.12, 0.00),(1.00, 0.15, 0.00),(1.00, 0.17, 0.00),(1.00, 0.20, 0.00),(1.00, 0.23, 0.00),(1.00, 0.25, 0.00),(1.00, 0.28, 0.00),(1.00, 0.30, 0.00),(1.00, 0.33, 0.00),(1.00, 0.35, 0.00),(1.00, 0.38, 0.00),(1.00, 0.40, 0.00),(1.00, 0.42, 0.00),(1.00, 0.45, 0.00),(1.00, 0.47, 0.00), 16 | #orange 17 | (1.00, 0.50, 0.00),(1.00, 0.53, 0.00),(1.00, 0.55, 0.00),(1.00, 0.57, 0.00),(1.00, 0.60, 0.00),(1.00, 0.62, 0.00),(1.00, 0.65, 0.00),(1.00, 0.68, 0.00),(1.00, 0.70, 0.00),(1.00, 0.72, 0.00),(1.00, 0.75, 0.00),(1.00, 0.78, 0.00),(1.00, 0.80, 0.00),(1.00, 0.82, 0.00),(1.00, 0.85, 0.00),(1.00, 0.88, 0.00),(1.00, 0.90, 0.00),(1.00, 0.93, 0.00),(1.00, 0.95, 0.00),(1.00, 0.97, 0.00), 18 | #yellow 19 | (1.00, 1.00, 0.00),(0.95, 1.00, 0.00),(0.90, 1.00, 0.00),(0.85, 1.00, 0.00),(0.80, 1.00, 0.00),(0.75, 1.00, 0.00),(0.70, 1.00, 0.00),(0.65, 1.00, 0.00),(0.60, 1.00, 0.00),(0.55, 1.00, 0.00),(0.50, 1.00, 0.00),(0.45, 1.00, 0.00),(0.40, 1.00, 0.00),(0.35, 1.00, 0.00),(0.30, 1.00, 0.00),(0.25, 1.00, 0.00),(0.20, 1.00, 0.00),(0.15, 1.00, 0.00),(0.10, 1.00, 0.00),(0.05, 1.00, 0.00), 20 | #green 21 | (0.00, 1.00, 0.00),(0.00, 0.95, 0.05),(0.00, 0.90, 0.10),(0.00, 0.85, 0.15),(0.00, 0.80, 0.20),(0.00, 0.75, 0.25),(0.00, 0.70, 0.30),(0.00, 0.65, 0.35),(0.00, 0.60, 0.40),(0.00, 0.55, 0.45),(0.00, 0.50, 0.50),(0.00, 0.45, 0.55),(0.00, 0.40, 0.60),(0.00, 0.35, 0.65),(0.00, 0.30, 0.70),(0.00, 0.25, 0.75),(0.00, 0.20, 0.80),(0.00, 0.15, 0.85),(0.00, 0.10, 0.90),(0.00, 0.05, 0.95), 22 | #blue 23 | (0.00, 0.00, 1.00),(0.05, 0.00, 1.00),(0.10, 0.00, 1.00),(0.15, 0.00, 1.00),(0.20, 0.00, 1.00),(0.25, 0.00, 1.00),(0.30, 0.00, 1.00),(0.35, 0.00, 1.00),(0.40, 0.00, 1.00),(0.45, 0.00, 1.00),(0.50, 0.00, 1.00),(0.55, 0.00, 1.00),(0.60, 0.00, 1.00),(0.65, 0.00, 1.00),(0.70, 0.00, 1.00),(0.75, 0.00, 1.00),(0.80, 0.00, 1.00),(0.85, 0.00, 1.00),(0.90, 0.00, 1.00),(0.95, 0.00, 1.00) 24 | ] 25 | 26 | while x < 700: 27 | idx = int(c) 28 | color = colors[idx] 29 | turtle.color(color) 30 | turtle.forward(x) 31 | turtle.right(98) 32 | x = x + 1 33 | c = c + 0.1 34 | 35 | turtle.exitonclick() -------------------------------------------------------------------------------- /Doraemon.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | 3 | 4 | def my_goto(x, y): 5 | penup() 6 | goto(x, y) 7 | pendown() 8 | 9 | 10 | def eyes(): 11 | fillcolor("#ffffff") 12 | begin_fill() 13 | 14 | tracer(False) 15 | a = 2.5 16 | for i in range(120): 17 | if 0 <= i < 30 or 60 <= i < 90: 18 | a -= 0.05 19 | lt(3) 20 | fd(a) 21 | else: 22 | a += 0.05 23 | lt(3) 24 | fd(a) 25 | tracer(True) 26 | end_fill() 27 | 28 | 29 | def beard(): 30 | my_goto(-32, 135) 31 | seth(165) 32 | fd(60) 33 | 34 | my_goto(-32, 125) 35 | seth(180) 36 | fd(60) 37 | 38 | my_goto(-32, 115) 39 | seth(193) 40 | fd(60) 41 | 42 | my_goto(37, 135) 43 | seth(15) 44 | fd(60) 45 | 46 | my_goto(37, 125) 47 | seth(0) 48 | fd(60) 49 | 50 | my_goto(37, 115) 51 | seth(-13) 52 | fd(60) 53 | 54 | 55 | def mouth(): 56 | my_goto(5, 148) 57 | seth(270) 58 | fd(100) 59 | seth(0) 60 | circle(120, 50) 61 | seth(230) 62 | circle(-120, 100) 63 | 64 | 65 | def scarf(): 66 | fillcolor('#e70010') 67 | begin_fill() 68 | seth(0) 69 | fd(200) 70 | circle(-5, 90) 71 | fd(10) 72 | circle(-5, 90) 73 | fd(207) 74 | circle(-5, 90) 75 | fd(10) 76 | circle(-5, 90) 77 | end_fill() 78 | 79 | 80 | def nose(): 81 | my_goto(-10, 158) 82 | seth(315) 83 | fillcolor('#e70010') 84 | begin_fill() 85 | circle(20) 86 | end_fill() 87 | 88 | 89 | def black_eyes(): 90 | seth(0) 91 | my_goto(-20, 195) 92 | fillcolor('#000000') 93 | begin_fill() 94 | circle(13) 95 | end_fill() 96 | 97 | pensize(6) 98 | my_goto(20, 205) 99 | seth(75) 100 | circle(-10, 150) 101 | pensize(3) 102 | 103 | my_goto(-17, 200) 104 | seth(0) 105 | fillcolor('#ffffff') 106 | begin_fill() 107 | circle(5) 108 | end_fill() 109 | my_goto(0, 0) 110 | 111 | 112 | def face(): 113 | 114 | fd(183) 115 | lt(45) 116 | fillcolor('#ffffff') 117 | begin_fill() 118 | circle(120, 100) 119 | seth(180) 120 | fd(121) 121 | pendown() 122 | seth(215) 123 | circle(120, 100) 124 | end_fill() 125 | my_goto(63.56, 218.24) 126 | seth(90) 127 | eyes() 128 | seth(180) 129 | penup() 130 | fd(60) 131 | pendown() 132 | seth(90) 133 | eyes() 134 | penup() 135 | seth(180) 136 | fd(64) 137 | 138 | 139 | def head(): 140 | penup() 141 | circle(150, 40) 142 | pendown() 143 | fillcolor('#00a0de') 144 | begin_fill() 145 | circle(150, 280) 146 | end_fill() 147 | 148 | 149 | def Doraemon(): 150 | head() 151 | 152 | scarf() 153 | 154 | face() 155 | 156 | nose() 157 | 158 | mouth() 159 | 160 | beard() 161 | 162 | my_goto(0, 0) 163 | seth(0) 164 | penup() 165 | circle(150, 50) 166 | pendown() 167 | seth(30) 168 | fd(40) 169 | seth(70) 170 | circle(-30, 270) 171 | 172 | fillcolor('#00a0de') 173 | begin_fill() 174 | 175 | seth(230) 176 | fd(80) 177 | seth(90) 178 | circle(1000, 1) 179 | seth(-89) 180 | circle(-1000, 10) 181 | 182 | 183 | seth(180) 184 | fd(70) 185 | seth(90) 186 | circle(30, 180) 187 | seth(180) 188 | fd(70) 189 | 190 | seth(100) 191 | circle(-1000, 9) 192 | 193 | seth(-86) 194 | circle(1000, 2) 195 | seth(230) 196 | fd(40) 197 | 198 | 199 | circle(-30, 230) 200 | seth(45) 201 | fd(81) 202 | seth(0) 203 | fd(203) 204 | circle(5, 90) 205 | fd(10) 206 | circle(5, 90) 207 | fd(7) 208 | seth(40) 209 | circle(150, 10) 210 | seth(30) 211 | fd(40) 212 | end_fill() 213 | 214 | seth(70) 215 | fillcolor('#ffffff') 216 | begin_fill() 217 | circle(-30) 218 | end_fill() 219 | 220 | my_goto(103.74, -182.59) 221 | seth(0) 222 | fillcolor('#ffffff') 223 | begin_fill() 224 | fd(15) 225 | circle(-15, 180) 226 | fd(90) 227 | circle(-15, 180) 228 | fd(10) 229 | end_fill() 230 | 231 | my_goto(-96.26, -182.59) 232 | seth(180) 233 | fillcolor('#ffffff') 234 | begin_fill() 235 | fd(15) 236 | circle(15, 180) 237 | fd(90) 238 | circle(15, 180) 239 | fd(10) 240 | end_fill() 241 | 242 | my_goto(-133.97, -91.81) 243 | seth(50) 244 | fillcolor('#ffffff') 245 | begin_fill() 246 | circle(30) 247 | end_fill() 248 | 249 | my_goto(-103.42, 15.09) 250 | seth(0) 251 | fd(38) 252 | seth(230) 253 | begin_fill() 254 | circle(90, 260) 255 | end_fill() 256 | 257 | my_goto(5, -40) 258 | seth(0) 259 | fd(70) 260 | seth(-90) 261 | circle(-70, 180) 262 | seth(0) 263 | fd(70) 264 | 265 | my_goto(-103.42, 15.09) 266 | fd(90) 267 | seth(70) 268 | fillcolor('#ffd200') 269 | begin_fill() 270 | circle(-20) 271 | end_fill() 272 | seth(170) 273 | fillcolor('#ffd200') 274 | begin_fill() 275 | circle(-2, 180) 276 | seth(10) 277 | circle(-100, 22) 278 | circle(-2, 180) 279 | seth(180-10) 280 | circle(100, 22) 281 | end_fill() 282 | goto(-13.42, 15.09) 283 | seth(250) 284 | circle(20, 110) 285 | seth(90) 286 | fd(15) 287 | dot(10) 288 | my_goto(0, -150) 289 | 290 | black_eyes() 291 | 292 | 293 | if __name__ == '__main__': 294 | screensize(800, 600, "#f0f0f0") 295 | pensize(3) 296 | speed(9) 297 | Doraemon() 298 | my_goto(100, -300) 299 | mainloop() 300 | -------------------------------------------------------------------------------- /Pikachu.py: -------------------------------------------------------------------------------- 1 | #pikachu animation using python-turtle 2 | import turtle 3 | def getPosition(x, y): 4 | turtle.setx(x) 5 | turtle.sety(y) 6 | print(x, y) 7 | 8 | 9 | class Pikachu: 10 | def __init__(self): 11 | self.t = turtle.Turtle() 12 | t = self.t 13 | t.pensize(3) 14 | t.speed(9) 15 | t.ondrag(getPosition) 16 | 17 | def noTrace_goto(self, x, y): 18 | self.t.penup() 19 | self.t.goto(x, y) 20 | self.t.pendown() 21 | 22 | def leftEye(self, x, y): 23 | self.noTrace_goto(x, y) 24 | t = self.t 25 | t.seth(0) 26 | t.fillcolor('#333333') 27 | t.begin_fill() 28 | t.circle(22) 29 | t.end_fill() 30 | 31 | self.noTrace_goto(x, y+10) 32 | t.fillcolor('#000000') 33 | t.begin_fill() 34 | t.circle(10) 35 | t.end_fill() 36 | 37 | self.noTrace_goto(x+6, y + 22) 38 | t.fillcolor('#ffffff') 39 | t.begin_fill() 40 | t.circle(10) 41 | t.end_fill() 42 | 43 | def rightEye(self, x, y): 44 | self.noTrace_goto(x, y) 45 | t = self.t 46 | t.seth(0) 47 | t.fillcolor('#333333') 48 | t.begin_fill() 49 | t.circle(22) 50 | t.end_fill() 51 | 52 | self.noTrace_goto(x, y+10) 53 | t.fillcolor('#000000') 54 | t.begin_fill() 55 | t.circle(10) 56 | t.end_fill() 57 | 58 | self.noTrace_goto(x-6, y + 22) 59 | t.fillcolor('#ffffff') 60 | t.begin_fill() 61 | t.circle(10) 62 | t.end_fill() 63 | 64 | def mouth(self, x, y): 65 | self.noTrace_goto(x, y) 66 | t = self.t 67 | 68 | t.fillcolor('#88141D') 69 | t.begin_fill() 70 | # lower lip 71 | l1 = [] 72 | l2 = [] 73 | t.seth(190) 74 | a = 0.7 75 | for i in range(28): 76 | a += 0.1 77 | t.right(3) 78 | t.fd(a) 79 | l1.append(t.position()) 80 | 81 | self.noTrace_goto(x, y) 82 | 83 | t.seth(10) 84 | a = 0.7 85 | for i in range(28): 86 | a += 0.1 87 | t.left(3) 88 | t.fd(a) 89 | l2.append(t.position()) 90 | 91 | # Upper lip 92 | t.seth(10) 93 | t.circle(50, 15) 94 | t.left(180) 95 | t.circle(-50, 15) 96 | 97 | t.circle(-50, 40) 98 | t.seth(233) 99 | t.circle(-50, 55) 100 | t.left(180) 101 | t.circle(50, 12.1) 102 | t.end_fill() 103 | 104 | # tongue 105 | self.noTrace_goto(17, 54) 106 | t.fillcolor('#DD716F') 107 | t.begin_fill() 108 | t.seth(145) 109 | t.circle(40, 86) 110 | t.penup() 111 | for pos in reversed(l1[:20]): 112 | t.goto(pos[0], pos[1]+1.5) 113 | for pos in l2[:20]: 114 | t.goto(pos[0], pos[1]+1.5) 115 | t.pendown() 116 | t.end_fill() 117 | 118 | # nose 119 | self.noTrace_goto(-17, 94) 120 | t.seth(8) 121 | t.fd(4) 122 | t.back(8) 123 | 124 | # Red cheeks 125 | def leftCheek(self, x, y): 126 | turtle.tracer(False) 127 | t = self.t 128 | self.noTrace_goto(x, y) 129 | t.seth(300) 130 | t.fillcolor('#DD4D28') 131 | t.begin_fill() 132 | a = 2.3 133 | for i in range(120): 134 | if 0 <= i < 30 or 60 <= i < 90: 135 | a -= 0.05 136 | t.lt(3) 137 | t.fd(a) 138 | else: 139 | a += 0.05 140 | t.lt(3) 141 | t.fd(a) 142 | t.end_fill() 143 | turtle.tracer(True) 144 | 145 | def rightCheek(self, x, y): 146 | t = self.t 147 | turtle.tracer(False) 148 | self.noTrace_goto(x, y) 149 | t.seth(60) 150 | t.fillcolor('#DD4D28') 151 | t.begin_fill() 152 | a = 2.3 153 | for i in range(120): 154 | if 0 <= i < 30 or 60 <= i < 90: 155 | a -= 0.05 156 | t.lt(3) 157 | t.fd(a) 158 | else: 159 | a += 0.05 160 | t.lt(3) 161 | t.fd(a) 162 | t.end_fill() 163 | turtle.tracer(True) 164 | 165 | def colorLeftEar(self, x, y): 166 | t = self.t 167 | self.noTrace_goto(x, y) 168 | t.fillcolor('#000000') 169 | t.begin_fill() 170 | t.seth(330) 171 | t.circle(100, 35) 172 | t.seth(219) 173 | t.circle(-300, 19) 174 | t.seth(110) 175 | t.circle(-30, 50) 176 | t.circle(-300, 10) 177 | t.end_fill() 178 | 179 | def colorRightEar(self, x, y): 180 | t = self.t 181 | self.noTrace_goto(x, y) 182 | t.fillcolor('#000000') 183 | t.begin_fill() 184 | t.seth(300) 185 | t.circle(-100, 30) 186 | t.seth(35) 187 | t.circle(300, 15) 188 | t.circle(30, 50) 189 | t.seth(190) 190 | t.circle(300, 17) 191 | t.end_fill() 192 | 193 | def body(self): 194 | t = self.t 195 | 196 | t.fillcolor('#F6D02F') 197 | t.begin_fill() 198 | # Right face Contour 199 | t.penup() 200 | t.circle(130, 40) 201 | t.pendown() 202 | t.circle(100, 105) 203 | t.left(180) 204 | t.circle(-100, 5) 205 | 206 | # Right ear 207 | t.seth(20) 208 | t.circle(300, 30) 209 | t.circle(30, 50) 210 | t.seth(190) 211 | t.circle(300, 36) 212 | 213 | # upper profile 214 | t.seth(150) 215 | t.circle(150, 70) 216 | 217 | # left ear 218 | t.seth(200) 219 | t.circle(300, 40) 220 | t.circle(30, 50) 221 | t.seth(20) 222 | t.circle(300, 35) 223 | # print(t.pos()) 224 | 225 | # Left face contour 226 | t.seth(240) 227 | t.circle(105, 95) 228 | t.left(180) 229 | t.circle(-105, 5) 230 | 231 | # left hand 232 | t.seth(210) 233 | t.circle(500, 18) 234 | t.seth(200) 235 | t.fd(10) 236 | t.seth(280) 237 | t.fd(7) 238 | t.seth(210) 239 | t.fd(10) 240 | t.seth(300) 241 | t.circle(10, 80) 242 | t.seth(220) 243 | t.fd(10) 244 | t.seth(300) 245 | t.circle(10, 80) 246 | t.seth(240) 247 | t.fd(12) 248 | t.seth(0) 249 | t.fd(13) 250 | t.seth(240) 251 | t.circle(10, 70) 252 | t.seth(10) 253 | t.circle(10, 70) 254 | t.seth(10) 255 | t.circle(300, 18) 256 | 257 | t.seth(75) 258 | t.circle(500, 8) 259 | t.left(180) 260 | t.circle(-500, 15) 261 | t.seth(250) 262 | t.circle(100, 65) 263 | 264 | # left foot 265 | t.seth(320) 266 | t.circle(100, 5) 267 | t.left(180) 268 | t.circle(-100, 5) 269 | t.seth(220) 270 | t.circle(200, 20) 271 | t.circle(20, 70) 272 | 273 | t.seth(60) 274 | t.circle(-100, 20) 275 | t.left(180) 276 | t.circle(100, 20) 277 | t.seth(300) 278 | t.circle(10, 70) 279 | 280 | t.seth(60) 281 | t.circle(-100, 20) 282 | t.left(180) 283 | t.circle(100, 20) 284 | t.seth(10) 285 | t.circle(100, 60) 286 | 287 | 288 | t.seth(180) 289 | t.circle(-100, 10) 290 | t.left(180) 291 | t.circle(100, 10) 292 | t.seth(5) 293 | t.circle(100, 10) 294 | t.circle(-100, 40) 295 | t.circle(100, 35) 296 | t.left(180) 297 | t.circle(-100, 10) 298 | 299 | # Right foot 300 | t.seth(290) 301 | t.circle(100, 55) 302 | t.circle(10, 50) 303 | 304 | t.seth(120) 305 | t.circle(100, 20) 306 | t.left(180) 307 | t.circle(-100, 20) 308 | 309 | t.seth(0) 310 | t.circle(10, 50) 311 | 312 | t.seth(110) 313 | t.circle(100, 20) 314 | t.left(180) 315 | t.circle(-100, 20) 316 | 317 | t.seth(30) 318 | t.circle(20, 50) 319 | 320 | t.seth(100) 321 | t.circle(100, 40) 322 | 323 | # Right body contour 324 | t.seth(200) 325 | t.circle(-100, 5) 326 | t.left(180) 327 | t.circle(100, 5) 328 | t.left(30) 329 | t.circle(100, 75) 330 | t.right(15) 331 | t.circle(-300, 21) 332 | t.left(180) 333 | t.circle(300, 3) 334 | 335 | # Right hand 336 | t.seth(43) 337 | t.circle(200, 60) 338 | 339 | t.right(10) 340 | t.fd(10) 341 | 342 | t.circle(5, 160) 343 | t.seth(90) 344 | t.circle(5, 160) 345 | t.seth(90) 346 | 347 | t.fd(10) 348 | t.seth(90) 349 | t.circle(5, 180) 350 | t.fd(10) 351 | 352 | t.left(180) 353 | t.left(20) 354 | t.fd(10) 355 | t.circle(5, 170) 356 | t.fd(10) 357 | t.seth(240) 358 | t.circle(50, 30) 359 | 360 | t.end_fill() 361 | self.noTrace_goto(130, 125) 362 | t.seth(-20) 363 | t.fd(5) 364 | t.circle(-5, 160) 365 | t.fd(5) 366 | 367 | # Fingerprint 368 | self.noTrace_goto(166, 130) 369 | t.seth(-90) 370 | t.fd(3) 371 | t.circle(-4, 180) 372 | t.fd(3) 373 | t.seth(-90) 374 | t.fd(3) 375 | t.circle(-4, 180) 376 | t.fd(3) 377 | 378 | # tail 379 | self.noTrace_goto(168, 134) 380 | t.fillcolor('#F6D02F') 381 | t.begin_fill() 382 | t.seth(40) 383 | t.fd(200) 384 | t.seth(-80) 385 | t.fd(150) 386 | t.seth(210) 387 | t.fd(150) 388 | t.left(90) 389 | t.fd(100) 390 | t.right(95) 391 | t.fd(100) 392 | t.left(110) 393 | t.fd(70) 394 | t.right(110) 395 | t.fd(80) 396 | t.left(110) 397 | t.fd(30) 398 | t.right(110) 399 | t.fd(32) 400 | 401 | t.right(106) 402 | t.circle(100, 25) 403 | t.right(15) 404 | t.circle(-300, 2) 405 | t.seth(30) 406 | t.fd(40) 407 | t.left(100) 408 | t.fd(70) 409 | t.right(100) 410 | t.fd(80) 411 | t.left(100) 412 | t.fd(46) 413 | t.seth(66) 414 | t.circle(200, 38) 415 | t.right(10) 416 | t.fd(10) 417 | t.end_fill() 418 | 419 | # Tail pattern 420 | t.fillcolor('#923E24') 421 | self.noTrace_goto(126.82, -156.84) 422 | t.begin_fill() 423 | 424 | t.seth(30) 425 | t.fd(40) 426 | t.left(100) 427 | t.fd(40) 428 | t.pencolor('#923e24') 429 | t.seth(-30) 430 | t.fd(30) 431 | t.left(140) 432 | t.fd(20) 433 | t.right(150) 434 | t.fd(20) 435 | t.left(150) 436 | t.fd(20) 437 | t.right(150) 438 | t.fd(20) 439 | t.left(130) 440 | t.fd(18) 441 | t.pencolor('#000000') 442 | t.seth(-45) 443 | t.fd(67) 444 | t.right(110) 445 | t.fd(80) 446 | t.left(110) 447 | t.fd(30) 448 | t.right(110) 449 | t.fd(32) 450 | t.right(106) 451 | t.circle(100, 25) 452 | t.right(15) 453 | t.circle(-300, 2) 454 | t.end_fill() 455 | 456 | # Hat, eyes, mouth, cheeks 457 | self.cap(-134.07, 147.81) 458 | self.mouth(-5, 25) 459 | self.leftCheek(-126, 32) 460 | self.rightCheek(107, 63) 461 | self.colorLeftEar(-250, 100) 462 | self.colorRightEar(140, 270) 463 | self.leftEye(-85, 90) 464 | self.rightEye(50, 110) 465 | t.hideturtle() 466 | 467 | def cap(self, x, y): 468 | self.noTrace_goto(x, y) 469 | t = self.t 470 | t.fillcolor('#CD0000') 471 | t.begin_fill() 472 | t.seth(200) 473 | t.circle(400, 7) 474 | t.left(180) 475 | t.circle(-400, 30) 476 | t.circle(30, 60) 477 | t.fd(50) 478 | t.circle(30, 45) 479 | t.fd(60) 480 | t.left(5) 481 | t.circle(30, 70) 482 | t.right(20) 483 | t.circle(200, 70) 484 | t.circle(30, 60) 485 | t.fd(70) 486 | t.right(35) 487 | t.fd(50) 488 | t.circle(8, 100) 489 | t.end_fill() 490 | self.noTrace_goto(-168.47, 185.52) 491 | t.seth(36) 492 | t.circle(-270, 54) 493 | t.left(180) 494 | t.circle(270, 27) 495 | t.circle(-80, 98) 496 | 497 | t.fillcolor('#444444') 498 | t.begin_fill() 499 | t.left(180) 500 | t.circle(80, 197) 501 | t.left(58) 502 | t.circle(200, 45) 503 | t.end_fill() 504 | 505 | self.noTrace_goto(-58, 270) 506 | t.pencolor('#228B22') 507 | t.dot(35) 508 | 509 | self.noTrace_goto(-30, 280) 510 | t.fillcolor('#228B22') 511 | t.begin_fill() 512 | t.seth(100) 513 | t.circle(30, 180) 514 | t.seth(190) 515 | t.fd(15) 516 | t.seth(100) 517 | t.circle(-45, 180) 518 | t.right(90) 519 | t.fd(15) 520 | t.end_fill() 521 | t.pencolor('#000000') 522 | 523 | def start(self): 524 | self.body() 525 | 526 | 527 | def main(): 528 | print('Started Painting the Pikachu... ') 529 | turtle.screensize(800, 600) 530 | turtle.title('Pikachu') 531 | pikachu = Pikachu() 532 | pikachu.start() 533 | turtle.mainloop() 534 | 535 | 536 | if __name__ == '__main__': 537 | main() 538 | --------------------------------------------------------------------------------