Light painted canvas relief
Compare flat paint with highlights and shadows derived from woven surface height.
APIs demonstrated
Section titled “APIs demonstrated”- emboss from
@pibbl/core/filters - PibblEmbossFilterOptions from
@pibbl/core/filters
Complete example
Section titled “Complete example”Plain source. Run as a browser module after the document body exists. TSX uses jsx: "react-jsx" and jsxImportSource: "@pibbl/core".
import { Group, Rectangle, Text, useTexture } from "@pibbl/core";import { pibblSync } from '@pibbl/core/sync';import { emboss, type PibblEmbossFilterOptions } from "@pibbl/core/filters";import { plainWeave } from "@pibbl/core/textures";function Scene() { const height = useTexture( plainWeave({ threads: 24, relief: 0.8, fuzz: 0.5 }), { resolution: { width: 256, height: 256 }, palette: ["#000000", "#ffffff"], }, ); const options: PibblEmbossFilterOptions = { region: { x: 0, y: 0, width: 224, height: 224 }, depth: 3, strength: 0.8, direction: [-0.6, -0.8], }; return ( <> <Rectangle style={{ width: 496, height: 288, fill: "#231f2b" }} /> <Text style={{ left: 16, top: 16, font: "600 14px system-ui", fill: "#f5e9d3", }} > Flat paint </Text> <Text style={{ left: 256, top: 16, font: "600 14px system-ui", fill: "#f5e9d3", }} > Embossed weave </Text> <Rectangle style={{ left: 16, top: 46, width: 224, height: 224, fill: "#c56948" }} /> <Group style={{ translateX: 256, translateY: 46 }}> <Rectangle style={{ width: 224, height: 224, fill: "#c56948", filter: emboss( height.paint({ mode: "repeat", tileWidth: 112, tileHeight: 112 }), options, ), }} /> </Group> </> );}const canvas = document.createElement("canvas");canvas.width = 496;canvas.height = 288;canvas.style.cssText = "display:block;max-width:100%;height:auto";document.body.append(canvas);const controller = pibblSync(canvas, <Scene />);window.addEventListener("pagehide", () => controller.dispose(), { once: true });Usage notes
Section titled “Usage notes”- The grayscale height map supplies relief; directional lighting preserves paint color and alpha.
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.