events
The last max presses (up to 32) on the canvas within maxAge seconds, read by slot: clicks(i) is a vec4f of (x, y in uv, age in seconds, seed 0–1).
events(source: 'click', opts: {max?: number; maxAge?: number} = {}): EventsInput
Import events from shaders/std.
Empty slots have age -1. Slot 0 is the newest.
Parameters
| Name | Type | Notes |
|---|---|---|
source | 'click' | |
opts | {max?: number; maxAge?: number} | Optional. Default {}. |
Example
inputs: {clicks: events('click', {max: 8})},
paint: wgsl`
var c = 0.0;
for (var i = 0; i < 8; i++) {
let e = clicks(i);
if (e.z < 0.0) { continue; }
let ring = abs(distance(uv, e.xy) - e.z * 0.4);
c += (1.0 - smoothstep(0.0, 0.01, ring)) * exp(-e.z * 2.0);
}
return vec4f(vec3f(c), 1.0);
`,