GRAPHICS

Line

How to draw line patterns with lines mostly of different lengths ?

Jeffrin
import os
import pygame
import time
import random
import math

from math import pi

pygame.init()

BLACK = (  0,   0,   0)
WHITE = (255, 255, 255)
BLUE =  (  0,   0, 255)
GREEN = (  0, 255,   0)
RED =   (255,   0,   0)


size = [1366, 768]
screen = pygame.display.set_mode(size)

#Loop until the user clicks the close button.
done = False
clock = pygame.time.Clock()
x = 0.0
y = 0.0
z = 0.0
while not done:
 
    # This limits the while loop to a max of 10 times per second.
    # Leave this out and we will use all CPU we can.
#    clock.tick(10)
     
    for event in pygame.event.get(): # User did something
        if event.type == pygame.QUIT: # If user clicked close
            done=True # Flag that we are done so we exit this loop
 
    
#    for i in range(250):
#        for j in range(250):
    x = random.randint(0,683)
    y = random.randint(0,384)
#   i = i + 0.1
#   j = j + 0.1
    x = 683 + x
    y = 384 + y
    a = x*x
    b = y*y
#    if ( math.sqrt(a + b) == 50 ):
    if True:   
        pygame.draw.line(screen, GREEN, [683, 384], [x, y], 2)
        time.sleep(0.1)
        pygame.display.flip()

pygame.quit()
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top