Python's Turtle module advances the turtle and draws at different angles. You might think it's a little messy, but the details are easy to understand ** (methods are also introduced) **. Reference URL: http://www.ic.daito.ac.jp/~mizutani/python/using_turtle.html
The IDE I tried is as follows. ・ Xcode ・ Pycharm ·Terminal
Try Turtle with simple code.
from turtle import *
shape()
done()
Then, the window was displayed as below.
By default, the arrow is just pointing to the right and nothing is drawn. Let's make it a little turtle-like. Enter 'turtle' in shape ().
from turtle import *
shape('turtle')
done()
The arrow displayed in the window is now Mr. Turtle. It's unique.
By the way, if you run it in the terminal, you don't need done (). If you forget done () in Xcode or Pycharm, you will think that the screen is displayed and it disappears in an instant. Please try once.
Let's move the turtle.
from turtle import *
shape('turtle')
forward(90)
done()
The turtle has advanced a little.
Let the turtle draw a square. The idea of cord is to move 90 ° to the left and repeat n distances after moving n distances.
from turtle import *
shape('turtle')
for i in xrange(4):
forward(90)
left(90)
done()
Now you know what the Turtle module looks like. Then, it is the main subject. I will share the source code for drawing Mickey Mouse, so Please try it in your environment! !!
https://github.com/Cremokoroah/Turtle_MM
There should be an easier way to draw, so I would like to improve it. Thank you very much.
Recommended Posts