| from PIL import Image, ImageDraw, ImageFilter |
| import hashlib |
| import numpy as np |
| from pydub import AudioSegment |
| from pydub.generators import Sine |
| from io import BytesIO |
| import textwrap |
|
|
| def generate_audio(state="intro", duration_ms=120000): |
| if state == "intro": |
| base_freq, binaural_freq, volume = 100, 6, -20 |
| else: |
| base_freq, binaural_freq, volume = 150, 10, -24 |
| |
| left_sine = Sine(base_freq).to_audio_segment(duration=duration_ms, volume=volume).set_channels(1) |
| right_sine = Sine(base_freq + binaural_freq).to_audio_segment(duration=duration_ms, volume=volume).set_channels(1) |
| binaural_beat = AudioSegment.from_mono_audiosegments(left_sine, right_sine) |
| |
| filename = f"{state}_resonance.wav" |
| binaural_beat.export(filename, format="wav") |
| return filename |
|
|
| def generate_bioresonant_sigil(text_input, size=512): |
| if not text_input: return Image.new('RGB', (size, size), 'black') |
| |
| hash_object = hashlib.sha256(text_input.encode('utf-8')) |
| seed = [int(c, 16) for c in hash_object.hexdigest()] |
| |
| img = Image.new('RGB', (size, size), (10, 5, 15)) |
| draw = ImageDraw.Draw(img) |
| center_x, center_y = size // 2, size // 2 |
| |
| for i in range(16): |
| s_idx = (i * 4) % len(seed) |
| angle = (sum(seed[s_idx:s_idx+4]) / (15*4)) * 2 * np.pi |
| radius = (seed[(i+1)%len(seed)] / 15) * (size * 0.45) |
| color = (50 + seed[(i+2)%len(seed)]*12, 50 + seed[(i+3)%len(seed)]*8, 100 + seed[i]*10) |
| |
| x1 = center_x + radius * np.cos(angle) |
| y1 = center_y + radius * np.sin(angle) |
| x2 = center_x - radius * np.cos(angle) |
| y2 = center_y - radius * np.sin(angle) |
| draw.line((x1, y1, x2, y2), fill=color, width=2) |
|
|
| |
| glow = img.filter(ImageFilter.GaussianBlur(radius=size*0.05)) |
| return Image.alpha_composite(img.convert('RGBA'), glow.convert('RGBA')).convert('RGB') |
|
|
| def create_quantum_tunnel_gif(filename="quantum_tunnel.gif", size=300, num_frames=20): |
| |
| frames = [] |
| for i in range(num_frames): |
| img = Image.new('RGB', (size, size), (13, 13, 13)); draw = ImageDraw.Draw(img) |
| center_x, center_y = size // 2, size // 2 |
| np.random.seed(i) |
| for _ in range(100): |
| angle = np.random.uniform(0, 2*np.pi); radius = np.random.uniform(0, size/2) |
| new_radius = (radius + (i/num_frames)*20) % (size/2) |
| x = center_x + new_radius*np.cos(angle); y = center_y + new_radius*np.sin(angle) |
| color = (np.random.randint(150,220), np.random.randint(100,200), np.random.randint(200,255)) |
| draw.point((x, y), fill=color) |
| frames.append(img) |
| frames[0].save(filename, save_all=True, append_images=frames[1:], optimize=False, duration=100, loop=0) |
| return filename |
|
|
| def create_soul_artifact(sigil_img, title, key, filename="Soul_Artifact.png"): |
| width, height = sigil_img.size |
| bg_color = (10, 5, 15) |
| text_color = (230, 220, 255) |
| |
| |
| artifact = Image.new('RGB', (width, height + 200), bg_color) |
| artifact.paste(sigil_img, (0, 0)) |
| draw = ImageDraw.Draw(artifact) |
|
|
| |
| try: |
| title_font = ImageFont.truetype("DejaVuSans-Bold.ttf", 32) |
| except IOError: |
| title_font = ImageFont.load_default() |
| try: |
| key_font = ImageFont.truetype("DejaVuSans.ttf", 24) |
| except IOError: |
| key_font = ImageFont.load_default() |
| |
| |
| wrapped_title = textwrap.fill(title, width=30) |
| draw.text((width/2, height + 50), wrapped_title, font=title_font, fill=text_color, anchor="ms", align="center") |
| |
| |
| wrapped_key = textwrap.fill(f'"{key}"', width=40) |
| draw.text((width/2, height + 130), wrapped_key, font=key_font, fill=text_color, anchor="ms", align="center") |
| |
| artifact.save(filename) |
| return filename |