- 论坛徽章:
- 0
|
初学(自学)Python,照着写了下面代码但是运行的时候提示:
line 18, in <module>
colour[2] += increment
ValueError: invalid color argument
请教为何会出这个错误,如何解决这个错误(我的是Python 3.6.4在win32位)
源代码如下:
import pygame
pygame.init()
width = 400
height = 300
windowSize = (width , height)
screen = pygame.display.set_mode(windowSize)
colour = pygame.color.Color('#646400')
row = 0
done = False
while not done:
increment = 255/100
while row <= height:
pygame.draw.rect(screen,colour,(0, row, width, row + increment))
pygame.display.flip()
if colour[2] + increment < 255:
colour[2] += increment
row += increment
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
pygame.quit()
|
|