Просто скомбинировал прямоугольники и круги.
import pygame
import sys
import random
pygame.init()
sc = pygame.display.set_mode((700, 700))
sc.fill((0, 0, 0))
color1 =(random.randint(0,255),random.randint(0,255),random.randint(0,255))
state = 1
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
pygame.image.save(sc, "image.jpg")
if state == 1:
for x in range(50,700,100):
for y in range(50,700,100):
select = random.randint(0,1)
if select == 0:
pygame.draw.circle(sc,color1, (x, y), random.randint(25,50))
else:
pygame.draw.rect(sc, color1, (x, y, random.randint(25,50), random.randint(25,50)))
state = 0
pygame.display.update()
|