用Python绘制青天白日旗和青天白日满地红旗,,青天白日旗:impo
用Python绘制青天白日旗和青天白日满地红旗,,青天白日旗:impo
青天白日旗:
import turtle as timport matht.colormode(255)rcblue=(4,0,174)def ol(r,n): na = 15 / 180 * math.pi ol=2*r*math.cos(na) ol=int(round(ol)) return oldef loop(r,n): t.fd(ol(r,n)) t.right(150)def main1(a,b): t.color(‘gray‘,rcblue) t.penup() t.right(90) t.fd(b/2) t.left(90) t.pendown() t.begin_fill() t.fd(a/2) t.left(90) t.fd(b) t.left(90) t.fd(a) t.left(90) t.fd(b) t.left(90) t.fd(a/2) t.end_fill() t.penup() t.goto(0,0) t.seth(0) t.pendown()def main2(r,n): t.pensize = 20 t.color(‘white‘, ‘white‘) t.penup() t.fd(r) t.right(180 - 30 / 2) t.pendown() t.begin_fill() for i in range(12): loop(r,n) t.end_fill() t.penup() t.goto(0,0) t.seth(0) t.pendown()def main3(r1,r2): t.color(rcblue, rcblue) # t.color(),not t.pencolor() t.begin_fill() t.up() t.right(90) t.fd(r1) t.left(90) t.pd() t.circle(r1) t.goto(0, 0) t.end_fill() t.color(‘white‘, ‘white‘) t.begin_fill() t.pu() t.right(90) t.fd(r2) t.left(90) t.pd() t.circle(r2) t.end_fill() t.penup() t.goto(0, 0) t.seth(0) t.pendown()def main(): r=a/4 n=8 r2=a/8 r1=b*17/80 main1(a,b) main2(r,n) main3(r1,r2)a=1020b=680t.setup(1000,700,100,0)main()t.done()
旗图:
青天白日满地红旗的核心还是绘制青天白日旗,需要注意坐标:
import turtle as timport matht.colormode(255)rcblue=(4,0,174)rcred=(254,0,0)def ol(r,n): na = 15 / 180 * math.pi ol=2*r*math.cos(na) ol=int(round(ol)) return oldef loop(r,n): t.fd(ol(r,n)) t.right(150)def main0(a,b): #没有循环和复杂角度操作的时候用goto比较快 t.color(rcred) t.penup() t.goto(-a/2,b/2) t.pendown() t.begin_fill() t.goto(-a/2,-b/2) t.goto(a/2,-b/2) t.goto(a/2,b/2) t.end_fill() t.penup() t.goto(-a/4,b/4) t.pendown()def main1(a1,b1): t.color(‘gray‘,rcblue) t.penup() t.right(90) t.fd(b1/2) t.left(90) t.pendown() t.begin_fill() t.fd(a1/2) t.left(90) t.fd(b1) t.left(90) t.fd(a1) t.left(90) t.fd(b1) t.left(90) t.fd(a1/2) t.end_fill() t.penup() t.goto(-a/4,b/4) t.seth(0) t.pendown()def main2(r,n): t.pensize = 20 t.color(‘white‘, ‘white‘) t.penup() t.fd(r) t.right(180 - 30 / 2) t.pendown() t.begin_fill() for i in range(12): loop(r,n) t.end_fill() t.penup() t.goto(-a/4,b/4) t.seth(0) t.pendown()def main3(r1,r2): t.color(rcblue, rcblue) # t.color(),not t.pencolor() t.begin_fill() t.up() t.right(90) t.fd(r1) t.left(90) t.pd() t.circle(r1) t.end_fill() t.penup() t.goto(-a/4,b/4) t.pendown() t.color(‘white‘, ‘white‘) t.begin_fill() t.pu() t.right(90) t.fd(r2) t.left(90) t.pd() t.circle(r2) t.end_fill() t.penup() t.goto(-a/4,b/4) t.seth(0) t.pendown()def main(a,b): a1 = a / 2 b1 = b / 2 r = a1 / 4 n = 8 r2 = a1 / 8 r1 = b1 * 17 / 80 main0(a,b) main1(a1,b1) main2(r,n) main3(r1,r2)a=1020b=680t.setup(1100,700,100,0)main(a,b)t.done()
旗图:
用Python绘制青天白日旗和青天白日满地红旗
相关内容
- python文档22-fixture详细介绍-作为参数传入,error和failed区
- python中使用Opencv进行人脸检测,,这两天学习了人脸识别
- 文件完整性hash验证demo(python脚本),,一个简单的文件
- Python输出特殊字符图形(一)大雁南飞,, 1 #condin
- Python 中的特殊双下划线方法,,python类内部部
- python两种生成md5的方法,,一. 使用md5包i
- 练习:python基础+字符串,,1、执行python
- Python数据结构之数字类型,,数字类型种类数字类型
- Python3中的open函数,,open(file,
- 在Windows上安装pytorch,,电脑环境为 :win
评论关闭