Created
March 21, 2017 22:23
-
-
Save max-kov/964cea58a63794abe7381cd37da4cd67 to your computer and use it in GitHub Desktop.
drawing circles on a circle (which is moving)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import numpy as np | |
# change these values | |
points_temp = 1000 | |
radius1 = 100 | |
radius2 = 100 | |
angular_speed_1 = 0.01 | |
angular_speed_2 = 0.0002 | |
points = int (2.0/angular_speed_1 + 2.0/angular_speed_2) | |
offset = [500,250] | |
resolution = np.array([1000, 500]) | |
pygame.init() | |
window = pygame.display.set_mode(resolution) | |
def get_offset_from_num(num): | |
return np.array([np.cos(num * angular_speed_2 * np.pi),np.sin(num * angular_speed_2 * np.pi)])*radius2 + offset | |
def get_coord_from_num(num,_offset): | |
return np.array([np.cos(num * angular_speed_1 * np.pi),np.sin(num * angular_speed_1 * np.pi)])*radius1 + _offset | |
offset_coords = np.array([get_offset_from_num(a) for a in range(points)]) | |
point_coords = np.array([get_coord_from_num(a,offset_coords[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