Skip to content

Commit 256130c

Browse files
new effect!
1 parent 9716da3 commit 256130c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/patterned.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import pmma
2+
import math
3+
4+
pmma.init()
5+
6+
display = pmma.Display()
7+
display.create()
8+
9+
events = pmma.Events()
10+
11+
noise = pmma.Perlin()
12+
13+
circles = []
14+
for _ in range(750): # 750
15+
circle = pmma.RadialPolygon()
16+
circle.set_radius(10)
17+
circle.generate_random_color()
18+
circles.append(circle)
19+
20+
offset = 0
21+
22+
def pythag(x, y):
23+
return math.sqrt((x*x)+(y*y))
24+
25+
ROOT_TWO = 2**0.5
26+
27+
while pmma.get_application_running():
28+
events.handle()
29+
30+
display.clear()
31+
32+
for i in range(len(circles)):
33+
a = ((1/360)*i)
34+
pos = [(math.sin(i+offset)*a)/display.get_aspect_ratio(), math.cos(i+offset)*a]
35+
distance = pythag(abs(pos[0]), abs(pos[1])) - circle.get_radius(format=pmma.Constants.OPENGL_COORDINATES)
36+
if distance < ROOT_TWO:
37+
size = noise.generate_1D_perlin_noise(-distance + pmma.get_application_run_time(), new_range=[1, 50]) * (distance / ROOT_TWO)
38+
size = max(size, 1)
39+
circles[i].set_radius(size)
40+
circles[i].set_center(pos, format=pmma.Constants.OPENGL_COORDINATES)
41+
circles[i].render()
42+
43+
pmma.compute()
44+
display.refresh()
45+
46+
pmma.quit()

0 commit comments

Comments
 (0)