Get the App
SLTechnology News&Howtos  ›  Development  › 

How to draw Chinese knots with Python turtle

Shulou Source: shulou.com Published: 2022-06-01 18:29:39 09月10日 Update

This article mainly introduces "how to draw Chinese knots with Python turtle". In daily operation, I believe many people have doubts about how to draw Chinese knots with Python turtle. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "how to draw Chinese knots with Python turtle". Next, please follow the editor to study!

1. China knot 01 Ping an Happy 1) effect picture

2) attached code import turtleturtle.screensize (600800) turtle.pensize (10) turtle.pencolor ("red") turtle.seth (- 45) turtle.fd (102c) turtle.circle (- 6180) turtle.fd (6180) turtle.circle (6180) turtle.fd (- 6180) turtle.fd (6180) turtle.circle (6180) turtle.fd (6180) turtle.circle (6180) turtle.fd (92) turtle.circle (- 6270) ) turtle.fd (92) turtle.circle (6180) turtle.fd (- 6180) turtle.fd (6180) turtle.circle (6180) turtle.circle (- 6180) turtle.fd (6180) turtle.circle (6180) turtle.circle (- 6180) turtle.fd (88) turtle.fd (20) turtle.seth turtle.fd (20) turtle.seth (20) turtle.fd (20) turtle.seth (315) turtle. Fd (20) turtle.seth (45) turtle.fd (20) turtle.seth (20) turtle.begin_fill ("red") turtle.fd (50) turtle.seth (45) turtle.fd (30) turtle.seth (- 45) turtle.fd (30) turtle.seth (30) turtle.fd (30) turtle.end_fill () turtle.seth (90) turtle.fd (40) turtle.pensize (20) turtle.fd (10) turtle.pensize (5) turtle.seth Turtle.fd (30) turtle.circle (- 8240) turtle.circle (20, 20) turtle.fd (5) turtle.circle (20, 60) turtle.fd (25) turtle.penup () turtle.setx (0) turtle.sety (0) turtle.goto (2) Turtle.pendown () turtle.pensize (5) turtle.begin_fill () turtle.fillcolor ("red") turtle.seth (0) turtle.fd (15) turtle.seth (- 90) turtle.fd (10) turtle.seth (10) turtle.fd (15) turtle.seth (90) turtle.fd (10) turtle.seth (0) turtle.fd (15) turtle.end_fill (2) for x in range (6): turtle.seth (- 90) Turtle.fd (50) turtle.penup () turtle.seth (90) turtle.fd (50) turtle.seth (180) turtle.fd (3) turtle.pendown () II. China knot 02 wishes come true 1) effect picture

2) attached code import turtle as tdef goto (XQuery y): t.penup () t.goto (XMague y) t.pendown () def init (): t.setup (800800) t.pensize (10) t.pencolor ("red") t.speed (14) def jiexin (): mQuery ninja 0200 for i in range (11): goto (m N) t.seth (- 45) t.fd (2) m-=20/pow (2) n-=20/pow (2) n-=20/pow (2) m journal 0200 for j in range (11): goto (m) N) t.seth (- 135) t.fd (200) m+=20/pow (2) n-=20/pow (2) def jiexiaoban (): m=-20/pow (2) (0.5) nasty 200-20/pow (2) for k in range (4): goto (m N) t.seth (135i) t.fd (20) t.circle (10180) t.fd (20) m-=40/pow (2p 0.5) n-=40/pow (2pm 0.5) m=20/pow (2le 0.5) nasty 200-20/pow (2pm 0.5) for k in range (4): goto (m N) t.seth (45) t.fd (20) t.circle (- 10180) t.fd (20) m+=40/pow (2Lot0.5) n-=40/pow (2L0.5) m=20/pow (2PM0.5) nymph200-200*pow (2L0.5) + 20/pow (2L0.5) for k in range (4): goto (m N) t.seth (- 45) t.fd (20) t.circle (10180) t.fd (20) m+=40/pow (2Lot0.5) n+=40/pow (2L0.5) m=-20/pow (2PM0.5) nymph200-200*pow (2L0.5) + 20/pow (2L0.5) for k in range (4): goto (m N) t.seth (- 135R) t.fd (20) t.circle (- 10180) t.fd (20) m-=40/pow (2pm 0.5) n+=40/pow (2pm 0.5) def waiyuan (): goto (90*pow (2pm 0.5) T.seth (- 45) t.circle (20270) goto (- 90*pow), t.circle (- 20270) goto (80*pow), 120*pow (2)) t.seth (- 45) t.circle (40270) goto (- 80*pow) Def shengzi (): goto (0200) t.pensize (20) t.seth (90) t.fd (60) goto (0320) t.pensize (12) t.seth (30360) t.circle (30360) goto (0200-200*pow) t.pensize (40) T.seth (- 90) t.fd (20) t.pensize (2) for i in range 20 for i in range (11): goto (s) Def hanzi (): goto (- 150325) t.write ("Happy Chinese Knot", font= ("Arial", 40) "normal") def main (): init () jiexin () jiexiaoban () waiyuan () shengzi () hanzi () t.hideturtle () 3. China Jie03 fireworks year after year

Ci Muer, fireworks year after year, bright future, Shuisui Kang'an.

At this point, the study on "how to draw Chinese knots with Python turtle" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: China Chinese knot learning code effect effect more fireworks help joy practicality success happiness wish come true next bright future article method theory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Huawei Linux Docker macOS