2
我想在終點上畫幾個帶正方形的弧線,而我大部分都是這樣,但有些東西並不完全正確。在我認爲弧應該結束的地方和它被繪製的地方之間總會有幾個像素的間隙。示例代碼如下:Pygame.draw.arc()完成bug還是隻是我?
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'函數接受一個起始角度和停止角度,但它看起來像你只指定的一個二。這可能是問題嗎? – jme 2014-11-24 15:58:26
對不起,這是一個錯字。我已經編輯了代碼,將它們的起始點添加爲0。除了從pi/4到pi/2的最後一個圓弧外 – 2014-11-24 16:44:41