Python Drawing (Turtle module)

Source: Internet
Author: User

With Python's turtle module you can draw a lot of beautiful graphics, the following is a brief introduction to how to use.

The tool that needs to be used has Python,python installation here is no longer elaborate. Search by yourself.

1  fromTurtleImport*#Introducing the Turtle module2Color'Red','Yellow')#set the color and fill color of the drawing3 4 #Turtle Settings5Hideturtle ()#Hide Arrows6Speed (10)#Set Speed7 #move back, turn left, go right.8FD (100)#forward 100 megapixels (forward (100) can also)9Right (90)#turn right 90 °TenBack (100) # back 100 pixels OneLeft (90) # Turn left 90° A #Fill Color - Begin_fill () #开始填充位置 -FillColor ('Yellow') #填充颜色 the dosomethinghere () #绘制你想绘制的图形 - End_fill () #结束填充位置 - #lift the pen and put down the pens so that the operation does not leave traces (the fill color will be displayed) - Penup () + Goto (Start_pos) - fd (RADIUS) +Pendown ()

Here are a few simple examples

1 "Draw single pentagram

1  fromTurtleImport*2Color'Red','Yellow')3 Begin_fill ()4 Hideturtle ()5Speed (10)6  whileTrue:7Forward (200)8Right (144)9     ifABS (POS ()) < 1:Ten          Break One End_fill () ADone ()

The effect is as follows:

2 "Draw a Gemini Star

1  fromTurtleImport*2Color'Red','Yellow')3 Begin_fill ()4 Hideturtle ()5Speed (10)6  whileTrue:7Forward (200)8Right (144)9     ifABS (POS ()) < 1:Ten          Break One  whileTrue: ABack (200) -Left (144) -     ifABS (POS ()) < 1: the          Break - End_fill () -Done ()

As follows:

3. Mapping of mother and child stars

1  fromTurtleImport*2Color'Red','Yellow')3 Begin_fill ()4 Hideturtle ()5Speed (10)6  whileTrue:7Forward (200)8Right (144)9     ifABS (POS ()) < 1:Ten          Break One  whileTrue: AForward (400) -Right (144) -     ifABS (POS ()) < 1: the          Break - End_fill () -Done ()

As follows:

4 "Draw Double flower

1  fromTurtleImport*2 3 4Speed (10)5Color'Red','Yellow')6 Begin_fill ()7  whileTrue:8Forward (200)9Right (164)Ten     ifABS (POS ()) < 1: One          Break A  whileTrue: -Back (200) -Left (164) the     ifABS (POS ()) < 1: -          Break - End_fill () -Done ()

As follows:

Try it out for the rest of the way, and you'll draw more incredible graphic patterns.

Python Drawing (Turtle module)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.