Files
999/scripts/composite_interstellar_magic.py

188 lines
8.5 KiB
Python

import math
import numpy as np
from PIL import Image, ImageDraw, ImageFilter, ImageEnhance
SIZE = 1024
CENTER = SIZE / 2.0
# 1. Base interstellar universe: take the richest cosmic backgrounds we have
bg_cosmic = Image.open('/home/alexives/.gemini/antigravity-ide/brain/4ff924d9-3d7f-4202-9066-3ac5c3088b8e/chrome_sacred_triskelion_void_1791132439786.jpg').convert('RGBA')
bg_cosmic = bg_cosmic.resize((SIZE, SIZE), Image.Resampling.LANCZOS)
# Interstellar accretion disk glow (Gargantua style glowing golden/cyan horizon)
accretion = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
adraw = ImageDraw.Draw(accretion)
# Gravitational lens ring behind star
for r in range(int(SIZE * 0.44), int(SIZE * 0.22), -3):
alpha = int(45 * (1.0 - abs(r - SIZE * 0.33) / (SIZE * 0.12))**1.5)
adraw.ellipse([CENTER - r, CENTER - r, CENTER + r, CENTER + r], fill=(255, 170, 40, max(0, alpha)))
accretion = accretion.filter(ImageFilter.GaussianBlur(35))
bg_cosmic = Image.alpha_composite(bg_cosmic, accretion)
# 2. EXACT 13-POINTED STAR (ТРИДЕКАГРАММА) С ЖИВЫМИ ЛЕПЕСТКАМИ ПЛАМЕНИ
N_POINTS = 13
R_TIP = SIZE * 0.465
R_INNER = SIZE * 0.28
R_MEDALLION = SIZE * 0.255
R_CORE = SIZE * 0.092
start_angle = -math.pi / 2.0
tips = []
valleys = []
for i in range(N_POINTS):
ang_tip = start_angle + i * (2.0 * math.pi / N_POINTS)
ang_val = ang_tip + (math.pi / N_POINTS)
tips.append((CENTER + R_TIP * math.cos(ang_tip), CENTER + R_TIP * math.sin(ang_tip)))
valleys.append((CENTER + R_INNER * math.cos(ang_val), CENTER + R_INNER * math.sin(ang_val)))
# Flame petals layer
star_glow = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
sgdraw = ImageDraw.Draw(star_glow)
star_lines = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
sldraw = ImageDraw.Draw(star_lines)
for i in range(N_POINTS):
ang_tip = start_angle + i * (2.0 * math.pi / N_POINTS)
ang_vl = ang_tip - (math.pi / N_POINTS)
ang_vr = ang_tip + (math.pi / N_POINTS)
p_tip = tips[i]
p_vl = valleys[(i - 1) % N_POINTS]
p_vr = valleys[i]
# Smooth curved Bézier petals
ctrl_r = (R_TIP + R_INNER) * 0.49
p_ctrl_l = (CENTER + ctrl_r * math.cos((ang_tip + ang_vl)*0.5 + 0.025), CENTER + ctrl_r * math.sin((ang_tip + ang_vl)*0.5 + 0.025))
p_ctrl_r = (CENTER + ctrl_r * math.cos((ang_tip + ang_vr)*0.5 - 0.025), CENTER + ctrl_r * math.sin((ang_tip + ang_vr)*0.5 - 0.025))
pts_l = [((1-t)**2 * p_vl[0] + 2*(1-t)*t * p_ctrl_l[0] + t**2 * p_tip[0],
(1-t)**2 * p_vl[1] + 2*(1-t)*t * p_ctrl_l[1] + t**2 * p_tip[1]) for t in np.linspace(0, 1, 30)]
pts_r = [((1-t)**2 * p_tip[0] + 2*(1-t)*t * p_ctrl_r[0] + t**2 * p_vr[0],
(1-t)**2 * p_tip[1] + 2*(1-t)*t * p_ctrl_r[1] + t**2 * p_vr[1]) for t in np.linspace(0, 1, 30)]
poly = [(CENTER, CENTER)] + pts_l + pts_r
# Volumetric celestial flame fill
sgdraw.polygon(poly, fill=(255, 140, 20, 70))
# Glowing photon edges
for edge in [pts_l, pts_r]:
for p in range(len(edge) - 1):
sgdraw.line([edge[p], edge[p+1]], fill=(255, 180, 40, 180), width=9)
sldraw.line([edge[p], edge[p+1]], fill=(255, 240, 160, 255), width=3)
sldraw.line([edge[p], edge[p+1]], fill=(255, 255, 255, 255), width=1)
# Diamond flare on each tip
tip_x, tip_y = p_tip
for l_fl, w_fl in [(16, 2), (8, 1)]:
sldraw.line([tip_x - l_fl, tip_y, tip_x + l_fl, tip_y], fill=(255, 255, 255, 255), width=w_fl)
sldraw.line([tip_x, tip_y - l_fl, tip_x, tip_y + l_fl], fill=(255, 255, 255, 255), width=w_fl)
# 3. Inner Medallion: Interstellar Wormhole / Event Horizon
med = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
mdraw = ImageDraw.Draw(med)
# Black hole / cosmic mirror
mdraw.ellipse([CENTER - R_MEDALLION, CENTER - R_MEDALLION, CENTER + R_MEDALLION, CENTER + R_MEDALLION], fill=(2, 4, 12, 240))
# Multi-ring golden photon orbit
for r_o, col, w in [(R_MEDALLION, (255, 200, 50, 255), 4), (R_MEDALLION - 4, (120, 230, 255, 200), 2), (R_MEDALLION - 8, (255, 240, 180, 160), 1)]:
mdraw.ellipse([CENTER - r_o, CENTER - r_o, CENTER + r_o, CENTER + r_o], outline=col, width=w)
# 4. CHROME TRISKELION: ЭЛЕГАНТНЫЕ ЗАВИТУШКИ ДЕВЯТОК
# Single central circle (eye of the singularity)
mdraw.ellipse([CENTER - R_CORE, CENTER - R_CORE, CENTER + R_CORE, CENTER + R_CORE], fill=(0, 2, 8, 255), outline=(255, 230, 100, 255), width=5)
mdraw.ellipse([CENTER - R_CORE + 4, CENTER - R_CORE + 4, CENTER + R_CORE - 4, CENTER + R_CORE - 4], outline=(100, 230, 255, 220), width=2)
# 3 swirling tails of 9s with delicate spiral flourish (завитушки на концах)
trisk_glow = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
tdraw_glow = ImageDraw.Draw(trisk_glow)
for k in range(3):
rot = start_angle + k * (2.0 * math.pi / 3.0)
outer = []
inner = []
steps = 70
for s in range(steps + 1):
t = s / float(steps)
t_curv = 0.5 * (1.0 - math.cos(t * math.pi))
cr = R_CORE + t_curv * (R_MEDALLION - R_CORE - 12)
ca = rot + t * 1.52
bx = CENTER + cr * math.cos(ca)
by = CENTER + cr * math.sin(ca)
outer.append((bx, by))
thick = math.sin(t * math.pi) * 16.0
ir = max(R_CORE, cr - thick)
inner.append((CENTER + ir * math.cos(ca + 0.08), CENTER + ir * math.sin(ca + 0.08)))
ribbon = outer + inner[::-1]
tdraw_glow.polygon(ribbon, fill=(255, 170, 30, 160))
# Outer bright lines
for p in range(len(outer) - 1):
tdraw_glow.line([outer[p], outer[p+1]], fill=(255, 200, 40, 220), width=8)
mdraw.line([outer[p], outer[p+1]], fill=(255, 255, 230, 255), width=3)
mdraw.line([outer[p], outer[p+1]], fill=(255, 255, 255, 255), width=1)
for p in range(len(inner) - 1):
mdraw.line([inner[p], inner[p+1]], fill=(80, 220, 255, 200), width=2)
# Elegant curly spiral flourish at the tip of the nine (завитушка)
tip_pt = outer[-1]
tip_ang = rot + 1.52
flourish_pts = []
for f in range(25):
ft = f / 24.0
f_r = 18 * (1.0 - ft * 0.7)
f_a = tip_ang + ft * math.pi * 1.6
fx = tip_pt[0] + f_r * math.cos(f_a) - 18 * math.cos(tip_ang)
fy = tip_pt[1] + f_r * math.sin(f_a) - 18 * math.sin(tip_ang)
flourish_pts.append((fx, fy))
for p in range(len(flourish_pts) - 1):
tdraw_glow.line([flourish_pts[p], flourish_pts[p+1]], fill=(255, 200, 50, 180), width=5)
mdraw.line([flourish_pts[p], flourish_pts[p+1]], fill=(255, 255, 255, 255), width=2)
# 5. Magical sparkles / stardust glitter (БЛЁСТКИ И МАГИЧЕСКИЕ ИСКРЫ)
sparkles = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
spdraw = ImageDraw.Draw(sparkles)
np.random.seed(42)
tints = [(255, 255, 255), (255, 220, 100), (120, 230, 255), (255, 180, 230)]
for _ in range(120):
rad = np.random.uniform(R_CORE * 0.7, R_TIP * 0.98)
ang = np.random.uniform(0, 2 * math.pi)
sp_x = CENTER + rad * math.cos(ang)
sp_y = CENTER + rad * math.sin(ang)
sp_sz = int(np.random.choice([2, 3, 4, 6]))
sp_col = tints[np.random.randint(0, len(tints))]
# 4-point micro-glint
spdraw.line([sp_x - sp_sz*1.5, sp_y, sp_x + sp_sz*1.5, sp_y], fill=sp_col + (240,), width=1)
spdraw.line([sp_x, sp_y - sp_sz*1.5, sp_x, sp_y + sp_sz*1.5], fill=sp_col + (240,), width=1)
spdraw.ellipse([sp_x-1, sp_y-1, sp_x+1, sp_y+1], fill=(255, 255, 255, 255))
# Central Quasar Singularity Superflare
for l, w in [(36, 4), (20, 2), (8, 1)]:
mdraw.line([CENTER - l, CENTER, CENTER + l, CENTER], fill=(255, 255, 255, 255), width=w)
mdraw.line([CENTER, CENTER - l, CENTER, CENTER + l], fill=(255, 255, 255, 255), width=w)
mdraw.line([CENTER - 16, CENTER - 16, CENTER + 16, CENTER + 16], fill=(120, 230, 255, 220), width=2)
mdraw.line([CENTER - 16, CENTER + 16, CENTER + 16, CENTER - 16], fill=(120, 230, 255, 220), width=2)
# Composite layers with heavy bloom & optical glow
comp = Image.alpha_composite(bg_cosmic, star_glow.filter(ImageFilter.GaussianBlur(16)))
comp = Image.alpha_composite(comp, trisk_glow.filter(ImageFilter.GaussianBlur(12)))
comp = Image.alpha_composite(comp, star_lines)
comp = Image.alpha_composite(comp, med)
comp = Image.alpha_composite(comp, sparkles)
# Extra cosmic bloom for that deep interstellar movie feel
bloom = comp.filter(ImageFilter.GaussianBlur(12))
final_img = Image.blend(comp, bloom, 0.28)
out_file = '/home/alexives/.gemini/antigravity-ide/brain/4ff924d9-3d7f-4202-9066-3ac5c3088b8e/star_13_interstellar_magic_glitter.png'
final_img.save(out_file, 'PNG')
print("Successfully created INTERSTELLAR MAGIC GLITTER ICON at", out_file)