import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import hsv_to_rgb
def lattis_interior_fractal(size=2000, max_iter=100, c_real=-0.7, c_imag=0.27):
"""Genera un fractal del interior del Lattis para recrear en Veo3."""
x = np.linspace(-2, 2, size)
y = np.linspace(-2, 2, size)
c = complex(c_real, c_imag)
Z = np.zeros((size, size), dtype=np.complex128)
divtime = np.zeros((size, size), dtype=int)
for i in range(size):
for j in range(size):
z = complex(x[i], y[j])
k = 0
while k < max_iter and abs(z) < 2:
z = z**2 + c
k += 1
divtime[i, j] = k
# Coloreado especial para el interior del Lattis
hsv = np.zeros(divtime.shape + (3,))
hsv[..., 0] = (divtime / max_iter) % 1.0 # Hue cíclico
hsv[..., 1] = 0.8 # Saturation alta
hsv[..., 2] = np.where(divtime < max_iter, 0.9, 0.0) # Value alto
rgb = hsv_to_rgb(hsv)
plt.figure(figsize=(10, 10))
plt.imshow(rgb, extent=[-2, 2, -2, 2])
plt.title("Fractal del Interior del Lattis (Coherencia: 0.92)", color='white')
plt.axis('off')
plt.savefig("lattis_interior_fractal.png", dpi=600, facecolor='black')
plt.close()
# Generar el fractal
lattis_interior_fractal(c_real=-0.7, c_imag=0.27, max_iter=100)