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 to realize Olympic rings in turtle drawing of python standard library

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the python standard library turtle drawing how to achieve the Olympic rings related knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that everyone after reading this python standard library turtle drawing how to achieve the Olympic rings article will have a harvest, let's take a look.

The non-standard library used is still turtle, because its role in painting is still very important.

Import turtle as tle

Write a function to initialize some global parameters of the turtle brush.

Def init (): tle.pensize (20) init ()

This time we use a single global parameter, just set the width of the brush.

The following is to write a function to draw a circle, because the five circles are all the same size, which has something in common, so you can use a function to write the circle drawing process.

Def draw_cricle (circle_size=100,x=-250,y=-30,color='blue'): tle.penup () tle.goto (x, y) tle.pendown () tle.color (color) tle.circle

Call the circle drawing function to draw five rings of different colors, and finally generate the shape of the Olympic rings.

Draw_cricle (Xanzhonglu 250, Yoshiyun, 30 lemonade, coloring bluetooth) draw_cricle (Xerogramme, YYLL30, colorless, blackout) draw_cricle (Xerox, 250, Japanese, Lexus, Lexi, 30, Colorado, colors, greens, draw_cricle) draw_cricle (Xenlashi, 125, Lilium, Yellowship,) draw_cricle (xylene, 125, camera, 105, color, green, green')

Looked at the above operation process, the operation is still very simple, used to do a turtle learning material is still very nice.

After the above process is completed, the part of the drawing is completed, and finally to improve the logic. Because the drawing window is automatically closed after the drawing is completed, it has been closed without seeing it clearly after the drawing is completed. So, set the properties of the drawing window and OK.

Keep the window open after the drawing is completed

Screen = tle.Screen () screen.exitonclick () on the python standard library turtle drawing how to achieve the Olympic rings, this article is introduced here, thank you for reading! I believe that everyone has a certain understanding of "python standard library turtle drawing how to achieve the Olympic rings" knowledge, if you want to learn more knowledge, 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.

Share To

Development

Wechat

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

12
Report