【发布时间】:2014-11-24 15:53:49
【问题描述】:
我正在尝试在端点处绘制几条带有正方形的弧线,其中大部分都已完成,但端点有些地方不太对劲。在我认为弧应该结束的位置和绘制它的位置之间总是有几个像素的差距。示例代码如下:
import pygame
from math import pi
pygame.init()
screen = pygame.display.set_mode([1000,1000])
clock = pygame.time.Clock()
done = False
while not done:
clock.tick(10)
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
screen.fill((0,0,0))
# draw first arc just past pi/2 to make sure arc is not cut off by rectangle bounds
pygame.draw.arc(screen, (255,255,255),[100,100,800,800], 0, 9 * pi / 16, 1)
# normal, easy, simple, arc does not touch vertical red line as expected
pygame.draw.arc(screen, (255,255,255),[200,200,600,600], 0, 2 * pi, 1)
# shorter arc because in my actual code it seems that smaller arcs have larger gaps
# but I can't seem to tell here besides it doesn't connect either
pygame.draw.arc(screen, (255,255,255),[300,300,400,400], 4 * pi / 16, pi / 2, 1)
# Horizontal and vertical lines for comparison
pygame.draw.line(screen, (255,0,0), [500,500], [500,0])
pygame.draw.line(screen, (255,0,0), [500,500], [900,500])
pygame.display.flip()
pygame.quit()
[示例输出][1] 注意鼠标光标左侧的间隙。 http://i.stack.imgur.com/0zxkG.jpg
在 OS X 和 Linux Mint 上的结果相同。先画线并没有什么不同,它总是终点而不是起点。感谢阅读!
【问题讨论】:
-
查看 API,
arc函数采用起始角度和终止角度,但看起来您只指定了两者之一。会不会是这个问题? -
抱歉,打错了。我已经编辑了代码以将起点添加到 0,因为它们应该是。除了从 pi/4 到 pi/2 的最后一条弧
标签: python python-2.7 pygame draw