-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlights.py
79 lines (49 loc) · 1.63 KB
/
lights.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import pmma
import random
import time
import math
import pygame
pmma.init(log_information=True)
display = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
events = pmma.Events()
registry = pmma.Registry
color = pmma.Color()
radius = pmma.Math().pythag(display.get_size())/4.2
PETALS = 8
clock = pygame.time.Clock()
class Point:
def __init__(self):
self.x = random.randint(0, display.get_width())
self.y = random.randint(0, display.get_height())
def compute(self):
self.x = int(display.get_width()/2 + (radius * math.sin(PETALS * now_time/10)) * math.cos(now_time/10 + 0))
self.y = int(display.get_height()/2 + (radius * math.sin(PETALS * now_time/10)) * math.sin(now_time/10 + 0))
def render(self, color):
self.compute()
pygame.draw.circle(Surface, color, (self.x, self.y), 10)
point = Point()
start = time.perf_counter()
now_time = 0
i = 0
while registry.running:
window_x, window_y = display.get_size()
window_size = (window_x, window_y)
Surface = pygame.Surface(window_size).convert()
Surface.fill((0, 0, 0))
Surface.set_colorkey((0, 0, 0))
Surface2 = pygame.Surface(window_size)
Surface2.fill((0, 0, 0))
color_value = color.generate_color_from_perlin_noise(now_time/10, format=pmma.Constants.RGB, color_range=[100, 255])
#display.clear()
events.handle()
point.render(color_value)
Surface2.set_alpha(1) # 10
if i % 8 == 0:
display.blit(Surface2, (0, 0))
display.blit(Surface, (0, 0))
pmma.compute()
pygame.display.flip()
clock.tick(60)
now_time = time.perf_counter() - start
i += 1
pmma.quit()