- 1.LineToFaceCircle.py
- 2.结果示例
【注1】采用 线动成面的原理,使用一维线去绘制二维平面图形!
【注2】密集的描竖直线即可!
【注3】在一维竖直线上有多点在函数上!即一个x对应多个y值,则先将多个y值求解放在列表y中! 1.LineToFaceCircle.py
import turtle as tle import math tle.speed(0) tle.delay(0) tle.pensize(2) tle.pencolor("blue") tle.tracer(True) #tle.tracer(False) col = ["yellow"] def subline(x,coll,y=[]): tle.pencolor(coll) tle.penup() tle.goto(x,-220) tle.pendown() for i in y: if x >= -150 and x <-60: tle.goto(x,i-1.4) #tle.penup() tle.pencolor("red") tle.goto(x,i+1.4) tle.pencolor(coll) #tle.pendown() elif x >= -60 and x <= 0: tle.goto(x,i-0.8) #tle.penup() tle.pencolor("red") tle.goto(x,i+0.8) tle.pencolor(coll) #tle.pendown() if x > 0 and x <= 60: tle.goto(x,i-0.8) #tle.penup() tle.pencolor("red") tle.goto(x,i+0.8) tle.pencolor(coll) #tle.pendown() elif x >= 60 and x <= 150: tle.goto(x,i-1.4) #tle.penup() tle.pencolor("red") tle.goto(x,i+1.4) tle.pencolor(coll) #tle.pendown() tle.goto(x,220) k = 0 i = -150 while(i<=150): if k == 1: k = 0 y = [] if i == 150 or i == -150: y.append(math.sqrt(22500-i*i)) else: y.append(-math.sqrt(22500-i*i)) y.append(math.sqrt(22500-i*i)) subline(i,col[k],y) i = i + 1 k = k + 1 tle.done()2.结果示例
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)