【问题标题】:How to make circle on canvas in tkinter?如何在 tkinter 的画布上制作圆圈?
【发布时间】:2017-08-28 21:38:41
【问题描述】:

我一直在尝试编写一个绘制圆的函数。我尝试使用距离公式来计算我的分数:

def distance_form(x1, y1, x2, y2):
    d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

那不行,所以我看了一下别人的代码圈了。这里是:

def circle(page, radius, g, h):
    for x in range(g, g + radius):
        y = h + (math.sqrt(radius ** 2 - ((x - g) ** 2)))
        plot(page, x, y)
        plot(page, x, 2 * h - y)
        plot(page, 2 * g - x, y)
        plot(page, 2 * g - x, 2 * h - y)

我数学不错,但我不太确定这意味着什么。

【问题讨论】:

标签: python canvas tkinter


【解决方案1】:

我认为标准的做法是使用 create_oval。

oval = canvas.create_oval(x0, y0, x1, y1, options)

create_oval Documentation

希望对您有所帮助。干杯!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    相关资源
    最近更新 更多