python turtle绘图,python turtle画图问题

1,python turtle画图问题import turtle as tt.showturtle()t.right(60)# 箭头右转60度t.forward(100)# 沿箭头方向前进100t.right(120)t.forward(100)t.right(120)t.forward(200)t.left(120)t.forward(100)t.left(120)t.forward(100)你的图像主要是画工字形状,定义一个函数画工字,里面要有有一个参数是控制工字比例大小的,其余两个是画的时候起始坐标然后定义一个列表,包括坐标,比例list=[(x1,y1,scale1),(x2,y2,scale2)......;(xn,yn,scalen)]for i in list:draw(*i)我这个只是一个粗略的比方,大概意思就是定义好画图函数,然后把坐标放在列表,然后遍历,调用函数【python turtle绘图,python turtle画图问题】
2,Python的turtle库画图使用中的问题当turtle.seth(0),箭头指向0,就是→ , 因为你后面是turtle.fd(-400),面向右方后退400个单位turtle.seth(0),箭头指向180,就是←,turtle.fd(400),-400变为400 , 就是想要的效果画圆的函数如下turtle.circle(radius, extent=none, steps=none)参数分别为半径、弧度和画圆弧线段的数量半径为负,方向相反的原因可以看下turtle库的源代码 w = 1.0 * extent / steps w2 = 0.5 * w l = 2.0 * radius * math.sin(w2*math.pi/180.0*self._degreesperau) if radius < 0: l, w, w2 = -l, -w, -w2时设计模块时,可能就希望用半径的正负控制划线的方向
3,python turtle画4个同心圆方法123456789101112131415161718192021 importturtle#draw first circleturtle.penup()turtle.goto(0,-200)turtle.pendown()turtle.circle(200)#draw second circleturtle.penup()turtle.goto(0,-150)turtle.pendown()turtle.circle(150)#draw third circleturtle.penup()turtle.goto(0,-100)turtle.pendown()turtle.circle(100)#draw fourth circleturtle.penup()turtle.goto(0,-50)turtle.pendown()turtle.circle(50) 画笔的坐标默认在0,0,就以它为圆心 。因为turtle画圆的时候是从圆的底部开始画的 , 所以需要找到四个圆底部的坐标比如:第一个半径为200的圆 , 底部为(0,-200)第二个半径为150的圆,底部为(0,-150)第三个半径为100的圆,底部为(0,-100)第四个半径为50的圆,底部为(0,-50)画的时候按下面的步骤:1. 抬起画笔:turtle.penup()2. 移动到相应坐标:turtle.goto(坐标)3. 放下画笔:turtle.pendown()4. 画圆:turtle.circle(半径)效果如下图所示:from turtle import *def Circle(radius,angle,length):for i in range(length):penup()goto(0,angle)pendown()circle(radius)angle=angle+50radius=radius-50Circle(200,-200,4)done()

    推荐阅读