LiveShader

class LiveShader(val name: String, source: String) : Visualization

A shader drawing whose program can be swapped while it runs. Made for writing new ones.

Hand replace new source whenever the file it came from is saved. If it compiles, the drawing switches to it on the next frame. If it does not, the old program keeps running and the compiler's message is kept in error, so a typo shows up as a message rather than as a black screen. The source is only the body: the shared library, with the spectrum, the palette and the rest, is put in front of it the same way it is for every built-in shader.

Constructors

Link copied to clipboard
constructor(name: String, source: String)

Properties

Link copied to clipboard
open val anchors: List<Anchor>

Where this drawing's actors are on screen, as shares. The first is the main one.

Link copied to clipboard
open val bloom: Int

Extra copies of the surviving frame at slightly different sizes, which reads as light bleed.

Link copied to clipboard
open override val bucket: VizEnergy

How busy this drawing is, so something choosing for the listener can match it to the music.

Link copied to clipboard
open val detail: Detail?

A fine moving texture added over everything, the smallest of the three scales. Null for none.

Link copied to clipboard

How the echo layer is laid over the ground.

Link copied to clipboard

What the compiler said about the last source tried, or null when it compiled.

Link copied to clipboard

Radians per second the surviving frame turns by. Echoes spiral instead of expanding straight.

Link copied to clipboard

How much the surviving frame grows before the new one is drawn on top. 1 leaves it alone.

Link copied to clipboard
open val forms: FormReadout?

The form on screen and the count of its changes, or null for a drawing with no named forms.

Link copied to clipboard
open val genes: Genes?

The parts of the recipe the song changes. Null for a drawing with none.

Link copied to clipboard
open val ground: Ground?

A live field drawn under everything else. Null keeps the plain background colour.

Link copied to clipboard
open val mapping: VizMapping?

What this drawing does with the audio, in a form a test and a menu can read.

Link copied to clipboard
open val moodSpec: MoodSpec?

Different settings for calm and lively music. Overrides trail, feedbackZoom, feedbackSpin.

Link copied to clipboard
open override val name: String
Link copied to clipboard

True for drawings that paint every pixel themselves, such as the full-screen shaders.

Link copied to clipboard
open val params: List<VizParam>

Settings a person may change while it runs. Most drawings have none.

Link copied to clipboard
open override val post: PostSpec

The finishing pass over this drawing: glow around bright parts, darker corners, a little grain. Drawings that already glow through the feedback loop get a gentler version, so the two do not stack up into a haze.

Link copied to clipboard
open val trail: Float

How much of the previous frame survives, 0 to just under 1.

Link copied to clipboard

The ways this drawing can arrive. The director picks among these and what suits the music. A drawing with no trail has no echoes to inherit, so the hand-off is only on offer to drawings that feed their frames back.

Link copied to clipboard
open val warp: WarpSpec?

How the previous frame is bent on its way back, per pixel.

Functions

Link copied to clipboard
open fun bloomShareAt(mood: Float): Float

How much of the trail's budget the wide copies take, for this mood.

Link copied to clipboard
open override fun DrawScope.draw(state: VizRenderState)
Link copied to clipboard

Drawn after the echo layer, straight on the canvas, for things that must stay sharp.

Link copied to clipboard
open fun echo(state: VizRenderState): EchoFrame

How the last frame comes back this frame. The default reads the zoom, spin and drift for the mood, and settles all three towards neutral as the music goes quiet.

Link copied to clipboard
open fun feedbackSpinAt(mood: Float): Float

The feedback spin for this mood.

Link copied to clipboard
open fun feedbackZoomAt(mood: Float): Float

The feedback zoom for this mood.

Link copied to clipboard
open fun onPreviousFrame(picture: ImageBitmap?)

The echo layer as it stood a frame ago, handed over just before draw, or null when there is no echo buffer yet. Most drawings ignore it; one that breaks the picture apart cuts its pieces from it.

Link copied to clipboard
fun replace(source: String): String?

Compiles source and switches to it if it worked. Answers the compiler's message, or null.

Link copied to clipboard
open override fun reset()

Drops any carried state. Called when this drawing is shown.

Link copied to clipboard
open fun trailAt(mood: Float): Float

The trail for this mood. The surface calls this rather than reading trail.

Link copied to clipboard
open fun trailHalfLifeAt(mood: Float): Float

How long the trail takes to fade to half, in seconds, for this mood.