In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to draw a bat chart with Python". 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 bat chart with Python.
Preface
Halloween is coming!
Today I will give you a simple tutorial to draw a bat.
Bat ears
Before drawing, we need to introduce the turtle library needed for drawing. The code is as follows:
Import turtlet = turtle.Pen ()
After importing the library, we still create a new brush called t.
Next, we do a little analysis of this bat.
In the turtle drawing, the entire screen is separated by such a coordinate system, and the middle position of the screen is (0Power0), which is the initial position of the turtle.
Let's assume that each grid represents 10 pixels on the screen. Can you calculate the coordinates of the bat's ears?
OK, let's write a short piece of code first and see if what we draw is correct!
T.forward (10) t.goto (200.30)
A sharp corner has been drawn!
Next, find the coordinates of the point under the bat's ear!
The wings of a bat
It seems that we need to draw some curves next. Do you remember how to draw curves?
Using the circle () method, we can draw a circle, or a half circle, or a stroke of 4 circles!
Pay attention to the direction of brush t!
Next we will adjust the direction of the brush t to the right, and then draw a straight line.
T.right (90) t.forward (100)
Here, we draw a circle with a radius of 100 and an angle of 90 degrees!
Use the code to draw this part!
T.left (180) t.circle (100pl 90)
The code is as follows:
T.setheading (180) t.circle
Let's take a look at the pattern!
The first is the first green circle:
T.left (180) t.circle
Then there is the second blue circle:
T.right (90) t.circle (100per 90)
Don't forget next!
We still need to turn around and draw the rest of the bat, which needs to be done carefully compared to the previous code.
T.right (180) t.fd (100) t.right (90) t.circle (40) t.goto (- 20) t.goto (- 10) t.goto (0)
You can use t.hideturtle () to hide the brush t so that it looks more perfect!
At this point, I believe you have a deeper understanding of "how to draw a bat chart with Python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.