查看: 22276|回复: 4

[Python] 【Python3】五星红旗源码及解析

[复制链接]
发表于 2020-8-11 18:48:41 | 显示全部楼层 |阅读模式
这是一个简单的Python教程,之前在红客(http://www.cnhonkerarmy.com/forum.php)发过,链接:http://www.cnhonkerarmy.com/forum.php?mod=viewthread&tid=251321&fromuid=1254105


解析:
import turtle    —— 这个我就不多说了哈
·背景:
turtle.setup(600,400,0,0)      —— 画布大小
turtle.bgcolor("red")     —— 画布颜色
·主星:
turtle.fillcolor("yellow")      —— 绘制图形的填充颜色(以下的都是)
turtle.color('yellow')      —— 设置画笔的颜色(以下的都是)
turtle.speed(10)      —— 这个是设定画笔的速度(以下的都是)
·第一颗星:
turtle.begin_fill()     —— 准备开始填充图形(以下的都是)
turtle.up()
turtle.goto(-280,100)      —— 设置画的位置(以下的都是)
turtle.down()
for i in range (5):    —— 把5依次赋值给i(以下的都是)
    turtle.forward(150)      —— 向当前画笔方向移动150像素长度(以下的都是)
    turtle.right(144)     —— 顺时针移动144°(以下的都是)
turtle.end_fill()     —— 填充完成(以下的都是)
·第二颗星:
turtle.begin_fill()
turtle.up()
turtle.goto(-100,180)
turtle.setheading(305)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.left(144)
turtle.end_fill()
·第三颗星:
turtle.begin_fill()
turtle.up()
turtle.goto(-50,110)
turtle.setheading(30)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()
·第四颗星:
turtle.begin_fill()
turtle.up()
turtle.goto(-40,50)
turtle.setheading(5)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()
·最后再设定一下画笔:
turtle.begin_fill()
turtle.up()
turtle.goto(-100,10)
turtle.setheading(300)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.left(144)
turtle.end_fill()
turtle.done()




源码:
[Python] 纯文本查看 复制代码
import turtle
turtle.setup(600,400,0,0)
turtle.bgcolor("red")
turtle.fillcolor("yellow")
turtle.color('yellow')
turtle.speed(10)
turtle.begin_fill()
turtle.up()
turtle.goto(-280,100)
turtle.down()
for i in range (5):
    turtle.forward(150)
    turtle.right(144)
turtle.end_fill()
turtle.begin_fill()
turtle.up()
turtle.goto(-100,180)
turtle.setheading(305)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.left(144)
turtle.end_fill()
turtle.begin_fill()
turtle.up()
turtle.goto(-50,110)
turtle.setheading(30)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()
turtle.begin_fill()
turtle.up()
turtle.goto(-40,50)
turtle.setheading(5)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()
turtle.begin_fill()
turtle.up()
turtle.goto(-100,10)
turtle.setheading(300)
turtle.down()
for i in range (5):
    turtle.forward(50)
    turtle.left(144)
turtle.end_fill()
turtle.done()


效果:
{BDCB5CB1-0166-4F82-AB98-3C9190BE0859}_20200506152441.jpg

评分

参与人数 1i币 +10 收起 理由
panadaa + 10 感谢分享

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

指导单位

江苏省公安厅

江苏省通信管理局

浙江省台州刑侦支队

DEFCON GROUP 86025

旗下站点

邮箱系统

应急响应中心

红盟安全

联系我们

官方QQ群:112851260

官方邮箱:security#ihonker.org(#改成@)

官方核心成员

Archiver|手机版|小黑屋| ( 沪ICP备2021026908号 )

GMT+8, 2025-3-7 02:58 , Processed in 0.021125 second(s), 11 queries , Gzip On, MemCache On.

Powered by ihonker.com

Copyright © 2015-现在.

  • 返回顶部