Skip to content

Polygon

Read as Markdown

import { Polygon } from "@pibbl/core";

Polygon uses PolygonProps and PolygonStyle. coords is a finite numeric pair list; three or more points form one closed outline, and shorter lists are empty geometry. It rejects children and supports shared rounded-corner style.

<Polygon
style={{
coords: [
[20, 90],
[70, 12],
[130, 90],
],
fill: "#f59e0b",
}}
/>

See the Polygon live example.

Describes a polygon primitive for JSX or createElement authoring.

Polygon: PibblPrimitiveComponent<PolygonProps, PrimitiveInput<PolygonProps, PolygonStyle>>

Related API: Polygon, PibblPrimitiveComponent, PolygonProps, PrimitiveInput, PolygonStyle.

  • props — Authored component inputs, supplied through JSX or createElement. See the linked props and style types.

When called directly; Pibbl mounts this component through JSX or createElement.

PolygonProps

PolygonStyle

View source — packages/core/src/lib/components/polygon.ts:122

Read the Drawing, layout, and effects companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

Compile this TSX module with jsx: "react-jsx" and jsxImportSource: "@pibbl/core", then load it from a browser entry point after the document body exists. It creates and mounts one canvas; dispose the controller before removing or replacing that canvas. The interactive study linked below adds controls beyond this minimal use case.

Download source

/** @jsxImportSource @pibbl/core */
import { pibbl, Polygon } from '@pibbl/core';
const canvas = document.createElement('canvas');
canvas.width = 320;
canvas.height = 240;
document.body.append(canvas);
const controller = pibbl(canvas, (
<Polygon
style={{
coords: [
[20, 90],
[70, 12],
[130, 90],
],
fill: "#f59e0b",
}}
/>
));
window.addEventListener('pagehide', () => controller.dispose(), { once: true });

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.