#!/bin/python
import pygame, sys
import random
green = (0, 255, 0)
black = (0, 0, 0)
red = (255, 0, 0)
pygame.init()
sc = pygame.display.set_mode((500, 700))
pygame.display.set_caption("Баловство с прямоугольниками на pygame")
state = 1
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
sz_1 = 100
sz_2 = 75
x = 200
y = 20
color_1 = [random.randint(0,255),random.randint(0,255),random.randint(0,255)]
color_2 = [random.randint(0,255),random.randint(0,255),random.randint(0,255)]
color_3 = [random.randint(0,255),random.randint(0,255),random.randint(0,255)]
if (state == 1):
state = 2
sc.fill((125,125,125))
pygame.draw.rect(sc, color_1, (x, y, sz_1, sz_2))
pygame.draw.rect(sc, color_2, (x-50, y+50, sz_1+100, sz_2))
pygame.draw.rect(sc, color_3, (x-100, y+100, sz_1+200, sz_2))
pygame.display.flip()
pygame.image.save(sc, "image.png")
|