Published foldkit API declarations for canvas.
./canvas
@wsagency/wseffect-foldkit · MIT · source · MIT license · WS-AGENCY-NOTICE · THIRD-PARTY-NOTICES
This entry point is published in @wsagency/wseffect-foldkit@0.1.0-rc.1. Import it from the package subpath shown below; the signatures and documentation are read from the installed package declarations.
import * as Wseffect from '@wsagency/wseffect-foldkit/canvas'
Exported declarations
BezierTo
Draw a cubic Bezier curve from the cursor through two control points to an end point.
BezierTo: import("../schema/index.js").CallableTaggedStruct<"BezierTo", {
cp1x: Schema.Number;
cp1y: Schema.Number;
cp2x: Schema.Number;
cp2y: Schema.Number;
x: Schema.Number;
y: Schema.Number;
}>
BezierTo
Draw a cubic Bezier curve from the cursor through two control points to an end point.
export type BezierTo = typeof BezierTo.Type;
Circle
A filled or stroked circle.
Circle: import("../schema/index.js").CallableTaggedStruct<"Circle", {
x: Schema.Number;
y: Schema.Number;
radius: Schema.Number;
fill: Schema.optional<Schema.String>;
stroke: Schema.optional<Schema.String>;
lineWidth: Schema.optional<Schema.Number>;
}>
Circle
A filled or stroked circle.
export type Circle = typeof Circle.Type;
Close
Close the current path by drawing a line back to its starting point.
Close: import("../schema/index.js").CallableTaggedStruct<"Close", {}>
Close
Close the current path by drawing a line back to its starting point.
export type Close = typeof Close.Type;
Group
A scene-graph node that applies a 2D transform and global alpha to a list of
child shapes. Transforms compose multiplicatively when groups are nested.
Defined via the `interface` form so the recursion (`shapes: ReadonlyArray<Shape>`
where `Shape` includes `Group` itself) resolves under TypeScript's lazy
interface evaluation. The matching runtime Schema uses `Schema.suspend`.
export interface Group extends Readonly<{
readonly _tag: 'Group';
readonly shapes: ReadonlyArray<Shape>;
readonly translate?: Point | undefined;
readonly rotate?: number | undefined;
readonly scale?: Point | undefined;
readonly opacity?: number | undefined;
}> {
}
Group
Construct a `Group` shape that wraps its children in a transformed scope.
Group: import("../schema/index.js").CallableTaggedStruct<"Group", {
shapes: Schema.$Array<Schema.Schema<Shape>>;
translate: Schema.optional<Schema.Struct<{
readonly x: Schema.Number;
readonly y: Schema.Number;
}>>;
rotate: Schema.optional<Schema.Number>;
scale: Schema.optional<Schema.Struct<{
readonly x: Schema.Number;
readonly y: Schema.Number;
}>>;
opacity: Schema.optional<Schema.Number>;
}>
LineCap
Stroke cap style: how the ends of an open stroked subpath are rendered.
export type LineCap = typeof LineCap.Type;
LineCap
Stroke cap style: how the ends of an open stroked subpath are rendered.
LineCap: Schema.Literals<readonly ["Butt", "Round", "Square"]>
LineJoin
Stroke join style: how two connected stroked segments meet.
export type LineJoin = typeof LineJoin.Type;
LineJoin
Stroke join style: how two connected stroked segments meet.
LineJoin: Schema.Literals<readonly ["Miter", "Round", "Bevel"]>
LineTo
Draw a straight line from the cursor to a point.
export type LineTo = typeof LineTo.Type;
LineTo
Draw a straight line from the cursor to a point.
LineTo: import("../schema/index.js").CallableTaggedStruct<"LineTo", {
x: Schema.Number;
y: Schema.Number;
}>
MoveTo
Move the path cursor to a point without drawing.
export type MoveTo = typeof MoveTo.Type;
MoveTo
Move the path cursor to a point without drawing.
MoveTo: import("../schema/index.js").CallableTaggedStruct<"MoveTo", {
x: Schema.Number;
y: Schema.Number;
}>
Path
A path built from a sequence of `PathInstruction`s.
export type Path = typeof Path.Type;
Path
A path built from a sequence of `PathInstruction`s.
Path: import("../schema/index.js").CallableTaggedStruct<"Path", {
instructions: Schema.$Array<Schema.Union<readonly [import("../schema/index.js").CallableTaggedStruct<"MoveTo", {
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"LineTo", {
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"QuadTo", {
cpx: Schema.Number;
cpy: Schema.Number;
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"BezierTo", {
cp1x: Schema.Number;
cp1y: Schema.Number;
cp2x: Schema.Number;
cp2y: Schema.Number;
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"Close", {}>]>>;
fill: Schema.optional<Schema.String>;
stroke: Schema.optional<Schema.String>;
lineWidth: Schema.optional<Schema.Number>;
lineCap: Schema.optional<Schema.Literals<readonly ["Butt", "Round", "Square"]>>;
lineJoin: Schema.optional<Schema.Literals<readonly ["Miter", "Round", "Bevel"]>>;
}>
PathInstruction
A single drawing instruction within a `Path` shape.
export type PathInstruction = typeof PathInstruction.Type;
PathInstruction
A single drawing instruction within a `Path` shape.
PathInstruction: Schema.Union<readonly [import("../schema/index.js").CallableTaggedStruct<"MoveTo", {
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"LineTo", {
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"QuadTo", {
cpx: Schema.Number;
cpy: Schema.Number;
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"BezierTo", {
cp1x: Schema.Number;
cp1y: Schema.Number;
cp2x: Schema.Number;
cp2y: Schema.Number;
x: Schema.Number;
y: Schema.Number;
}>, import("../schema/index.js").CallableTaggedStruct<"Close", {}>]>
Point
A 2D point in canvas-local coordinates.
export type Point = typeof Point.Type;
Point
A 2D point in canvas-local coordinates.
Point: Schema.Struct<{
readonly x: Schema.Number;
readonly y: Schema.Number;
}>
QuadTo
Draw a quadratic Bezier curve from the cursor through a control point to an end point.
export type QuadTo = typeof QuadTo.Type;
QuadTo
Draw a quadratic Bezier curve from the cursor through a control point to an end point.
QuadTo: import("../schema/index.js").CallableTaggedStruct<"QuadTo", {
cpx: Schema.Number;
cpy: Schema.Number;
x: Schema.Number;
y: Schema.Number;
}>
Rect
An axis-aligned rectangle.
export type Rect = typeof Rect.Type;
Rect
An axis-aligned rectangle.
Rect: import("../schema/index.js").CallableTaggedStruct<"Rect", {
x: Schema.Number;
y: Schema.Number;
width: Schema.Number;
height: Schema.Number;
fill: Schema.optional<Schema.String>;
stroke: Schema.optional<Schema.String>;
lineWidth: Schema.optional<Schema.Number>;
}>
Shape
A drawable scene-graph node. Composing `Group` recursively builds a tree;
the painter walks the tree depth-first, applying transforms via
`ctx.save` / `ctx.restore`.
export type Shape = typeof Rect.Type | typeof Circle.Type | typeof Path.Type | typeof Text.Type | Group;
Text
A single line of text drawn with a font, fill, and optional stroke.
export type Text = typeof Text.Type;
Text
A single line of text drawn with a font, fill, and optional stroke.
Text: import("../schema/index.js").CallableTaggedStruct<"Text", {
x: Schema.Number;
y: Schema.Number;
content: Schema.String;
font: Schema.optional<Schema.String>;
fill: Schema.optional<Schema.String>;
stroke: Schema.optional<Schema.String>;
lineWidth: Schema.optional<Schema.Number>;
align: Schema.optional<Schema.Literals<readonly ["Left", "Center", "Right", "Start", "End"]>>;
baseline: Schema.optional<Schema.Literals<readonly ["Top", "Middle", "Bottom", "Alphabetic", "Hanging", "Ideographic"]>>;
}>
TextAlign
Horizontal alignment of a `Text` shape relative to its anchor x coordinate.
export type TextAlign = typeof TextAlign.Type;
TextAlign
Horizontal alignment of a `Text` shape relative to its anchor x coordinate.
TextAlign: Schema.Literals<readonly ["Left", "Center", "Right", "Start", "End"]>
TextBaseline
Vertical alignment of a `Text` shape relative to its anchor y coordinate.
export type TextBaseline = typeof TextBaseline.Type;
TextBaseline
Vertical alignment of a `Text` shape relative to its anchor y coordinate.
TextBaseline: Schema.Literals<readonly ["Top", "Middle", "Bottom", "Alphabetic", "Hanging", "Ideographic"]>
view
A virtual DOM `<canvas>` element backed by a declarative scene description.
The insert hook captures the 2D context and paints the initial scene; the
postpatch hook re-paints on every render. The canvas is a pure function of
`shapes`. Same shapes produce the same pixels.
The trailing `h` fixes `Message` to the calling view's frame; the pointer
handlers dispatch through that frame at fire time, so passing the builder
that built the surrounding view is what makes the handler types truthful.
view: <Message>(config: ViewConfig<NoInfer<Message>>, _h: HtmlBuilder<Message>) => Html
ViewConfig
Configuration for `Canvas.view`. Pointer handlers are optional and
receive a `Point` already translated to the canvas's internal coordinate
space (the `width` and `height` passed here), independent of how the
canvas is sized in CSS.
export type ViewConfig<Message> = Readonly<{
width: number;
height: number;
shapes: ReadonlyArray<Shape>;
className?: string | undefined;
onPointerDown?: ((point: Point) => Message) | undefined;
onPointerMove?: ((point: Point) => Message) | undefined;
onPointerUp?: ((point: Point) => Message) | undefined;
}>;