python–pygame调色板绘图

#调色板绘图
import	pygame
pygame.init()
screen = pygame.display.set_mode([800,600])
pygame.display.set_caption("拖动鼠标左键来画画")
mousedown = False
unfinished=True

white = (255,255,255)
red = (255,50,50)
yellow = (230,230,50)
blue = (0,0,255)

pygame.draw.rect(screen,white,(0,0,50,50),0)
pygame.draw.rect(screen,red,(50,0,50,50),0)
pygame.draw.rect(screen,yellow,(100,0,50,50),0)
pygame.draw.rect(screen,blue,(150,0,50,50),0)
color=white
while unfinished:
	for event in pygame.event.get():
		if event.type==pygame.QUIT:
			unfinished = False
		if event.type == pygame.MOUSEBUTTONDOWN:
			mousedown = True
		if event.type == pygame.MOUSEBUTTONUP:
			mousedown = False
	if mousedown:
		spot = pygame.mouse.get_pos()
		#spot[0]X坐标,spot[1]Y坐标
		if spot[0]<=50 and spot[1]<=50:
			color = white
			print(color)
		elif spot[0]<=100 and spot[1]<=50:
			color = red
			print(color)
		elif spot[0]<=150 and spot[1]<=50:
			color = yellow
			print(color)
		elif spot[0]<=200 and spot[1]<=50:
			color = blue
			print(color)
		pygame.draw.circle(screen,color,spot,15)
	pygame.display.update()
pygame.quit()