import pygame
pygame.init()
sc = pygame.display.set_mode((400, 300))
done = False
white=(255,255,255)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
sc.fill(white)
state_mouse = 0
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
state_mouse = 1
if event.type == pygame.MOUSEBUTTONUP:
if event.button == 1:
state_mouse = 2
if event.type == pygame.MOUSEMOTION:
if (state_mouse == 1):
pygame.draw.rect(sc, green,(event.pos[0],event.pos[1],2,2))
pygame.display.update()
pygame.image.save(sc, "img.png")
|