zoukankan      html  css  js  c++  java
  • 基于python的turtle模块画国旗

    基于python的turtle模块画国旗,愿祖国早日战胜病毒

    • 画国旗是很严肃的问题,一定要按照规定去画
    • 国旗宽高比为:3:2
    • 国旗标准图
    • 绘制五角星需要严格的计算
    • 科学计算器网站:http://www.ab126.com/
    • 知道三角函数值求角度方法,使用excel =ASIN(A1)*180/PI()
    import turtle
    
    # 设置画笔速度和画布大小和位置
    turtle.speed(10)
    turtle.setup(650, 450)
    # 画国旗大背景
    # 移动画笔需要先把笔抬起来
    turtle.up()
    turtle.goto(-300, 200)
    turtle.down()
    turtle.begin_fill()
    turtle.fillcolor("red")
    turtle.pencolor("red")
    # 画出边界
    for i in range(2):
        turtle.forward(600)
        turtle.right(90)
        turtle.forward(400)
        turtle.right(90)
    # 填充国旗颜色
    turtle.end_fill()
    
    # 画大五角星
    turtle.up()
    turtle.goto(-200, 160)
    turtle.seth(-72)
    turtle.down()
    turtle.begin_fill()
    turtle.fillcolor("yellow")
    turtle.pencolor("yellow")
    for x in range(5):
        turtle.forward(120)
        turtle.right(144)
    turtle.end_fill()
    
    # 画第一个小五角星
    turtle.up()
    turtle.goto(-100 - 17.3145, 160 - 6.174)
    turtle.seth(48.96347)
    turtle.down()
    turtle.begin_fill()
    turtle.fillcolor("yellow")
    turtle.pencolor("yellow")
    for x in range(5):
        turtle.forward(38.0417418)
        turtle.right(144)
    turtle.end_fill()
    
    # 画第二个小五角星
    turtle.up()
    turtle.goto(-60 - 19.7948663580, 120 - 2.857143)
    turtle.seth(36.213211)
    turtle.down()
    turtle.begin_fill()
    turtle.fillcolor("yellow")
    turtle.pencolor("yellow")
    for x in range(5):
        turtle.forward(38.0417418)
        turtle.right(144)
    turtle.end_fill()
    
    # 画第三个小五角星
    turtle.up()
    turtle.goto(-60 - 19.5, 60 + 5.714285848)
    turtle.seth(5)
    turtle.down()
    turtle.begin_fill()
    turtle.fillcolor("yellow")
    turtle.pencolor("yellow")
    for x in range(5):
        turtle.forward(38.0417418)
        turtle.right(144)
    turtle.end_fill()
    
    # 画第四个小五角星
    turtle.up()
    turtle.goto(-100 - 17.2, 20 + 15.99999)
    turtle.seth(-35.1301)
    turtle.down()
    turtle.begin_fill()
    turtle.fillcolor("yellow")
    turtle.pencolor("yellow")
    for x in range(5):
        turtle.forward(38.0417418)
        turtle.right(144)
    turtle.end_fill()
    
    # 写文字
    turtle.up()
    turtle.goto(0, -100)
    turtle.pencolor('violet')
    turtle.write('武汉加油,中国加油!', move=True, align='center', font=('华文新魏', 30, 'normal'))
    
    # 隐藏画笔,绘画完成
    turtle.hideturtle()
    turtle.done()
    

    效果图

    版权声明:本文为博主原创文章,转载请附上博文链接!
  • 相关阅读:
    最课程阶段大作业03:用半天实现淘宝首页?
    最课程阶段大作业02:实现自己的利息计算器
    最课程阶段大作业之01:使用SVN实现版本控制
    Java全栈程序员之01:做个Linux下的程序猿
    最课程学员启示录:这么PL的小姐姐你要不要
    学员优秀博文赏析:泛型通配符及约束
    魅族便签,是否能成为国内便签应用的No.1?
    Ubuntu上安装git和创建工作区和提交文件!!!
    OpenGL核心技术之HDR
    病毒木马查杀实战第020篇:Ring3层主动防御之基本原理
  • 原文地址:https://www.cnblogs.com/zq98/p/15028023.html
Copyright © 2011-2022 走看看