In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you how to write the love expression code of the villain painting in python, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Introduction
hello! I am Muzi, and it's time for today's update!
Let's see what to write.
The editor has a good brother who has been chasing girls recently, making out with girls! All I need is a kick at the door. I helped to make up for this jio.
He asked if there were any cool ways to express his love, which could be tempted to catch up with jio. There were many ways to express his love.
Today Muzi is going to teach you a little man who was very popular before to draw a love confession code!
Text
Turtle library is the basic drawing library of python, this library is very convenient to use, after learning some basic information, it will soon be the first choice for editor drawing!
First, draw love.
Import turtleimport time # draw a heart arc def hart_arc (): for i in range (2) turtle.right (1) turtle.forward (2) def move_pen_position (x, y): turtle.hideturtle () # Hidden brush (first) turtle.up () # pick up turtle.goto (x Y) # move the brush to the specified starting coordinates (window center is 0P0) turtle.down () # Down turtle.showturtle () # Show brush # initialize turtle.setup (width=800, height=500) # window (canvas) size turtle.color ('red' 'pink') # Brush Color turtle.pensize (5) # Brush thickness turtle.speed (1) # paint Speed # initialize brush start coordinates move_pen_position Moving brush position turtle.left (140) # rotate 140 degrees left turtle.begin_fill () # Mark background fill position # draw heart line (lower left) turtle.forward (224) # move the brush forward Length: 224 # draw love arc hart_arc () # left arc turtle.left (120) # adjust brush angle hart_arc () # right arc # draw heart line (lower right) turtle.forward (224) turtle.end_fill () # Mark background fill end position # Click window close program window = turtle.Screen () window.exitonclick ()
The effect is as follows:
Secondly, draw little people.
Import turtle as tfrom time import sleepdef go_to (x, y): t.up () t.goto (x, y) t.down () def head (x, y, r): go_to (x, y) t.speed (20) t.circle (r) leg (x, y) def leg (x Y): t.right, t.forward, t.right, 30, t.forward, t.left, go_to, x, y-180, t.forward, t.right, t.forward, t.left, hand (x, y) def hand (x, y): go_to Y-60) t.forward t.left (60) t.forward (100) go_to (x, y-90) t.right (60) t.forward (100) t.right (60) t.forward (100) t.left (60) eye (x, y) def eye (x, y): go_to (x-50) Y + 130) t.right (90) t.forward (50) go_to (x + 40) Y + 130) t.forward (50) t.left (90) def big_Circle (size): t.speed (20) for i in range (150): t.forward (size) t.right (0.3) def line (size): t.speed (20) t.forward (51 * size) def small_Circle (size): t.speed (20) for i in range (210): T.forward (size) t.right (0.786) def heart (x Y, size): go_to (x, y) t.left (150) t.begin_fill () line (size) big_Circle (size) small_Circle (size) t.left (120) small_Circle (size) big_Circle (size) line (size) t.end_fill ()
The effect is as follows:
Finally, add text
T.write ("To: do you know what my weakness is?", move=True, align= "left", font= ("To", 20, "normal"))
The effect is as follows:
The above content is the python villain painting love confession code how to write, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.