Python turtle.done() Examples

The following are 3 code examples of turtle.done(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module turtle , or try the search function .
Example #1
Source File: main.py    From python-turtle-draw-svg with GNU General Public License v3.0 7 votes vote down vote up
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() 
Example #2
Source File: KochSnowflake.py    From Jtyoui with MIT License 6 votes vote down vote up
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() 
Example #3
Source File: CantorTernarySet.py    From Jtyoui with MIT License 5 votes vote down vote up
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()