sampleShapePoints
Returns perimeter points for a named shape centred at a point, starting at twelve o'clock and going clockwise, or an empty list for an unknown shape.
@internote/canvas-sdkOn this page
import { sampleShapePoints } from '@internote/canvas-sdk';The shapes are circle, square, rectangle, triangle, diamond, hexagon, star, cross and tick. Two shapes sampled with the same count morph into each other point by point.
#Signature
(
x: number,
y: number,
r: number,
type: string,
n: number,
halfHeight?: number,
): Vec2[]#Parameters
xThe centre's x.
yThe centre's y.
rThe shape's radius, or half-size — a rectangle's half-width.
typeThe shape's name, in any case.
nHow many points to sample.
halfHeightA rectangle's half-height; absent, 0.6 of
r.#Example
const points = sampleShapePoints(cx, cy, size / 2, attrs.shape, 32);
<polygon points={points.map(([px, py]) => `${px},${py}`).join(' ')} />Declared in packages/canvas-sdk/src/geometry/polygon-sampling.ts:73.