Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Olympic rings in turtle drawing of python standard library

Shulou Source: shulou.com Published: 2022-05-31 17:42:35 10月03日 Update

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.

Tags: Drawing Olympic Games standard five rings function circle or knowledge process global content parameter brush article learning difference importance value function commonness Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Redmi Huawei vpn