用python函数画德国国旗代码_求一段python中用class方法绘制国旗的代码!记得不是常见的海龟做法!这个星期给我再加送财富点!...
展开全部
from matplotlib import patches, pyplot as plt
from math import sin, cos, pi
fig = plt.figure(figsize=(6, 4))
ax = fig.add_subplot(111)
def star(coord, size, rotate):
pts = [(size * sin(i * 4 * pi / 5 + rotate) + coord[0], size * cos(i * 4 * pi / 5 + rotate) + coord[1]) for i in range(5)]
return patches.Polygon(pts, fc='yellow', ec='yellow')
ax.add_patch(patches.Rectangle([0, -2], 3, 2, fc='red', ec='red'))
ax.add_patch(star((0.5, -0.5), 0.3, 0.0))
ax.add_patch(star((1.0, -0.2), 0.07, 0.3))
ax.add_patch(star((1.2, -0.4), 0.07, 0.9))
ax.add_patch(star((1.2, -0.7), 0.07, 0.0))
ax.add_patch(star((1.0, -0.9), 0.07, 0.3))
ax.set_axis_off()
plt.axis('scaled')
plt.show()
import turtle
import time
import os
#
def draw_square(org_x, org_y, x, y):
turtle.setpos(org_x, org_y) # to left and bottom connor
turtle.color('red', 'red')
turtle.begin_fill()
turtle.fd(x)
turtle.lt(90)
turtle.fd(y)
turtle.lt(90)
turtle.fd(x)
#print(turtle.pos())
turtle.lt(90)
turtle.fd(y)
turtle.end_fill()
def draw_star(center_x, center_y, radius):
print(center_x, center_y)
turtle.pencolor('black')
turtle.setpos(center_x, center_y)
pt1 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt2 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt3 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt4 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt5 = turtle.pos()
turtle.color('yellow', 'yellow')
turtle.begin_fill()
turtle.goto(pt3)
turtle.goto(pt1)
turtle.goto(pt4)
turtle.goto(pt2)
turtle.goto(pt5)
turtle.end_fill()
print(turtle.pos())
turtle.pu()
draw_square(-320, -260, 660, 440)
star_part_x = -320
star_part_y = -260 + 440
star_part_s = 660 / 30
center_x, center_y = star_part_x + star_part_s * 5, star_part_y - star_part_s * 5
turtle.setpos(center_x, center_y) # big star center
turtle.lt(90)
draw_star(star_part_x + star_part_s * 5, star_part_y - star_part_s * 2, star_part_s * 3)
# draw 1st small star
turtle.goto(star_part_x + star_part_s * 10, star_part_y - star_part_s * 2) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)
# draw 2nd small star
turtle.goto(star_part_x + star_part_s * 12, star_part_y - star_part_s * 4) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)
# draw 3rd small star
turtle.goto(star_part_x + star_part_s * 12, star_part_y - star_part_s * 7) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)
# draw 4th small star
turtle.goto(star_part_x + star_part_s * 10, star_part_y - star_part_s * 9) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)
turtle.ht()
time.sleep(5)
os._exit(1)
两个版本,仅供参考62616964757a686964616fe4b893e5b19e31333361326266
用python函数画德国国旗代码_求一段python中用class方法绘制国旗的代码!记得不是常见的海龟做法!这个星期给我再加送财富点!...相关推荐
- 用python函数画德国国旗代码_每日一程-11.利用Python turtle库绘制国旗
Author: Notus(hehe_xiao@qq.com) Create: 2019-02-19 Update: 2019-02-19 利用turtle模块绘制五星红旗 原理不算太复杂,只是需要稍 ...
- python turtle画圆、循环法_实验与作业(Python)-03 Python程序实例解析(函数、循环、range、turtle)...
截止日期: 要求: 下周实验课前上交,做好后在实验课上检查可获取平时分. 做出进阶或选做的的请用清晰的标致标识出来,方便老师批改 本次作业:可提交也可不提交.作业算平时成绩. 本次作业内容量较大,请组 ...
- python函数后面两个括号_简单了解为什么python函数后有多个括号
这篇文章主要介绍了简单了解为什么python函数后有多个括号,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 一般而言,函数后面只有一个括号.如果看见 ...
- 用python函数画德国国旗代码_用Python的turtle模块画国旗
最近在学Python,发现Python的海龟绘图非常有趣,就分享一下!话不多说,先来Python turtle的官方文档链接: Python turtle.这里面有turtle的各类指令.turtle ...
- 用python函数画德国国旗代码_使用Python的turtle模块画国旗
Python的turtle模块画国旗主要用到两个函数:draw_rentangle和draw_star. 至于函数的调用就和我们学的C,C++是一样的.对于turtle画国旗的程序中,首先是查找国旗的 ...
- 用python函数画德国国旗代码_用Python绘制一面国旗
import turtle as tu tu.hideturtle() #隐藏海龟 tu.speed(10) tu.title("Chinese National Flag.") ...
- 用python函数画德国国旗代码_用python画个五星红旗
importturtle turtle.bgcolor("red") turtle.fillcolor("yellow") turtle.color('yell ...
- 用python函数画德国国旗代码_python海龟绘图之画国旗实例代码
画之前肯定要知道规格图,我找了一个大致的图. 参考图片: 绘制大星的方法很简单,五角星的补角是144度. 绘制小五角星有点麻烦,因为我国国旗上的小五角星并不是平放的(美帝曾经这样把我们的国旗搞错过), ...
- 用python函数画德国国旗代码_Python使用Turtle模块绘制五星红旗代码示例
在Udacity上课时学到了python的turtle方法,这是一个很经典的用来教小孩儿编程的图形模块,最早起源于logo语言.python本身内置了这个模块,其可视化的方法可以帮助小孩儿对编程的一些 ...
最新文章
- 展望 | 基于数字化技术的软件生态未来全解析
- IPv6新形势下的安全解决方案
- 零基础学Python(第五章 运算符)
- OpenVINO——配置与道路分割案例
- Google Chrome 总提示flash插件过期,用命令行模式解决
- RESTful 架构
- 软件测试适合女生学吗?
- Windows Mina 2.0.7 环境搭建
- configure make make install in linux
- 阿里云maven仓库地址
- 深圳市居住证查询、办理政府网址
- (高小德用车)高仿滴滴/快的应用源代码
- android 实现冒泡动画,android 触摸事件冒泡动画效果
- FPGA图像处理 浅浅浅浅浅记
- pdo mysql 教程_PDO入门教程
- 此pl2303驱动程序不支持win11、非旺玖原装PL2303驱动解决办法
- Inserting Data Into Tables Using Direct-Path INSERT
- 银行数据治理的一些思考(不限于银行 数据治理)
- TikTok 被盯上原来是扎克伯格背后搞的鬼?
- WebRTC通话原理-网络协商-NAT-ICE-STUN-TURN