Python|Use turtle brush to make Olympic rings

1 Foreword

Recently, I learned that it is very interesting to use python's turtle to draw pictures, so I learned some simple painting basic codes on the Internet to complete the classic Olympic rings pattern.

2 Actual operation

First prepare the python environment (if you don't need to download it first), after the environment is ready, use the built-in module turtle in python and then run the code.

Code:

import turtle as t

t.pensize(10)

t.pencolor("black")

t.circle(100)

t.penup()

t.goto(150,0)

t.pendown()

t.pencolor("red")

t.circle(100)

t.left(180)

t.penup()

t.goto(-150,0)

t.left(180)

t.pendown()

t.pencolor("blue")

t.circle(100)

t.left(90)

t.penup()

t.goto(0,0)

t.pendown()

t.pencolor("yellow")

t.circle(100)

t.right(180)

t.pencolor("green")

t.circle(100)

t.speed(0)

Then run to the rendering:

3 to sum up

In the process of writing pictures, you must pay attention to the position of the pen, pay attention to the coordinates, accurately control the pen drop point, and pay attention to the symmetrical image format.

END

Edit | Wang Wenxing

Responsible Editor | Long Daozheng

Recommended Posts

Python|Use turtle brush to make Olympic rings