2 patterns-psychedelic-Plasma-Color-Cycling
Balazs Horvath edited this page 2026-04-18 11:13:09 +02:00

Plasma Color Cycling

Multi-layer plasma with warm sunset palette and color cycling animation.

Mathematical Formula


\text{plasma} = \frac{\sin(x + \omega_1 t) + \sin(y + \omega_2 t) + \sin(\frac{x+y}{2} + \omega_3 t)}{3}

R = \text{plasma}

G = \text{plasma} + \frac{2\pi}{3}

B = \text{plasma} + \frac{4\pi}{3}

Where:

  • \omega_1, \omega_2, \omega_3 are temporal frequencies
  • Phase offsets: 0, \frac{2\pi}{3}, \frac{4\pi}{3} for RGBent spatial and temporal frequencies
  • Linear color mapping to warm sunset palette

How It Works

Plasma effects use wave superposition to create smooth, flowing patterns. Multiple sine waves with different orientations and speeds combine to create complex interference patterns that appear to move organically.

Implementation

import torch

width, height = 512, 512
frames = []

for t in range(30):
    x = torch.linspace(0, 2*torch.pi, width)
    y = torch.linspace(0, 2*torch.pi, height)
    X, Y = torch.meshgrid(x, y, indexing='ij')
    
    # Multi-layer plasma
    p1 = torch.sin(X + t/5)
    p2 = torch.sin(Y + t/4)
    p3 = torch.sin((X + Y) / 2 + t/6)
    p4 = torch.sin((X - Y) / 2 + t/7)
    
    plasma = (p1 + p2 + p3 + p4) / 4
    
    # Pleasing palette: warm sunset colors
    r = plasma * 0.8 + 0.2
    g = plasma * 0.4 + 0.3
    b = plasma * 0.2 + 0.6
    
    rgb = torch.stack([r, g, b], dim=-1).clamp(0, 1)
    frames.append(rgb)

output_image = torch.stack(frames, dim=0)

Line-by-Line Explanation

plasma = (p1 + p2 + p3 + p4) / 4

Averages four sine waves to create the plasma pattern.

r = plasma * 0.8 + 0.2

Red channel: high contrast with offset to ensure minimum brightness.

g = plasma * 0.4 + 0.3
b = plasma * 0.2 + 0.6

Green and blue channels: lower contrast, different offsets for color variation.

Customization

More Waves

p5 = torch.sin(X * 2 + t/8)
plasma = (p1 + p2 + p3 + p4 + p5) / 5

Different Palette

# Oceanic
r = plasma * 0.2 + 0.6
g = plasma * 0.5 + 0.3
b = plasma * 0.8 + 0.2

References