Plasma

Paint a classic animated plasma with a few lines of NumPy and show it live on a display block.

Download
Blocks 2
Category Visualization
Version 1.0.0
License MIT
Updated Sep 28, 2026

Blocks used

Python
Frame

Overview

The plasma is a classic effect of computer graphics demos, a soft and endlessly shifting field of color that looks far more complex than the code behind it. It is usually built as a sum of sine functions evaluated at every pixel.[1] Each sine on its own draws plain stripes or rings. Added together, they reinforce in some places and cancel in others, and the result drifts and swirls.

This flowgraph paints a new plasma on every update. A Python block adds four sine waves over a 760 by 400 pixel canvas with NumPy and writes the result as an RGB image into a tensor, and a Frame block displays it. No radio is involved, which makes it a good first look at how a Python block produces data for a native display.

How it works

Python Plasma PainterFrame Display

The canvas is 760 by 400 pixels (width by height). Each pixel gets coordinates xx and yy that run from about −9.5-9.5 to 9.59.5 across and −5-5 to 55 down. On every update the block advances time tt by 0.05 and adds four waves,

s=sin⁡(x+t)+sin⁡y+t2+sin⁡x+y+t2+sin⁡(r+t),s = \sin(x + t) + \sin\frac{y + t}{2} + \sin\frac{x + y + t}{2} + \sin(r + t),

where rr is roughly the distance from the pixel to a center that wanders slowly around the canvas. The first term draws vertical stripes, the second horizontal stripes twice as wide, the third diagonal stripes, and the fourth rings around the moving center. Adding tt inside each sine shifts its phase, and that is what makes the bands move. In the painter, the s = ... line is this equation written in NumPy, with the same names.

The sum ss stays between −4-4 and 44. A cosine palette turns it into color,[2]

(R,G,B)=12+12cos⁡(2π(s/4+d)),d=(0,0.2,0.4).(R, G, B) = \tfrac{1}{2} + \tfrac{1}{2} \cos\big(2\pi (s/4 + d)\big), \qquad d = (0, 0.2, 0.4).

Offsetting the phase dd between the three channels is what spreads the pattern across so many hues. The output is a CPU tensor of 32-bit floats with shape [400, 760, 3], holding red, green, and blue between 0 and 1. The Frame block shows those values as is, with auto range turned off. With auto range on, it would stretch each frame between its own minimum and maximum, and the brightness would pump from frame to frame.

What to look for

Watch the rings first. They come from the fourth wave, and their center drifts along a slow loop, dragging them across the canvas. The three straight waves sweep through in different directions, bending the rings into ovals and pinching them into islands where the waves cancel.

The palette repeats as the sum rises, so a single ridge of the pattern shows up as several bands of color, running through orange, red, purple, blue, cyan, green, and yellow. Every term repeats within 12π12\pi of time, so the animation comes back to where it started after about 754 updates. For more on building plasmas and on cosine palettes, see the sources below.

Going further

To see what one wave contributes on its own, replace the s = ... line in the painter with a single term, such as the rings,

PYTHON
    s = np.sin(r + t)

and put the other terms back one at a time. With fewer waves the sum covers a narrower slice of the palette, so the colors also get calmer.

Three constants at the top of the painter control the rest. Raising SCALE packs more stripes into the canvas, STEP sets the speed, and PHASE is the palette phase dd. Values such as (0.3,0.2,0.2)(0.3, 0.2, 0.2) give dark red and teal, and (0.8,0.9,0.3)(0.8, 0.9, 0.3) gives blue and yellow. The canvas size is tied to the output tensor, so changing H or W means updating the painter's declared output shape to match. The Python block reference explains how output shapes are declared.

The painter recomputes every pixel in NumPy on each update, which favors readability over speed.

References

References

  1. L. Vandevenne, "Plasma," Lode's Computer Graphics Tutorial, 2004. lodev.org/cgtutor/plasma.html ↩

  2. I. Quilez, "Simple color palettes," iquilezles.org. iquilezles.org/articles/palettes ↩

CyberEther

High-performance GPU-accelerated signal processing and visualization framework that runs anywhere.

Star on GitHub

© 2026 CyberEther. All rights reserved.

The final frontier!