Get the App
SLTechnology News&Howtos  ›  Development  › 

How python uses Turtle to draw snowflakes in the south

Shulou Source: shulou.com Published: 2022-06-03 08:33:42 09月12日 Update

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!

Tags: Color snowflake different time code area effect module environment article old rule speed adjustable drawing pixel parameter finished shape point direction Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker Shulou Technology Redmi OPPO Reno