Files
999/scripts/render_pure_interstellar_13_v2.py
T

167 lines
7.5 KiB
Python

import math
import numpy as np
from PIL import Image, ImageDraw, ImageFilter
SIZE = 1024
CENTER = SIZE / 2.0
# 1. ЧИСТЫЙ КОСМОС: глубокое индиго + золотой свет квазара
bg = Image.new('RGBA', (SIZE, SIZE), (2, 3, 11, 255))
# Плавные космические вихри
neb = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
ndraw = ImageDraw.Draw(neb)
ndraw.ellipse([50, 50, 974, 974], fill=(30, 15, 60, 120))
ndraw.ellipse([120, 120, 904, 904], fill=(5, 50, 110, 130))
ndraw.ellipse([220, 220, 804, 804], fill=(160, 80, 20, 90))
neb = neb.filter(ImageFilter.GaussianBlur(75))
bg = Image.alpha_composite(bg, neb)
# Звёзды - чистые фотонные светящиеся сферы без всяких крестиков
stars = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
sdraw = ImageDraw.Draw(stars)
np.random.seed(999)
t_options = [(255, 255, 255), (190, 230, 255), (255, 240, 180)]
for _ in range(550):
x = float(np.random.randint(0, SIZE))
y = float(np.random.randint(0, SIZE))
dist = math.hypot(x - CENTER, y - CENTER)
if dist < 140 and np.random.rand() > 0.1:
continue
rad = np.random.choice([0.9, 1.4, 2.0, 3.2], p=[0.7, 0.2, 0.08, 0.02])
br = np.random.randint(150, 255)
tint = t_options[np.random.randint(0, len(t_options))]
sdraw.ellipse([x - rad, y - rad, x + rad, y + rad], fill=tint + (br,))
stars_soft = stars.filter(ImageFilter.GaussianBlur(2.5))
bg = Image.alpha_composite(bg, stars)
bg = Image.alpha_composite(bg, stars_soft)
# 2. РОВНО 13 ПЛАВНЫХ ЛЕПЕСТКОВ СВЕТА
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 = [(CENTER + R_TIP * math.cos(start_angle + i * 2 * math.pi / N_POINTS),
CENTER + R_TIP * math.sin(start_angle + i * 2 * math.pi / N_POINTS)) for i in range(N_POINTS)]
valleys = [(CENTER + R_INNER * math.cos(start_angle + (i + 0.5) * 2 * math.pi / N_POINTS),
CENTER + R_INNER * math.sin(start_angle + (i + 0.5) * 2 * math.pi / N_POINTS)) for i in range(N_POINTS)]
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):
p_tip = tips[i]
p_vl = valleys[(i - 1) % N_POINTS]
p_vr = valleys[i]
ang_tip = start_angle + i * 2 * math.pi / N_POINTS
ang_vl = ang_tip - math.pi / N_POINTS
ang_vr = ang_tip + math.pi / N_POINTS
ctrl_r = (R_TIP + R_INNER) * 0.49
p_cl = (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_cr = (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))
steps = 35
pts_l = [((1-t)**2 * p_vl[0] + 2*(1-t)*t * p_cl[0] + t**2 * p_tip[0],
(1-t)**2 * p_vl[1] + 2*(1-t)*t * p_cl[1] + t**2 * p_tip[1]) for t in np.linspace(0, 1, steps)]
pts_r = [((1-t)**2 * p_tip[0] + 2*(1-t)*t * p_cr[0] + t**2 * p_vr[0],
(1-t)**2 * p_tip[1] + 2*(1-t)*t * p_cr[1] + t**2 * p_vr[1]) for t in np.linspace(0, 1, steps)]
poly = [(CENTER, CENTER)] + pts_l + pts_r
sgdraw.polygon(poly, fill=(255, 140, 30, 80))
for edge in [pts_l, pts_r]:
for p in range(len(edge) - 1):
sgdraw.line([edge[p], edge[p+1]], fill=(255, 175, 40, 160), width=9)
sldraw.line([edge[p], edge[p+1]], fill=(255, 235, 140, 255), width=3)
sldraw.line([edge[p], edge[p+1]], fill=(255, 255, 255, 255), width=1)
sldraw.line([CENTER, CENTER, p_tip[0], p_tip[1]], fill=(255, 255, 240, 240), width=2)
# Сияющая круглая световая жемчужина на кончике каждого луча
for r_drop in range(5, 0, -1):
sldraw.ellipse([p_tip[0]-r_drop, p_tip[1]-r_drop, p_tip[0]+r_drop, p_tip[1]+r_drop], fill=(255, 255, 255, 255))
# 3. ВНУТРЕННИЙ ПОРТАЛ
med = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
mdraw = ImageDraw.Draw(med)
mdraw.ellipse([CENTER - R_MEDALLION, CENTER - R_MEDALLION, CENTER + R_MEDALLION, CENTER + R_MEDALLION], fill=(1, 2, 7, 245), outline=(255, 215, 70, 255), width=4)
mdraw.ellipse([CENTER - R_MEDALLION - 3, CENTER - R_MEDALLION - 3, CENTER + R_MEDALLION + 3, CENTER + R_MEDALLION + 3], outline=(60, 200, 255, 190), width=2)
# 4. CHROME TRISKELION: КРАСИВЕЙШИЕ ЗАВИТУШКИ ДЕВЯТОК
mdraw.ellipse([CENTER - R_CORE, CENTER - R_CORE, CENTER + R_CORE, CENTER + R_CORE], fill=(0, 1, 5, 255), outline=(255, 225, 90, 255), width=5)
mdraw.ellipse([CENTER - R_CORE + 4, CENTER - R_CORE + 4, CENTER + R_CORE - 4, CENTER + R_CORE - 4], outline=(80, 220, 255, 210), width=2)
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 = 80
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 - 10)
ca = rot + t * 1.50
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, 175, 40, 180))
for p in range(len(outer) - 1):
tdraw_glow.line([outer[p], outer[p+1]], fill=(255, 190, 40, 230), width=7)
mdraw.line([outer[p], outer[p+1]], fill=(255, 255, 235, 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=(60, 200, 255, 210), width=2)
# Изящный завиток девятки
tip_pt = outer[-1]
tip_ang = rot + 1.50
flourish = []
for f in range(30):
ft = f / 29.0
f_r = 16.0 * (1.0 - ft * 0.75)
f_a = tip_ang + ft * math.pi * 1.7
fx = tip_pt[0] + f_r * math.cos(f_a) - 16.0 * math.cos(tip_ang)
fy = tip_pt[1] + f_r * math.sin(f_a) - 16.0 * math.sin(tip_ang)
flourish.append((fx, fy))
for p in range(len(flourish) - 1):
tdraw_glow.line([flourish[p], flourish[p+1]], fill=(255, 190, 40, 200), width=5)
mdraw.line([flourish[p], flourish[p+1]], fill=(255, 255, 255, 255), width=2)
# Центральное оптическое ядро (чистый мягкий фотонный шар)
core_spark = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
cdraw = ImageDraw.Draw(core_spark)
for r_c in range(28, 0, -2):
alpha = int(255 * (1.0 - r_c / 28.0)**1.3)
cdraw.ellipse([CENTER - r_c, CENTER - r_c, CENTER + r_c, CENTER + r_c], fill=(255, 252, 235, alpha))
comp = Image.alpha_composite(bg, star_glow.filter(ImageFilter.GaussianBlur(16)))
comp = Image.alpha_composite(comp, trisk_glow.filter(ImageFilter.GaussianBlur(10)))
comp = Image.alpha_composite(comp, star_lines)
comp = Image.alpha_composite(comp, med)
comp = Image.alpha_composite(comp, core_spark)
bloom = comp.filter(ImageFilter.GaussianBlur(9))
final_img = Image.blend(comp, bloom, 0.24)
out_file = '/home/alexives/.gemini/antigravity-ide/brain/4ff924d9-3d7f-4202-9066-3ac5c3088b8e/star_13_interstellar_pure_gold_magic.png'
final_img.save(out_file, 'PNG')
print("Saved V2 to", out_file)