""" 三角圆图.py """ import turtle def draw_circle(pos,radius): """以pos为中心点为半径为radius的圆""" pass turtle.speed(0) turtle.delay(0) turtle.penup() turtle.pensize(2) # 画一个三角形,获取它们的顶点坐标 turtle.begin_poly() turtle.fd(200) turtle.lt(120) turtle.fd(200) turtle.lt(120) turtle.fd(200) turtle.lt(120) turtle.end_poly() p = list(turtle.get_poly()) # 转换成列表 p.pop() # 求出三角形中心点坐标,以这个为圆心画圆 centerx = (p[0][0] + p[1][0] + p[2][0])/3 centery = (p[0][1] + p[1][1] + p[2][1])/3 center = centerx,centery s = turtle.getscreen() s.onclick(inside) for radius in range(4,120,10): # 画一些圆,超出三角范围则不画 draw_circle(center,radius) turtle.ht() turtle.done()
需要全部源代码,请扫码付款:
本站所有作品,教程等皆为原创,版权所有。只供个人及单位内部研究使用,对外展示或传播必需经本站同意,且注明来自本站。培训机构等用本站资源培训学生,需经本站授权。一旦付款,表示同意本站知识付费原则:数字商品,不支持退款。亦可直接向微信号scratch8付款购买。入住QQ群:225792826 和爱好者共同交流,并且能下载免费提供的Python资源(需提供真实姓名才可入群)
李兴球的博客_Python创意编程技术前沿_pygame » 三角圆图
李兴球的博客_Python创意编程技术前沿_pygame » 三角圆图