Skip to content

Commit 3183ad7

Browse files
new effects!
1 parent 57eac1f commit 3183ad7

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

Diff for: src/hexagonally.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import pygame
2+
import math
3+
import pmma
4+
import time
5+
import random
6+
7+
# Initialize Pygame
8+
pygame.init()
9+
pmma.init()
10+
11+
# Screen settings
12+
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
13+
clock = pygame.time.Clock()
14+
15+
# Circle settings
16+
NUM_CIRCLES = 15
17+
SPEED = 0.01 # Rotation speed
18+
CIRCLE_RADIUS = 8 # Size of each circle
19+
HEX_STEPS = 6 # Six steps for hexagonal motion
20+
radius = 0
21+
22+
class Circle:
23+
def __init__(self, index, radius):
24+
"""Initialize a circle at a fixed distance from the center."""
25+
self.angle = index * (2 * math.pi / NUM_CIRCLES)
26+
self.index = index # Unique index for hexagonal stepping
27+
self.color = pmma.ColorConverter()
28+
self.radius = radius
29+
radius += CIRCLE_RADIUS
30+
self.angle = random.uniform(0, 2 * math.pi) # Random starting angle
31+
32+
def update(self):
33+
"""Update position following a hexagonal path while keeping distance constant."""
34+
step_angle = (self.index % HEX_STEPS) * (math.pi / 3) # Six-step hexagonal movement
35+
hex_offset = math.sin(self.angle * HEX_STEPS) * (self.radius * 0.1) # Small hex variation
36+
37+
x = screen.get_width() // 2 + (self.radius + hex_offset) * math.cos(self.angle + step_angle)
38+
y = screen.get_height() // 2 + (self.radius + hex_offset) * math.sin(self.angle + step_angle)
39+
40+
pygame.draw.circle(screen, self.color.generate_color_from_perlin_noise(now_time / 7), (int(x), int(y)), CIRCLE_RADIUS)
41+
42+
self.angle += SPEED # Rotate around the center
43+
44+
circles = []
45+
# Create circles
46+
for i in range(NUM_CIRCLES):
47+
radius += CIRCLE_RADIUS * 4
48+
circles.append(Circle(i, radius))
49+
50+
running = True
51+
now_time = 0
52+
start = time.perf_counter()
53+
while running:
54+
#screen.fill((0, 0, 0)) # Clear screen
55+
56+
for circle in circles:
57+
circle.update()
58+
59+
# Handle events
60+
for event in pygame.event.get():
61+
if event.type == pygame.QUIT:
62+
running = False
63+
64+
pygame.display.flip()
65+
clock.tick(60 * 2) # 60 FPS
66+
now_time = time.perf_counter() - start
67+
pygame.quit()

Diff for: src/patterned.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import random
44

55
pmma.set_clean_profiling(False)
6-
pmma.set_profile_result_path(r"H:\Downloads\twtwo profile.txt")
6+
pmma.set_profile_result_path(r"H:\Downloads\40 profile.txt")
77
#pmma.init(general_profile_application=True)
88
pmma.init(general_profile_application=False, use_c_acceleration=True)
99

@@ -45,9 +45,9 @@ def pythag(x, y):
4545
circles[i].set_center(pos, format=pmma.Constants.OPENGL_COORDINATES)
4646

4747
for i in range(len(circles)):
48-
if random.choice([True, False]):
48+
#if random.choice([True, False]):
4949
#circles[i].generate_random_color()
50-
circles[i].render()
50+
circles[i].render()
5151

5252
pmma.compute()
5353

0 commit comments

Comments
 (0)