日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python画八卦图

發布時間:2024/1/8 python 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python画八卦图 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

畫八卦圖,需要思路和計算

可以用turtle的粗畫筆來實現挖空操作?

import turtle # 創建一個新的畫布 win = turtle.Screen() # 設置窗口大小和背景顏色 win.setup(500,500) win.bgcolor("white") # 創建一個turtle對象 t = turtle.Turtle() #設置八卦圖大小 r = 100 # 畫圓 t.speed(10) t.penup() t.goto(0,-r) t.pendown() t.circle(r) # 畫上下部分的黑色圓弧 t.penup() t.goto(0,0) t.pendown() t.begin_fill() t.pencolor("black") t.fillcolor("black") t.circle(r/2,180) t.circle(r,180) t.circle(r/2,-180) t.end_fill() # 添加兩個小圓點 t.pencolor("black") t.fillcolor("white") t.begin_fill() t.penup() t.goto(0,r/2) t.pendown() t.circle(r/15) t.end_fill() t.pencolor("black") t.fillcolor("black") t.begin_fill() t.penup() t.goto(0,-r/2) t.pendown() t.circle(r/15) t.end_fill() # 三個八邊形 t.pensize(12) t.pencolor("black") t.penup() t.goto(-45,108) t.seth(360) t.pendown() for i in range(8):t.forward(90)t.right(45) t.penup() t.goto(-55,132) t.seth(360) t.pendown() for i in range(8):t.forward(110)t.right(45) t.penup() t.goto(-65,156) t.seth(360) t.pendown() for i in range(8):t.forward(130)t.right(45) # 畫白線 t.penup() t.pencolor("white") t.pensize(12) t.goto(-42,100.8) t.pendown() t.seth(112.5) t.forward(300) t.pensize(12) t.penup() t.goto(42,100.8) t.pendown() t.seth(67.5) t.forward(300) t.pensize(12) t.penup() t.goto(85,85) t.pendown() t.seth(45) t.forward(300) t.pensize(12) t.penup() t.goto(100.8,42) t.pendown() t.seth(22.5) t.forward(300) t.pensize(12) t.penup() t.goto(105.5,0) t.pendown() t.seth(0) t.forward(35) t.pensize(12) t.penup() t.goto(100.8,-42) t.pendown() t.seth(-22.5) t.forward(300) t.pensize(12) t.penup() t.goto(108,-108) t.pendown() t.seth(-45) t.forward(300) t.pensize(12) t.penup() t.goto(42,-100.8) t.pendown() t.seth(-67.5) t.forward(300) t.penup() t.goto(-42,-100.8) t.pendown() t.seth(-112.5) t.forward(300) t.penup() t.goto(-74.5,-74.5) t.pendown() t.seth(-135) t.forward(300) t.penup() t.goto(-100.8,-42) t.pendown() t.seth(-157.5) t.forward(300) t.penup() t.goto(-105.5,0) t.pendown() t.seth(-180) t.forward(13) t.penup() t.goto(-100.8,42) t.pendown() t.seth(-202.5) t.forward(300) t.penup() t.goto(0,105.5) t.pendown() t.seth(90) t.forward(10) t.penup() t.goto(0,150) t.pendown() t.seth(90) t.forward(30) t.penup() t.goto(0,-127) t.pendown() t.seth(-90) t.forward(12) # 隱藏turtle t.hideturtle() # 程序圖形化界面待用戶關閉 turtle.done()

?

總結

以上是生活随笔為你收集整理的python画八卦图的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。