GRAPHICS

Circle

How to try Randomly finding points for a circle using python ?

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(1,250)
    y = random.randint(1,250)
#   i = i + 0.1
#   j = j + 0.1
    x = x*x
    y = y*y
    if ( math.sqrt(x + y) == 100 ):   
        pygame.draw.line(screen, GREEN, [500 ,500], [math.sqrt(x), math.sqrt(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