API Reference
Properties
ShaderPad intentionally exposes a small public property surface. Most interaction happens through methods.
Instance Properties
shader.canvas
canvas: HTMLCanvasElement | OffscreenCanvas
The canvas backing this ShaderPad instance.
- If you pass an
HTMLCanvasElementorOffscreenCanvasto the constructor,shader.canvasis that same object. - If you pass
{ width, height },null, or omitcanvas, ShaderPad creates a headlessOffscreenCanvasand exposes it here.
Use canvas when you need the underlying canvas directly, such as checking its size or reusing it for another ShaderPad instance.
const shader = new ShaderPad(fragmentShaderSrc, {
canvas: createFullscreenCanvas(),
});
console.log(shader.canvas.width, shader.canvas.height);
Chaining ShaderPads
If you want to sample one ShaderPad from another, pass the ShaderPad instance itself to initializeTexture() instead of using shader.canvas.