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 draw Chinese knots with Python turtle

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

Share

Shulou(Shulou.com)06/01 Report--

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!

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: 221

*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