Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How python uses Turtle to draw snowflakes in the south

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how python uses Turtle to draw southern snowflakes. I hope you will get something after reading this article. Let's discuss it together.

Officially began to hit the code-the first snow pear fall!

(1) Environmental installation:

Old rules: Python, Pycharm, Turtle module.

(2) the speed of drawing:

Turtle.speed (7) # drawing speed, optional

(3) draw light blue areas:

Color ("black", "# 97CBFF") # Black line Fill color begin_fill () # start filling fd (100) # turn right 60 degrees for i in range (3): fd (100) left (120) fd (100) left (60) fd (100) right (120) fd (100) left (60) right (120) fd (100) right (180) # point the brush in the original direction end_fill ()

(4) draw light cyan areas:

Begin_fill () color ("black", "# 80FFFF") begin_fill () # start filling for i in range (3): fd (100) left (60) fd (100) right (120) fd (100) left (60) fd (100) left (120) end_fill () # filled

The effect is as follows:

Officially start hitting the code-the second snowflake blue ocean!

(1) Environmental installation:

Old rules: Python, Pycharm, Turtle module.

(2) attached source code:

Def snowflake (l, d): screen = turtle.Screen () # screen.bgpic ("my_q.jpg") screen.bgcolor ("blue") # background color adjustable turtle.tracer (0 0) if d > 0: for i in range (6): speed ("fastest") color ("white") # silver width (5) forward (l) snowflake (l / / 3, d-1) backward (l) left (60) if _ name__ = = "_ main__": snowflake 5) # adjustable shape parameters time.sleep (100) #

The effect is as follows:

Draw snapshots of different times and colors (1)--

Draw snapshots of different times and colors (2)--

Draw snapshots of different times and colors (3)--

After reading this article, I believe you have a certain understanding of "how python uses Turtle to draw southern snowflakes". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report