Polygon marks
Draw a rounded triangle, regular hexagon, and five-point star.
APIs demonstrated
Section titled “APIs demonstrated”- Polygon from
@pibbl/core - PolygonProps from
@pibbl/core - PolygonStyle from
@pibbl/core - RegularPolygon from
@pibbl/core - RegularPolygonProps from
@pibbl/core - RegularPolygonStyle from
@pibbl/core - Star from
@pibbl/core - StarProps from
@pibbl/core - StarStyle from
@pibbl/core
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 { Polygon, RegularPolygon, Star, pibbl, type PolygonProps, type PolygonStyle, type RegularPolygonProps, type RegularPolygonStyle, type StarProps, type StarStyle,} from "@pibbl/core";
const triangleProps: PolygonProps = { pointerEvents: "auto" };const triangleStyle: PolygonStyle = { coords: [ [30, 170], [80, 35], [130, 170], ], cornerRadius: 7, fill: "#0f766e",};const hexProps: RegularPolygonProps = { pointerEvents: "auto" };const hexStyle: RegularPolygonStyle = { sides: 6, cx: 185, cy: 105, circumradius: 60, fill: "#f97316", stroke: "#9a3412", strokeWidth: 2,};const starProps: StarProps = { pointerEvents: "auto" };const starStyle: StarStyle = { points: 5, cx: 280, cy: 105, outerRadius: 34, innerRadius: 17, fill: "#7c3aed",};const canvas = document.createElement("canvas");canvas.width = 340;canvas.height = 220;document.body.append(canvas);const app = pibbl( canvas, <> <Polygon {...triangleProps} style={triangleStyle} /> <RegularPolygon {...hexProps} style={hexStyle} /> <Star {...starProps} style={starStyle} /> </>,);window.addEventListener("pagehide", () => app.dispose(), { once: true });Usage notes
Section titled “Usage notes”- Creates its own canvas and disposes the Pibbl mount on pagehide.
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.