Skip to content

Instantly share code, notes, and snippets.

@max-kov
Created March 19, 2017 17:23
Show Gist options
  • Save max-kov/f58362341c2f6689912345ad967794ba to your computer and use it in GitHub Desktop.
Save max-kov/f58362341c2f6689912345ad967794ba to your computer and use it in GitHub Desktop.
import pygame
import numpy as np
# change these values
points = 10000
circles = 30.0
radius = 200.0
resolution = np.array([1000, 500])
pygame.init()
window = pygame.display.set_mode(resolution)
points_per_circle = points / circles
angle_per_point = 2.0 / points_per_circle
radius_per_point = radius / points
offset = resolution / 2
def get_coord_from_num(num):
return np.array([np.cos(np.pi * num * angle_per_point) * (radius_per_point * (points - num)),
np.sin(np.pi * num * angle_per_point) * (radius_per_point * (points - num))] + offset)
point_coords = np.array([get_coord_from_num(a) for a in range(points)])
last_point = point_coords[0]
for point in point_coords:
pygame.draw.line(window, (255, 255, 255), last_point, point)
last_point = point
pygame.display.update()
while 1:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment