Line
Full-page experience · Open playground
Connect a sequence of coordinates into expressive polylines and diagrams.
Try it
Section titled “Try it”Trace the cobalt route with the mouse.
What to learn
Section titled “What to learn”- Draw a multi-segment line from coordinate pairs.
- Separate visible stroke width from a forgiving mouse hit width.
Integration boundaries
Section titled “Integration boundaries”- Coordinates are visited in array order.
lineInteractionWidthcan make a thin line easier to target without changing its paint.
This is a Pibbl Canvas example. Its mount owns its runtime resources; call its controller’s dispose method when removing it. The preview starts automatically unless reduced motion is enabled; Stop disposes the mount. Preserve the source’s logical canvas size and aspect ratio. Native HTML is not captured by Canvas filters.
Related APIs
Section titled “Related APIs”Complete source
Section titled “Complete source”Host setup for this source: use a canvas with width 720 and height 420, compile with jsx: "react-jsx" and jsxImportSource: "@pibbl/core", import its default mount, and call const controller = mount(canvas) after attaching the canvas. Call controller.dispose() before removing it.
line.example.tsx
Section titled “line.example.tsx”import { pibbl, useSignal, Line, Rectangle, Text, type PibblController,} from "@pibbl/core";function LineStudy() { const tracking = useSignal(false); return [ <Rectangle style={{ left: 0, top: 0, width: 720, height: 420, fill: "#f7f0df", }} />, <Line style={{ coords: [ [64, 338], [174, 238], [270, 278], [370, 112], [478, 184], [650, 68], ], stroke: "#17211d", strokeWidth: 18, }} />, <Line style={{ coords: [ [64, 328], [174, 228], [270, 268], [370, 102], [478, 174], [650, 58], ], stroke: tracking.get() ? "#ff6b57" : "#1f4bd8", strokeWidth: 7, lineInteractionWidth: 34, cursor: "crosshair", }} onMouseOver={() => tracking.set(true)} onMouseOut={() => tracking.set(false)} />, <Text style={{ left: 64, top: 56, fill: "#17211d", font: "800 18px monospace", }} > {tracking.get() ? "ON THE ROUTE" : "FOLLOW THE ROUTE"} </Text>, ];}export default function mount(canvas: HTMLCanvasElement): PibblController { return pibbl(canvas, <LineStudy />);}Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.