In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to draw love with python code" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope this "how to use python code to draw love" article can help you solve the problem.
Code:
Effect picture:
But looking from left to right, I found that the logic behind it, such as the parameters of forward () and right (), was not very straightforward, so I pushed it again with the simplest way of thinking:
The first step is to start from the position of the "heart tip" and draw a straight line to the upper left corner with an angle of 45 degrees from the y-axis:
In the second step, the top of the heart is an arc, which can be designed to start with the original slope and draw a semicircle for every unit of progress.
The third step is basically repeated on the right side, but if you adjust the rotation angle, the relationship between the corresponding parameters can also be easily deduced:
OK follows this line of thinking, and the very simple code is as follows:
Import turtle# set a windowwn = turtle.Screen () wn.bgcolor ("black") wn.screensize # set a penpen = turtle.Turtle () pen.color ("pink") pen.shape ("turtle") # the brush shape is set to a very lovely turtle hhpen.fillcolor ("pink") turtle.speed (10) # define functionsdef curve (): for i in range (180): pen.right (1) pen.forward (2) def heart (): pen.left (135) pen.forward (720mp 3.14) curve ( ) pen.left (90) curve () pen.forward (720 enter the words 3.14) def text (): pen.penup () pen.setpos (- 50, 50) pen.pendown () pen.color ("white") pen.write (input ("enter the words:") Font = ("Verdana", 30, "bold")) # paintingcake pen.beginfilled fill () pen.penup () pen.setpos (0mermer150) pen.pendown () heart () pen.end_fill () turtle.done ()
Effect!
This is the end of the content about "how to draw love with python code". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.