【发布时间】: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)
我数学不错,但我不太确定这意味着什么。
【问题讨论】:
-
Google tkinter canvas create circle first result... This looks promising... 在提出一个包含大量易于查找的文档的问题之前尝试使用谷歌搜索一下,因为提出不好的问题可能会阻止您以后再问问题。
-
tkinter 没有名为
plot的方法。您是否在使用其他库,例如 matplotlib? -
@Brian Oakley 哦,我已经定义了 plot 来创建一条线