本文整理汇总了Python中turtle.done方法的典型用法代码示例。如果您正苦于以下问题:Python turtle.done方法的具体用法?Python turtle.done怎么用?Python turtle.done使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle
的用法示例。
在下文中一共展示了turtle.done方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_koch
# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import done [as 别名]
def draw_koch(n=3, polygon=6):
"""绘画科赫雪花
:param n: 迭代次数
:param polygon: 多边形雪花
"""
pen = turtle.Pen()
turtle.title('科赫雪花')
pen.speed(0)
r = pen.screen.canvwidth / 2
pen.penup()
pen.goto(-r, 0)
pen.pendown()
a = 180 - (polygon - 2) * 180 / polygon # 计算多边形旋转的角度,计算公式
# 多边形的内角和公式(n-2)*180/n
for i in range(polygon):
angle = a * (1 - i)
pen.setheading(angle)
koch(pen, n, r)
turtle.done()
示例2: draw
# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import done [as 别名]
def draw(self): # 绘画
pen = turtle.Pen()
turtle.title('康托三分集')
pen.width(2)
for index, dot in enumerate(self.dot):
for x, y in dot:
pen.penup()
pen.goto(x=x, y=100 - index * 10)
pen.pendown()
pen.forward(y - x)
turtle.done()
示例3: drawBitmap
# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import done [as 别名]
def drawBitmap(w_image):
print('Reducing the colors...')
Z = w_image.reshape((-1, 3))
# convert to np.float32
Z = np.float32(Z)
# define criteria, number of clusters(K) and apply kmeans()
criteria = (cv2.TERM_CRITERIA_EPS, 10, 1.0)
global K
ret, label, center = cv2.kmeans(
Z, K, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
# Now convert back into uint8, and make original image
center = np.uint8(center)
res = center[label.flatten()]
res = res.reshape(w_image.shape)
no = 1
for i in center:
sys.stdout.write('\rDrawing: %.2f%% [' % (
no / K * 100) + '#' * no + ' ' * (K - no) + ']')
no += 1
res2 = cv2.inRange(res, i, i)
res2 = cv2.bitwise_not(res2)
cv2.imwrite('.tmp.bmp', res2)
os.system('potrace.exe .tmp.bmp -s --flat')
# print(i)
drawSVG('.tmp.svg', '#%02x%02x%02x' % (i[2], i[1], i[0]))
os.remove('.tmp.bmp')
os.remove('.tmp.svg')
print('\n\rFinished, close the window to exit.')
te.done()