0
我正在處理涉及在圓圈中繪製隨機像素的項目。我想提高像素的繪製速度。我如何改變每秒的幀數。我看了一些例子,但我的代碼仍然無法正常工作。我使用Python 3.2.3和1.9的Pygame這是我的代碼:使用Python繪圖時每秒的幀數
from pygame import*
from random import*
screen = display.set_mode((1000,800))
tick = time.Clock()
rand_spraypaint_xs = []
rand_spraypaint_ys = []
col1 = (0,0,0)
canvasRect = Rect(100,100,500,500)
tool = 'spraypaint'
draw.rect(screen,(0,255,0),canvasRect,0)
running = True
while running:
for e in event.get():
if e.type == QUIT:
running = False
mx,my = mouse.get_pos()
mb = mouse.get_pressed()
x = randint(mx-30,mx+30)
y = randint(my-30,my+30)
dist =(((mx - x)**2 + (my - y)**2)**0.5)
if dist <=30:
rand_spraypaint_xs.append(x)
rand_spraypaint_ys.append(y)
if canvasRect.collidepoint(mx,my):
if tool == 'spraypaint':
if mb[0]==1:
screen.set_at((rand_spraypaint_xs[-1], rand_spraypaint_ys[-1]),col1)
time.wait(1)
tick.tick(10000)
display.flip()
quit()
你如何繪圖 - PyGame,PyQt,PyOpenGL?根據框架,它可能會非常不同? – 2014-01-09 04:47:04
我使用pygame繪圖 – user3175999
我建議使用[Short Self Contained Correct Example](http://sscce.org)來給代碼提供更多的上下文。 – 2014-01-09 05:17:07