Move your pointer to carry the light.

0:01 / 0:30
Playback speed

Point light

Carry the light across a tile. When is the tile brightest, and when does it start to fade?

Interactive demo#LightAndGlow

A light that shines in all directions from one spot and fades with distance.

The scene is drawn normally, then covered in darkness with a soft hole cut out around the light. How quickly the light fades toward its edge is called falloff.

Code

src/demos/point_light.goose
namespace point_light_lesson;
import stage;
import std;
import math;

export "point-light" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
    lit_scene();
    let radius = 44 + sin(time * 13) * 1.5;
    darkness(0.93, px, py, radius);
}

Stage drawing helpers · All demos on GitHub

Comments

No comments yet.