import pygame
import random
import math
WIDTH = 500
HEIGHT = 500
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
running = True
def draw_dotted_line(x_start,y,len_line,cnt):
x = random.randint(1,100)
for i in range(0,cnt):
pygame.draw.line(screen,(255,255,255), [x,y], [x+len_line, y], 3)
x = x + random.randint(1,100)*2
state = 0
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
pygame.image.save(screen, "image.jpg")
if state == 0:
for i in range(0,500,10):
draw_dotted_line(0,i,10,20)
state = 1
pygame.display.flip()
pygame.quit()
|