-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolored lines dynamic.py
65 lines (47 loc) · 1.7 KB
/
colored lines dynamic.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
import pmma
import pygame
import time
display = pmma.Display()
display.create(1280, 720)
events = pmma.Events(canvas=display)
background_perlin = pmma.Perlin()
math = pmma.Math()
draw = pmma.Draw(canvas=display)
start = time.perf_counter()
now_time = 0
number_of_circles = int(math.pythag(display.get_size()))
surface = pygame.Surface(display.get_size())
rect = pygame.Rect(500, 300, 200, 200)
NUMBER_OF_LINES = 5
LINE_SEEDS = []
for _ in range(NUMBER_OF_LINES):
LINE_SEEDS.append(pmma.Perlin())
def line_function():
t = now_time/10
for line in range(NUMBER_OF_LINES):
seed = LINE_SEEDS[line]
x, y = center
points = []
for i in range(25):
points.append([x, y])
x += seed.generate_2D_perlin_noise((i + t)/100, 0, new_range=[-20, 20])
y += seed.generate_2D_perlin_noise(-(i + t)/100, 0, new_range=[-20, 20])
pygame.draw.lines(surface, (255, 255, 255), False, points, width=1)
while True:
display.clear()
center = display.get_width() / 2, display.get_height() / 2
for r in range(number_of_circles, 0, -25):
ar = (now_time + r) / 500
color = [
background_perlin.generate_2D_perlin_noise(ar, 0, new_range=[0, 255]),
background_perlin.generate_2D_perlin_noise(0, ar, new_range=[0, 255]),
background_perlin.generate_2D_perlin_noise(-ar, 0, new_range=[0, 255])]
draw.circle(color, center, r)
event_arr = events.handle()
surface = pygame.Surface(display.get_size())
surface.fill((0, 0, 0))
line_function()
surface.set_colorkey([255, 255, 255])
display.blit(surface, (0, 0))
display.refresh()
now_time = -(time.perf_counter() - start)*100