@pg-labs-incubator/cobweb 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +163 -0
- package/README.md +82 -2
- package/package.json +112 -3
- package/src/action/action.yaml +291 -0
- package/src/action/button-group.yaml +56 -0
- package/src/action/button.yaml +239 -0
- package/src/action/split-button.yaml +87 -0
- package/src/color/color.yaml +181 -0
- package/src/color/palette.yaml +147 -0
- package/src/container/card.yaml +170 -0
- package/src/container/corner-radius.yaml +50 -0
- package/src/container/elevation.yaml +19 -0
- package/src/design.yaml +41 -0
- package/src/feedback/feedback.yaml +225 -0
- package/src/icon/icon-font.yaml +28 -0
- package/src/icon/icon.yaml +31 -0
- package/src/input/date-picker.yaml +144 -0
- package/src/input/date-range-input.yaml +162 -0
- package/src/input/range-slider.yaml +161 -0
- package/src/input/select.yaml +230 -0
- package/src/input/slider.yaml +172 -0
- package/src/input/text-field.yaml +240 -0
- package/src/input/time-picker.yaml +220 -0
- package/src/motion/motion.yaml +371 -0
- package/src/navigation/app-bar.yaml +147 -0
- package/src/navigation/navigation.yaml +339 -0
- package/src/navigation/scroll.yaml +23 -0
- package/src/navigation/search.yaml +112 -0
- package/src/navigation/tabs.yaml +144 -0
- package/src/navigation/toolbar.yaml +130 -0
- package/src/selection/checkbox.yaml +162 -0
- package/src/selection/chip.yaml +219 -0
- package/src/selection/radio.yaml +125 -0
- package/src/selection/segmented-group.yaml +11 -0
- package/src/selection/segmented.yaml +69 -0
- package/src/selection/switch.yaml +209 -0
- package/src/spacing/measurement.yaml +80 -0
- package/src/state/state.yaml +38 -0
- package/src/surface/surface.yaml +483 -0
- package/src/text/line-height.yaml +144 -0
- package/src/text/typeface.yaml +31 -0
- package/src/text/typescale.yaml +726 -0
- package/target/esbuild/action/action.css +1 -0
- package/target/esbuild/action/base.jsx +1 -0
- package/target/esbuild/action/button.jsx +17 -0
- package/target/esbuild/action/fab-menu-context.jsx +1 -0
- package/target/esbuild/action/fab-menu.jsx +15 -0
- package/target/esbuild/action/fab.jsx +7 -0
- package/target/esbuild/action/group.jsx +22 -0
- package/target/esbuild/action/icon-button.jsx +5 -0
- package/target/esbuild/action/index.jsx +1 -0
- package/target/esbuild/action/split-button.jsx +12 -0
- package/target/esbuild/color/contrast.jsx +1 -0
- package/target/esbuild/color/dynamic.jsx +1 -0
- package/target/esbuild/color/hct.jsx +1 -0
- package/target/esbuild/color/index.css +1 -0
- package/target/esbuild/color/index.jsx +1 -0
- package/target/esbuild/color/palette.jsx +1 -0
- package/target/esbuild/color/scheme.jsx +1 -0
- package/target/esbuild/color/temperature.jsx +1 -0
- package/target/esbuild/container/card.css +1 -0
- package/target/esbuild/container/card.jsx +1 -0
- package/target/esbuild/container/elevation-shadow.css +1 -0
- package/target/esbuild/container/elevation-shadow.jsx +1 -0
- package/target/esbuild/container/index.jsx +1 -0
- package/target/esbuild/dom/client.jsx +1 -0
- package/target/esbuild/dom/index.jsx +1 -0
- package/target/esbuild/dom/server.jsx +1 -0
- package/target/esbuild/dom/types.jsx +1 -0
- package/target/esbuild/feedback/badge.jsx +15 -0
- package/target/esbuild/feedback/feedback.css +1 -0
- package/target/esbuild/feedback/focus.jsx +1 -0
- package/target/esbuild/feedback/index.jsx +1 -0
- package/target/esbuild/feedback/loading.jsx +7 -0
- package/target/esbuild/feedback/observe.jsx +1 -0
- package/target/esbuild/feedback/progress.jsx +35 -0
- package/target/esbuild/feedback/snackbar.jsx +23 -0
- package/target/esbuild/feedback/tooltip.jsx +24 -0
- package/target/esbuild/icon/icon.css +1 -0
- package/target/esbuild/icon/icon.jsx +1 -0
- package/target/esbuild/icon/index.jsx +1 -0
- package/target/esbuild/index.css +1 -0
- package/target/esbuild/index.jsx +1 -0
- package/target/esbuild/input/autocomplete.jsx +5 -0
- package/target/esbuild/input/base.jsx +4 -0
- package/target/esbuild/input/date-picker.css +1 -0
- package/target/esbuild/input/date-picker.jsx +104 -0
- package/target/esbuild/input/date-range-input.css +1 -0
- package/target/esbuild/input/date-time.jsx +21 -0
- package/target/esbuild/input/index.css +1 -0
- package/target/esbuild/input/index.jsx +1 -0
- package/target/esbuild/input/paired-input.jsx +1 -0
- package/target/esbuild/input/picker-dialog.css +1 -0
- package/target/esbuild/input/picker-dialog.jsx +14 -0
- package/target/esbuild/input/select.css +1 -0
- package/target/esbuild/input/select.jsx +63 -0
- package/target/esbuild/input/slider.css +1 -0
- package/target/esbuild/input/slider.jsx +51 -0
- package/target/esbuild/input/text-field.css +1 -0
- package/target/esbuild/input/text-field.jsx +67 -0
- package/target/esbuild/input/time-picker.css +1 -0
- package/target/esbuild/input/time-picker.jsx +29 -0
- package/target/esbuild/motion/frame.jsx +1 -0
- package/target/esbuild/motion/index.css +1 -0
- package/target/esbuild/motion/index.jsx +1 -0
- package/target/esbuild/motion/material.jsx +1 -0
- package/target/esbuild/motion/motion.jsx +1 -0
- package/target/esbuild/motion/spring.jsx +1 -0
- package/target/esbuild/motion/transition.css +1 -0
- package/target/esbuild/motion/transition.jsx +1 -0
- package/target/esbuild/motion/velocity.jsx +1 -0
- package/target/esbuild/navigation/app-bar.jsx +51 -0
- package/target/esbuild/navigation/base.jsx +1 -0
- package/target/esbuild/navigation/drawer.jsx +25 -0
- package/target/esbuild/navigation/index.jsx +1 -0
- package/target/esbuild/navigation/navigation.css +1 -0
- package/target/esbuild/navigation/navigation.jsx +29 -0
- package/target/esbuild/navigation/scroll.jsx +1 -0
- package/target/esbuild/navigation/search.jsx +29 -0
- package/target/esbuild/navigation/tabs.jsx +7 -0
- package/target/esbuild/navigation/toolbar.jsx +23 -0
- package/target/esbuild/selection/base.jsx +1 -0
- package/target/esbuild/selection/checkbox.jsx +14 -0
- package/target/esbuild/selection/chip.jsx +23 -0
- package/target/esbuild/selection/index.jsx +1 -0
- package/target/esbuild/selection/radio.jsx +9 -0
- package/target/esbuild/selection/segmented.jsx +15 -0
- package/target/esbuild/selection/selection.css +1 -0
- package/target/esbuild/selection/switch.jsx +14 -0
- package/target/esbuild/shape/corner-rounding.jsx +1 -0
- package/target/esbuild/shape/cubic.jsx +1 -0
- package/target/esbuild/shape/index.jsx +1 -0
- package/target/esbuild/shape/material-shapes.jsx +1 -0
- package/target/esbuild/shape/morph.jsx +1 -0
- package/target/esbuild/shape/path.jsx +1 -0
- package/target/esbuild/shape/point.jsx +1 -0
- package/target/esbuild/shape/rounded-polygon.jsx +1 -0
- package/target/esbuild/shape/shapes.jsx +1 -0
- package/target/esbuild/spacing/index.jsx +1 -0
- package/target/esbuild/state/component.css +1 -0
- package/target/esbuild/state/component.jsx +1 -0
- package/target/esbuild/state/controller.jsx +1 -0
- package/target/esbuild/state/index.jsx +1 -0
- package/target/esbuild/state/ripple.jsx +1 -0
- package/target/esbuild/state/state.jsx +1 -0
- package/target/esbuild/state/style.jsx +1 -0
- package/target/esbuild/surface/carousel-layout.jsx +1 -0
- package/target/esbuild/surface/carousel.css +1 -0
- package/target/esbuild/surface/carousel.jsx +10 -0
- package/target/esbuild/surface/dialog.jsx +35 -0
- package/target/esbuild/surface/divider.jsx +1 -0
- package/target/esbuild/surface/drag.jsx +1 -0
- package/target/esbuild/surface/gestures.css +1 -0
- package/target/esbuild/surface/gestures.jsx +7 -0
- package/target/esbuild/surface/index.css +1 -0
- package/target/esbuild/surface/index.jsx +1 -0
- package/target/esbuild/surface/interactive.jsx +1 -0
- package/target/esbuild/surface/list-patterns.jsx +26 -0
- package/target/esbuild/surface/list.css +1 -0
- package/target/esbuild/surface/list.jsx +9 -0
- package/target/esbuild/surface/menu.css +1 -0
- package/target/esbuild/surface/menu.jsx +12 -0
- package/target/esbuild/surface/scaffold.jsx +47 -0
- package/target/esbuild/surface/sheet.jsx +21 -0
- package/target/esbuild/surface/side-sheet.jsx +17 -0
- package/target/esbuild/surface/slots.jsx +1 -0
- package/target/esbuild/surface/surface.css +1 -0
- package/target/esbuild/surface/surface.jsx +1 -0
- package/target/esbuild/text/index.css +1 -0
- package/target/esbuild/text/index.jsx +1 -0
- package/target/esbuild/text/text.css +1 -0
- package/target/esbuild/text/text.jsx +3 -0
- package/target/esbuild/text/typography.css +1 -0
- package/target/esbuild/text/typography.jsx +1 -0
- package/target/esbuild/util/box-side.jsx +1 -0
- package/target/esbuild/util/debug.jsx +1 -0
- package/target/esbuild/util/dom.jsx +1 -0
- package/target/esbuild/util/event.jsx +1 -0
- package/target/esbuild/util/index.jsx +1 -0
- package/target/esbuild/util/preconditions.jsx +1 -0
- package/target/esbuild/util/reactive.jsx +1 -0
- package/target/tsc/action/action.css.d.ts +3 -0
- package/target/tsc/action/base.d.ts +211 -0
- package/target/tsc/action/button.d.ts +126 -0
- package/target/tsc/action/fab-menu-context.d.ts +16 -0
- package/target/tsc/action/fab-menu.d.ts +112 -0
- package/target/tsc/action/fab.d.ts +98 -0
- package/target/tsc/action/group.d.ts +166 -0
- package/target/tsc/action/icon-button.d.ts +79 -0
- package/target/tsc/action/index.d.ts +24 -0
- package/target/tsc/action/split-button.d.ts +78 -0
- package/target/tsc/color/contrast.d.ts +48 -0
- package/target/tsc/color/dynamic.d.ts +203 -0
- package/target/tsc/color/hct.d.ts +114 -0
- package/target/tsc/color/index.css.d.ts +3 -0
- package/target/tsc/color/index.d.ts +23 -0
- package/target/tsc/color/palette.d.ts +30 -0
- package/target/tsc/color/scheme.d.ts +446 -0
- package/target/tsc/color/temperature.d.ts +24 -0
- package/target/tsc/container/card.css.d.ts +3 -0
- package/target/tsc/container/card.d.ts +110 -0
- package/target/tsc/container/elevation-shadow.css.d.ts +3 -0
- package/target/tsc/container/elevation-shadow.d.ts +23 -0
- package/target/tsc/container/index.d.ts +44 -0
- package/target/tsc/dom/client.d.ts +387 -0
- package/target/tsc/dom/index.d.ts +93 -0
- package/target/tsc/dom/server.d.ts +65 -0
- package/target/tsc/dom/types.d.ts +134 -0
- package/target/tsc/feedback/badge.d.ts +116 -0
- package/target/tsc/feedback/feedback.css.d.ts +3 -0
- package/target/tsc/feedback/focus.d.ts +20 -0
- package/target/tsc/feedback/index.d.ts +17 -0
- package/target/tsc/feedback/loading.d.ts +194 -0
- package/target/tsc/feedback/observe.d.ts +75 -0
- package/target/tsc/feedback/progress.d.ts +281 -0
- package/target/tsc/feedback/snackbar.d.ts +398 -0
- package/target/tsc/feedback/tooltip.d.ts +326 -0
- package/target/tsc/icon/icon.css.d.ts +3 -0
- package/target/tsc/icon/icon.d.ts +69 -0
- package/target/tsc/icon/index.d.ts +13 -0
- package/target/tsc/index.css.d.ts +3 -0
- package/target/tsc/index.d.ts +7 -0
- package/target/tsc/input/autocomplete.d.ts +119 -0
- package/target/tsc/input/base.d.ts +282 -0
- package/target/tsc/input/date-picker.css.d.ts +3 -0
- package/target/tsc/input/date-picker.d.ts +351 -0
- package/target/tsc/input/date-range-input.css.d.ts +3 -0
- package/target/tsc/input/date-time.d.ts +171 -0
- package/target/tsc/input/index.css.d.ts +3 -0
- package/target/tsc/input/index.d.ts +27 -0
- package/target/tsc/input/paired-input.d.ts +435 -0
- package/target/tsc/input/picker-dialog.css.d.ts +3 -0
- package/target/tsc/input/picker-dialog.d.ts +84 -0
- package/target/tsc/input/select.css.d.ts +3 -0
- package/target/tsc/input/select.d.ts +267 -0
- package/target/tsc/input/slider.css.d.ts +3 -0
- package/target/tsc/input/slider.d.ts +372 -0
- package/target/tsc/input/text-field.css.d.ts +3 -0
- package/target/tsc/input/text-field.d.ts +415 -0
- package/target/tsc/input/time-picker.css.d.ts +3 -0
- package/target/tsc/input/time-picker.d.ts +212 -0
- package/target/tsc/motion/frame.d.ts +36 -0
- package/target/tsc/motion/index.css.d.ts +3 -0
- package/target/tsc/motion/index.d.ts +34 -0
- package/target/tsc/motion/material.d.ts +110 -0
- package/target/tsc/motion/motion.d.ts +235 -0
- package/target/tsc/motion/spring.d.ts +223 -0
- package/target/tsc/motion/transition.css.d.ts +3 -0
- package/target/tsc/motion/transition.d.ts +597 -0
- package/target/tsc/motion/velocity.d.ts +54 -0
- package/target/tsc/navigation/app-bar.d.ts +473 -0
- package/target/tsc/navigation/base.d.ts +331 -0
- package/target/tsc/navigation/drawer.d.ts +301 -0
- package/target/tsc/navigation/index.d.ts +25 -0
- package/target/tsc/navigation/navigation.css.d.ts +3 -0
- package/target/tsc/navigation/navigation.d.ts +537 -0
- package/target/tsc/navigation/scroll.d.ts +218 -0
- package/target/tsc/navigation/search.d.ts +332 -0
- package/target/tsc/navigation/tabs.d.ts +497 -0
- package/target/tsc/navigation/toolbar.d.ts +248 -0
- package/target/tsc/selection/base.d.ts +100 -0
- package/target/tsc/selection/checkbox.d.ts +194 -0
- package/target/tsc/selection/chip.d.ts +358 -0
- package/target/tsc/selection/index.d.ts +21 -0
- package/target/tsc/selection/radio.d.ts +198 -0
- package/target/tsc/selection/segmented.d.ts +333 -0
- package/target/tsc/selection/selection.css.d.ts +3 -0
- package/target/tsc/selection/switch.d.ts +165 -0
- package/target/tsc/shape/corner-rounding.d.ts +36 -0
- package/target/tsc/shape/cubic.d.ts +215 -0
- package/target/tsc/shape/index.d.ts +35 -0
- package/target/tsc/shape/material-shapes.d.ts +176 -0
- package/target/tsc/shape/morph.d.ts +91 -0
- package/target/tsc/shape/path.d.ts +177 -0
- package/target/tsc/shape/point.d.ts +165 -0
- package/target/tsc/shape/rounded-polygon.d.ts +289 -0
- package/target/tsc/shape/shapes.d.ts +76 -0
- package/target/tsc/spacing/index.d.ts +19 -0
- package/target/tsc/state/component.css.d.ts +3 -0
- package/target/tsc/state/component.d.ts +276 -0
- package/target/tsc/state/controller.d.ts +257 -0
- package/target/tsc/state/index.d.ts +19 -0
- package/target/tsc/state/ripple.d.ts +50 -0
- package/target/tsc/state/state.d.ts +129 -0
- package/target/tsc/state/style.d.ts +22 -0
- package/target/tsc/surface/carousel-layout.d.ts +212 -0
- package/target/tsc/surface/carousel.css.d.ts +3 -0
- package/target/tsc/surface/carousel.d.ts +231 -0
- package/target/tsc/surface/dialog.d.ts +582 -0
- package/target/tsc/surface/divider.d.ts +92 -0
- package/target/tsc/surface/drag.d.ts +92 -0
- package/target/tsc/surface/gestures.css.d.ts +3 -0
- package/target/tsc/surface/gestures.d.ts +292 -0
- package/target/tsc/surface/index.css.d.ts +3 -0
- package/target/tsc/surface/index.d.ts +29 -0
- package/target/tsc/surface/interactive.d.ts +22 -0
- package/target/tsc/surface/list-patterns.d.ts +384 -0
- package/target/tsc/surface/list.css.d.ts +3 -0
- package/target/tsc/surface/list.d.ts +340 -0
- package/target/tsc/surface/menu.css.d.ts +3 -0
- package/target/tsc/surface/menu.d.ts +590 -0
- package/target/tsc/surface/scaffold.d.ts +337 -0
- package/target/tsc/surface/sheet.d.ts +384 -0
- package/target/tsc/surface/side-sheet.d.ts +183 -0
- package/target/tsc/surface/slots.d.ts +21 -0
- package/target/tsc/surface/surface.css.d.ts +3 -0
- package/target/tsc/surface/surface.d.ts +192 -0
- package/target/tsc/text/index.css.d.ts +3 -0
- package/target/tsc/text/index.d.ts +18 -0
- package/target/tsc/text/text.css.d.ts +3 -0
- package/target/tsc/text/text.d.ts +94 -0
- package/target/tsc/text/typography.css.d.ts +3 -0
- package/target/tsc/text/typography.d.ts +82 -0
- package/target/tsc/util/box-side.d.ts +76 -0
- package/target/tsc/util/debug.d.ts +20 -0
- package/target/tsc/util/dom.d.ts +35 -0
- package/target/tsc/util/event.d.ts +93 -0
- package/target/tsc/util/index.d.ts +12 -0
- package/target/tsc/util/preconditions.d.ts +79 -0
- package/target/tsc/util/reactive.d.ts +36 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import type { PointTransformer } from "./point";
|
|
2
|
+
import { Point } from "./point";
|
|
3
|
+
/**
|
|
4
|
+
* Coordinates of a cubic Bezier curve.
|
|
5
|
+
*
|
|
6
|
+
* This holds the start anchor, the first control point, the second control point and the end
|
|
7
|
+
* anchor of the curve, in order, as `[x, y]` pairs.
|
|
8
|
+
*/
|
|
9
|
+
export type CubicCoordinates = readonly [
|
|
10
|
+
number,
|
|
11
|
+
number,
|
|
12
|
+
number,
|
|
13
|
+
number,
|
|
14
|
+
number,
|
|
15
|
+
number,
|
|
16
|
+
number,
|
|
17
|
+
number
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Distance below which coordinates coincide.
|
|
21
|
+
*
|
|
22
|
+
* Two curves are contiguous if, and only if, their anchors are within this distance along both
|
|
23
|
+
* axes. Likewise, a curve has zero length if, and only if, all of its points are within this
|
|
24
|
+
* distance of its start anchor along both axes.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CUBIC_CONTINUITY_EPSILON: number;
|
|
27
|
+
/**
|
|
28
|
+
* Cubic Bezier curve.
|
|
29
|
+
*
|
|
30
|
+
* Curves are immutable, except for the curves of {@link Cubic.interpolate} and of morphs. These
|
|
31
|
+
* are new for each call, and belong to the caller.
|
|
32
|
+
*/
|
|
33
|
+
export declare class Cubic {
|
|
34
|
+
/**
|
|
35
|
+
* Coordinates of the curve.
|
|
36
|
+
*/
|
|
37
|
+
readonly points: CubicCoordinates;
|
|
38
|
+
/**
|
|
39
|
+
* Construct a new curve.
|
|
40
|
+
*
|
|
41
|
+
* @param points - coordinates of start anchor, first control point, second control point and
|
|
42
|
+
* end anchor, as `[x, y]` pairs
|
|
43
|
+
* @throws {@link Error} `points` does not have eight entries, or one of them is not finite
|
|
44
|
+
*/
|
|
45
|
+
constructor(points: readonly number[]);
|
|
46
|
+
/**
|
|
47
|
+
* Horizontal coordinate of start anchor.
|
|
48
|
+
*/
|
|
49
|
+
get anchor0X(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Vertical coordinate of start anchor.
|
|
52
|
+
*/
|
|
53
|
+
get anchor0Y(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Horizontal coordinate of first control point.
|
|
56
|
+
*/
|
|
57
|
+
get control0X(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Vertical coordinate of first control point.
|
|
60
|
+
*/
|
|
61
|
+
get control0Y(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Horizontal coordinate of second control point.
|
|
64
|
+
*/
|
|
65
|
+
get control1X(): number;
|
|
66
|
+
/**
|
|
67
|
+
* Vertical coordinate of second control point.
|
|
68
|
+
*/
|
|
69
|
+
get control1Y(): number;
|
|
70
|
+
/**
|
|
71
|
+
* Horizontal coordinate of end anchor.
|
|
72
|
+
*/
|
|
73
|
+
get anchor1X(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Vertical coordinate of end anchor.
|
|
76
|
+
*/
|
|
77
|
+
get anchor1Y(): number;
|
|
78
|
+
/**
|
|
79
|
+
* Create a curve from its points.
|
|
80
|
+
*
|
|
81
|
+
* @param anchor0 - start anchor
|
|
82
|
+
* @param control0 - first control point
|
|
83
|
+
* @param control1 - second control point
|
|
84
|
+
* @param anchor1 - end anchor
|
|
85
|
+
* @returns new curve
|
|
86
|
+
* @throws {@link Error} a coordinate is not finite
|
|
87
|
+
*/
|
|
88
|
+
static fromPoints(anchor0: Point, control0: Point, control1: Point, anchor1: Point): Cubic;
|
|
89
|
+
/**
|
|
90
|
+
* Create a curve of a straight line.
|
|
91
|
+
*
|
|
92
|
+
* The control points of the line lie at one third and two thirds of its length,
|
|
93
|
+
* respectively.
|
|
94
|
+
*
|
|
95
|
+
* @param x0 - horizontal coordinate of start
|
|
96
|
+
* @param y0 - vertical coordinate of start
|
|
97
|
+
* @param x1 - horizontal coordinate of end
|
|
98
|
+
* @param y1 - vertical coordinate of end
|
|
99
|
+
* @returns new curve
|
|
100
|
+
* @throws {@link Error} a coordinate is not finite
|
|
101
|
+
*/
|
|
102
|
+
static straightLine(x0: number, y0: number, x1: number, y1: number): Cubic;
|
|
103
|
+
/**
|
|
104
|
+
* Approximate a circular arc between two points.
|
|
105
|
+
*
|
|
106
|
+
* This approximates the shorter arc from the start to the end, around the center. The radius
|
|
107
|
+
* of the arc is the distance of the start from the center. If the directions of the start and
|
|
108
|
+
* the end from the center nearly coincide, with an angle whose cosine is above `0.999`, then
|
|
109
|
+
* this returns a {@link Cubic.straightLine | straight line}. Opposite directions turn
|
|
110
|
+
* clockwise.
|
|
111
|
+
*
|
|
112
|
+
* @param centerX - horizontal coordinate of center
|
|
113
|
+
* @param centerY - vertical coordinate of center
|
|
114
|
+
* @param x0 - horizontal coordinate of start
|
|
115
|
+
* @param y0 - vertical coordinate of start
|
|
116
|
+
* @param x1 - horizontal coordinate of end
|
|
117
|
+
* @param y1 - vertical coordinate of end
|
|
118
|
+
* @returns new curve
|
|
119
|
+
* @throws {@link Error} start or end is the center
|
|
120
|
+
*/
|
|
121
|
+
static circularArc(centerX: number, centerY: number, x0: number, y0: number, x1: number, y1: number): Cubic;
|
|
122
|
+
/**
|
|
123
|
+
* Create a curve of zero length.
|
|
124
|
+
*
|
|
125
|
+
* @param x - horizontal coordinate of all points
|
|
126
|
+
* @param y - vertical coordinate of all points
|
|
127
|
+
* @returns new curve
|
|
128
|
+
* @throws {@link Error} `x` or `y` is not finite
|
|
129
|
+
*/
|
|
130
|
+
static empty(x: number, y: number): Cubic;
|
|
131
|
+
/**
|
|
132
|
+
* Interpolate linearly between two curves.
|
|
133
|
+
*
|
|
134
|
+
* This returns a new curve whose coordinates are neither validated nor frozen, and may be
|
|
135
|
+
* modified.
|
|
136
|
+
*
|
|
137
|
+
* @param start - curve at progress `0`
|
|
138
|
+
* @param end - curve at progress `1`
|
|
139
|
+
* @param progress - finite progress to interpolate at, extrapolating outside `[0, 1]`
|
|
140
|
+
* @returns interpolated curve
|
|
141
|
+
* @throws {@link Error} `progress` is not finite
|
|
142
|
+
*/
|
|
143
|
+
static interpolate(start: Cubic, end: Cubic, progress: number): Cubic;
|
|
144
|
+
/**
|
|
145
|
+
* Compute the point at a parameter.
|
|
146
|
+
*
|
|
147
|
+
* @param progress - parameter, `0` at start anchor and `1` at end anchor
|
|
148
|
+
* @returns point of curve at `progress`
|
|
149
|
+
* @throws {@link Error} point is not finite
|
|
150
|
+
*/
|
|
151
|
+
pointAt(progress: number): Point;
|
|
152
|
+
/**
|
|
153
|
+
* Test whether curve has zero length.
|
|
154
|
+
*
|
|
155
|
+
* @returns `true` if, and only if, all points are within {@link CUBIC_CONTINUITY_EPSILON} of
|
|
156
|
+
* the start anchor along both axes
|
|
157
|
+
*/
|
|
158
|
+
zeroLength(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Test whether curve turns clockwise into another.
|
|
161
|
+
*
|
|
162
|
+
* @param next - curve following this curve
|
|
163
|
+
* @returns `true` if, and only if, the start anchor of this curve, its end anchor, and the end
|
|
164
|
+
* anchor of `next` turn clockwise
|
|
165
|
+
* @throws {@link Error} an anchor is not finite
|
|
166
|
+
*/
|
|
167
|
+
convexTo(next: Cubic): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Calculate the bounds of the curve.
|
|
170
|
+
*
|
|
171
|
+
* Approximate bounds contain the control points of the curve, and may thus exceed the curve.
|
|
172
|
+
*
|
|
173
|
+
* @param bounds - array to write `[left, top, right, bottom]` into, if any
|
|
174
|
+
* @param approximate - `true` if, and only if, bounds should be approximate
|
|
175
|
+
* @returns `bounds`, or a new array if `bounds` is `undefined`
|
|
176
|
+
* @throws {@link Error} `bounds` has fewer than four entries
|
|
177
|
+
*/
|
|
178
|
+
calculateBounds(bounds?: number[], approximate?: boolean): number[];
|
|
179
|
+
/**
|
|
180
|
+
* Split the curve at a parameter.
|
|
181
|
+
*
|
|
182
|
+
* @param progress - parameter to split at
|
|
183
|
+
* @returns tuple of curves before and after the split point, respectively
|
|
184
|
+
* @throws {@link Error} split point is not finite
|
|
185
|
+
*/
|
|
186
|
+
split(progress: number): [Cubic, Cubic];
|
|
187
|
+
/**
|
|
188
|
+
* Reverse the direction of the curve.
|
|
189
|
+
*
|
|
190
|
+
* @returns curve from end anchor to start anchor of this curve
|
|
191
|
+
* @throws {@link Error} a coordinate is not finite
|
|
192
|
+
*/
|
|
193
|
+
reverse(): Cubic;
|
|
194
|
+
/**
|
|
195
|
+
* Transform the points of the curve.
|
|
196
|
+
*
|
|
197
|
+
* @param transformer - function to transform each point with, in order
|
|
198
|
+
* @returns transformed curve
|
|
199
|
+
* @throws {@link Error} a transformed coordinate is not finite
|
|
200
|
+
*/
|
|
201
|
+
transformed(transformer: PointTransformer): Cubic;
|
|
202
|
+
/**
|
|
203
|
+
* Test whether a value is an equal curve.
|
|
204
|
+
*
|
|
205
|
+
* @param other - value to compare with
|
|
206
|
+
* @returns `true` if, and only if, `other` is a curve with strictly equal coordinates
|
|
207
|
+
*/
|
|
208
|
+
equals(other: unknown): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Format the curve as a string.
|
|
211
|
+
*
|
|
212
|
+
* @returns description of the four points, such as `Cubic(0,0 1,2 3,2 4,0)`
|
|
213
|
+
*/
|
|
214
|
+
toString(): string;
|
|
215
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape and shape morphing definitions.
|
|
3
|
+
*
|
|
4
|
+
* This package provides {@link RoundedPolygon | rounded polygons}, which are closed outlines of
|
|
5
|
+
* cubic Bezier curves, built from vertices with {@link CornerRounding | rounded corners} or by the
|
|
6
|
+
* {@link Shapes} factories. {@link MaterialShapes} provides the Material 3 Expressive shapes, and
|
|
7
|
+
* a {@link Morph} morphs a polygon into another. Outlines are serialized as SVG path data or CSS
|
|
8
|
+
* `path()` functions. All definitions are available on both client-side and server-side.
|
|
9
|
+
*
|
|
10
|
+
* {@link MaterialShapes | Material shapes} are normalized into the unit square. Their
|
|
11
|
+
* {@link toSvgPath | SVG paths} may be drawn in an `<svg viewBox="0 0 1 1">`, or used by an SVG
|
|
12
|
+
* `<clipPath>` whose `clipPathUnits` are `objectBoundingBox`. Likewise, {@link toCssPath} fits
|
|
13
|
+
* them to the box of an element:
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <svg viewBox="0 0 1 1"><path d={toSvgPath(MaterialShapes.Cookie9Sided)} /></svg>
|
|
17
|
+
* <div style={{ "clip-path": toCssPath(MaterialShapes.Heart, 48) }} />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
export type { CubicCoordinates } from "./cubic";
|
|
23
|
+
export type { MaterialShapeName } from "./material-shapes";
|
|
24
|
+
export type { MorphCubicPair } from "./morph";
|
|
25
|
+
export type { PathOptions } from "./path";
|
|
26
|
+
export type { PointTransformer } from "./point";
|
|
27
|
+
export type { PolygonFeatureKind, RoundedPolygonOptions } from "./rounded-polygon";
|
|
28
|
+
export { CornerRounding } from "./corner-rounding";
|
|
29
|
+
export { CUBIC_CONTINUITY_EPSILON, Cubic } from "./cubic";
|
|
30
|
+
export { MATERIAL_SHAPE_NAMES, MaterialShapes } from "./material-shapes";
|
|
31
|
+
export { Morph } from "./morph";
|
|
32
|
+
export { Path, cubicsToPath, formatPathCoordinate, morphToCssPath, morphToPath, roundedPolygonToPath, toCssPath, toSvgPath } from "./path";
|
|
33
|
+
export { Point, directionVector, distanceBetween, isConvex } from "./point";
|
|
34
|
+
export { PolygonFeature, RoundedPolygon, isRoundedPolygon } from "./rounded-polygon";
|
|
35
|
+
export { Shapes } from "./shapes";
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { RoundedPolygon } from "./rounded-polygon";
|
|
2
|
+
/**
|
|
3
|
+
* Union of {@link MaterialShapes | Material shape} names.
|
|
4
|
+
*/
|
|
5
|
+
export type MaterialShapeName = "Circle" | "Square" | "Slanted" | "Arch" | "SemiCircle" | "Oval" | "Pill" | "Triangle" | "Arrow" | "Fan" | "Diamond" | "ClamShell" | "Pentagon" | "Gem" | "VerySunny" | "Sunny" | "Cookie4Sided" | "Cookie6Sided" | "Cookie7Sided" | "Cookie9Sided" | "Cookie12Sided" | "Clover4Leaf" | "Clover8Leaf" | "Burst" | "SoftBurst" | "Boom" | "SoftBoom" | "Flower" | "Puffy" | "PuffyDiamond" | "Ghostish" | "PixelCircle" | "PixelTriangle" | "Bun" | "Heart";
|
|
6
|
+
/**
|
|
7
|
+
* Material 3 Expressive shapes.
|
|
8
|
+
*
|
|
9
|
+
* This builds each shape on first access, normalized into the unit square. Every subsequent
|
|
10
|
+
* access returns the same immutable polygon.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MaterialShapes {
|
|
13
|
+
/**
|
|
14
|
+
* Circle.
|
|
15
|
+
*/
|
|
16
|
+
static get Circle(): RoundedPolygon;
|
|
17
|
+
/**
|
|
18
|
+
* Square with rounded corners.
|
|
19
|
+
*/
|
|
20
|
+
static get Square(): RoundedPolygon;
|
|
21
|
+
/**
|
|
22
|
+
* Rounded parallelogram, slanted to the right.
|
|
23
|
+
*/
|
|
24
|
+
static get Slanted(): RoundedPolygon;
|
|
25
|
+
/**
|
|
26
|
+
* Arch, a square rounded fully at its top.
|
|
27
|
+
*/
|
|
28
|
+
static get Arch(): RoundedPolygon;
|
|
29
|
+
/**
|
|
30
|
+
* Wide rectangle rounded fully at its top.
|
|
31
|
+
*/
|
|
32
|
+
static get SemiCircle(): RoundedPolygon;
|
|
33
|
+
/**
|
|
34
|
+
* Oval, tilted by 45 degrees counter-clockwise.
|
|
35
|
+
*/
|
|
36
|
+
static get Oval(): RoundedPolygon;
|
|
37
|
+
/**
|
|
38
|
+
* Diagonal pill, rising to the right.
|
|
39
|
+
*/
|
|
40
|
+
static get Pill(): RoundedPolygon;
|
|
41
|
+
/**
|
|
42
|
+
* Rounded triangle, pointing up.
|
|
43
|
+
*/
|
|
44
|
+
static get Triangle(): RoundedPolygon;
|
|
45
|
+
/**
|
|
46
|
+
* Rounded arrowhead, pointing up.
|
|
47
|
+
*/
|
|
48
|
+
static get Arrow(): RoundedPolygon;
|
|
49
|
+
/**
|
|
50
|
+
* Square with a large rounded top-right corner.
|
|
51
|
+
*/
|
|
52
|
+
static get Fan(): RoundedPolygon;
|
|
53
|
+
/**
|
|
54
|
+
* Rounded diamond.
|
|
55
|
+
*/
|
|
56
|
+
static get Diamond(): RoundedPolygon;
|
|
57
|
+
/**
|
|
58
|
+
* Rounded hexagon, wide at its sides.
|
|
59
|
+
*/
|
|
60
|
+
static get ClamShell(): RoundedPolygon;
|
|
61
|
+
/**
|
|
62
|
+
* Rounded pentagon, pointing up.
|
|
63
|
+
*/
|
|
64
|
+
static get Pentagon(): RoundedPolygon;
|
|
65
|
+
/**
|
|
66
|
+
* Gem, a rounded heptagon pointing down.
|
|
67
|
+
*/
|
|
68
|
+
static get Gem(): RoundedPolygon;
|
|
69
|
+
/**
|
|
70
|
+
* Rounded star of eight long rays.
|
|
71
|
+
*/
|
|
72
|
+
static get VerySunny(): RoundedPolygon;
|
|
73
|
+
/**
|
|
74
|
+
* Rounded star of eight short rays.
|
|
75
|
+
*/
|
|
76
|
+
static get Sunny(): RoundedPolygon;
|
|
77
|
+
/**
|
|
78
|
+
* Cookie of four lobes.
|
|
79
|
+
*/
|
|
80
|
+
static get Cookie4Sided(): RoundedPolygon;
|
|
81
|
+
/**
|
|
82
|
+
* Cookie of six lobes.
|
|
83
|
+
*/
|
|
84
|
+
static get Cookie6Sided(): RoundedPolygon;
|
|
85
|
+
/**
|
|
86
|
+
* Cookie of seven lobes.
|
|
87
|
+
*/
|
|
88
|
+
static get Cookie7Sided(): RoundedPolygon;
|
|
89
|
+
/**
|
|
90
|
+
* Cookie of nine lobes.
|
|
91
|
+
*/
|
|
92
|
+
static get Cookie9Sided(): RoundedPolygon;
|
|
93
|
+
/**
|
|
94
|
+
* Cookie of twelve lobes.
|
|
95
|
+
*/
|
|
96
|
+
static get Cookie12Sided(): RoundedPolygon;
|
|
97
|
+
/**
|
|
98
|
+
* Clover of four leaves.
|
|
99
|
+
*/
|
|
100
|
+
static get Clover4Leaf(): RoundedPolygon;
|
|
101
|
+
/**
|
|
102
|
+
* Clover of eight leaves.
|
|
103
|
+
*/
|
|
104
|
+
static get Clover8Leaf(): RoundedPolygon;
|
|
105
|
+
/**
|
|
106
|
+
* Burst of twelve sharp points.
|
|
107
|
+
*/
|
|
108
|
+
static get Burst(): RoundedPolygon;
|
|
109
|
+
/**
|
|
110
|
+
* Burst of ten soft points.
|
|
111
|
+
*/
|
|
112
|
+
static get SoftBurst(): RoundedPolygon;
|
|
113
|
+
/**
|
|
114
|
+
* Burst of fifteen long, sharp points.
|
|
115
|
+
*/
|
|
116
|
+
static get Boom(): RoundedPolygon;
|
|
117
|
+
/**
|
|
118
|
+
* Burst of sixteen long, soft points.
|
|
119
|
+
*/
|
|
120
|
+
static get SoftBoom(): RoundedPolygon;
|
|
121
|
+
/**
|
|
122
|
+
* Flower of eight petals.
|
|
123
|
+
*/
|
|
124
|
+
static get Flower(): RoundedPolygon;
|
|
125
|
+
/**
|
|
126
|
+
* Puffy cloud, wider than tall.
|
|
127
|
+
*/
|
|
128
|
+
static get Puffy(): RoundedPolygon;
|
|
129
|
+
/**
|
|
130
|
+
* Puffy diamond.
|
|
131
|
+
*/
|
|
132
|
+
static get PuffyDiamond(): RoundedPolygon;
|
|
133
|
+
/**
|
|
134
|
+
* Ghost with two lobes at its bottom.
|
|
135
|
+
*/
|
|
136
|
+
static get Ghostish(): RoundedPolygon;
|
|
137
|
+
/**
|
|
138
|
+
* Pixelated circle.
|
|
139
|
+
*/
|
|
140
|
+
static get PixelCircle(): RoundedPolygon;
|
|
141
|
+
/**
|
|
142
|
+
* Pixelated triangle, pointing right.
|
|
143
|
+
*/
|
|
144
|
+
static get PixelTriangle(): RoundedPolygon;
|
|
145
|
+
/**
|
|
146
|
+
* Bun of two lobes stacked vertically.
|
|
147
|
+
*/
|
|
148
|
+
static get Bun(): RoundedPolygon;
|
|
149
|
+
/**
|
|
150
|
+
* Heart.
|
|
151
|
+
*/
|
|
152
|
+
static get Heart(): RoundedPolygon;
|
|
153
|
+
/**
|
|
154
|
+
* Retrieve a Material shape by name.
|
|
155
|
+
*
|
|
156
|
+
* @param name - name of shape to retrieve
|
|
157
|
+
* @returns shape named `name`
|
|
158
|
+
* @throws {@link Error} `name` is not the name of a Material shape
|
|
159
|
+
*/
|
|
160
|
+
static byName(name: string): RoundedPolygon;
|
|
161
|
+
/**
|
|
162
|
+
* List all Material shapes.
|
|
163
|
+
*
|
|
164
|
+
* @returns new array of new records of shape names and shapes, in catalog order
|
|
165
|
+
*/
|
|
166
|
+
static all(): {
|
|
167
|
+
readonly name: MaterialShapeName;
|
|
168
|
+
readonly polygon: RoundedPolygon;
|
|
169
|
+
}[];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Names of the {@link MaterialShapes | Material shapes}, in catalog order.
|
|
173
|
+
*
|
|
174
|
+
* This lists the names of the static accessors of {@link MaterialShapes}, in definition order.
|
|
175
|
+
*/
|
|
176
|
+
export declare const MATERIAL_SHAPE_NAMES: readonly MaterialShapeName[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Cubic } from "./cubic";
|
|
2
|
+
import type { RoundedPolygon } from "./rounded-polygon";
|
|
3
|
+
/**
|
|
4
|
+
* Pair of curves morphing into each other.
|
|
5
|
+
*
|
|
6
|
+
* This holds a curve of the start polygon of a {@link Morph}, and the curve of the end polygon it
|
|
7
|
+
* morphs into, respectively.
|
|
8
|
+
*/
|
|
9
|
+
export type MorphCubicPair = readonly [Cubic, Cubic];
|
|
10
|
+
/**
|
|
11
|
+
* Morph between two polygons.
|
|
12
|
+
*
|
|
13
|
+
* This pairs the curves of both outlines, where each pair of curves morphs into each other.
|
|
14
|
+
* Corners of the same convexity are matched by place, in the same circular order, and both
|
|
15
|
+
* outlines are split where needed, until they have as many curves. Morphs work best between
|
|
16
|
+
* normalized polygons, such as the {@link ./material-shapes#MaterialShapes | Material shapes}.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const morph = new Morph(MaterialShapes.Circle, MaterialShapes.Heart);
|
|
20
|
+
*
|
|
21
|
+
* path.setAttribute("d", morphToPath(morph, progress).toSvgPathData());
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class Morph {
|
|
25
|
+
#private;
|
|
26
|
+
/**
|
|
27
|
+
* Polygon at progress `0`.
|
|
28
|
+
*/
|
|
29
|
+
readonly start: RoundedPolygon;
|
|
30
|
+
/**
|
|
31
|
+
* Polygon at progress `1`.
|
|
32
|
+
*/
|
|
33
|
+
readonly end: RoundedPolygon;
|
|
34
|
+
/**
|
|
35
|
+
* Number of curves of each frame.
|
|
36
|
+
*/
|
|
37
|
+
readonly cubicCount: number;
|
|
38
|
+
/**
|
|
39
|
+
* Construct a new morph.
|
|
40
|
+
*
|
|
41
|
+
* @param start - polygon at progress `0`
|
|
42
|
+
* @param end - polygon at progress `1`
|
|
43
|
+
* @throws {@link Error} a polygon outline has no length
|
|
44
|
+
*/
|
|
45
|
+
constructor(start: RoundedPolygon, end: RoundedPolygon);
|
|
46
|
+
/**
|
|
47
|
+
* Compute the curves of a frame.
|
|
48
|
+
*
|
|
49
|
+
* Frames are closed outlines, whose curves continue each other exactly. This returns new
|
|
50
|
+
* curves, which belong to the caller.
|
|
51
|
+
*
|
|
52
|
+
* @param progress - finite progress of frame, extrapolating outside `[0, 1]`
|
|
53
|
+
* @returns {@link Morph.cubicCount} curves, in outline order
|
|
54
|
+
* @throws {@link Error} `progress` is not finite
|
|
55
|
+
*/
|
|
56
|
+
asCubics(progress: number): Cubic[];
|
|
57
|
+
/**
|
|
58
|
+
* Invoke a function for each curve of a frame.
|
|
59
|
+
*
|
|
60
|
+
* This does **not** collect the curves into an array.
|
|
61
|
+
*
|
|
62
|
+
* @param progress - finite progress of frame, extrapolating outside `[0, 1]`
|
|
63
|
+
* @param callback - function to invoke with each curve {@link Morph.asCubics} would return, in
|
|
64
|
+
* outline order
|
|
65
|
+
* @throws {@link Error} `progress` is not finite
|
|
66
|
+
*/
|
|
67
|
+
forEachCubic(progress: number, callback: (cubic: Cubic) => void): void;
|
|
68
|
+
/**
|
|
69
|
+
* Calculate bounds containing both polygons.
|
|
70
|
+
*
|
|
71
|
+
* Frames of progress outside `[0, 1]` may exceed these bounds. Approximate bounds contain the
|
|
72
|
+
* control points of the curves, and may thus exceed the outlines.
|
|
73
|
+
*
|
|
74
|
+
* @param bounds - array to write `[left, top, right, bottom]` into, if any
|
|
75
|
+
* @param approximate - `true` if, and only if, bounds should be approximate
|
|
76
|
+
* @returns `bounds`, or a new array if `bounds` is `undefined`
|
|
77
|
+
* @throws {@link Error} `bounds` has fewer than four entries
|
|
78
|
+
*/
|
|
79
|
+
calculateBounds(bounds?: number[], approximate?: boolean): number[];
|
|
80
|
+
/**
|
|
81
|
+
* Calculate bounds of both polygons in any rotation.
|
|
82
|
+
*
|
|
83
|
+
* The bounds contain both polygons in any rotation around their centers.
|
|
84
|
+
*
|
|
85
|
+
* @param bounds - array to write `[left, top, right, bottom]` into, if any
|
|
86
|
+
* @returns `bounds`, or a new array if `bounds` is `undefined`
|
|
87
|
+
* @throws {@link Error} `bounds` has fewer than four entries
|
|
88
|
+
* @see {@link ./rounded-polygon#RoundedPolygon.calculateMaxBounds}
|
|
89
|
+
*/
|
|
90
|
+
calculateMaxBounds(bounds?: number[]): number[];
|
|
91
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { Cubic } from "./cubic";
|
|
2
|
+
import type { Morph } from "./morph";
|
|
3
|
+
import type { RoundedPolygon } from "./rounded-polygon";
|
|
4
|
+
/**
|
|
5
|
+
* {@link roundedPolygonToPath} and {@link morphToPath} options.
|
|
6
|
+
*/
|
|
7
|
+
export interface PathOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Start angle of the outline, in degrees.
|
|
10
|
+
*
|
|
11
|
+
* This is measured clockwise from 3 o'clock. If set, the outline is rotated around its center
|
|
12
|
+
* until its first point lies at this angle; otherwise, the outline is not rotated. For
|
|
13
|
+
* example, `270` starts the outline at 12 o'clock.
|
|
14
|
+
*/
|
|
15
|
+
startAngle?: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Outline is traced twice.
|
|
18
|
+
*
|
|
19
|
+
* If `true`, the outline is traced twice, joined by a line of zero length. This allows a dash
|
|
20
|
+
* pattern to run across the start of the outline.
|
|
21
|
+
*
|
|
22
|
+
* @defaultValue `false`
|
|
23
|
+
*/
|
|
24
|
+
repeatPath?: boolean | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Format a path coordinate.
|
|
28
|
+
*
|
|
29
|
+
* This rounds the coordinate to five decimal places, with halves towards positive infinity. The
|
|
30
|
+
* result has no trailing zeros, exponent, or sign of a negative zero.
|
|
31
|
+
*
|
|
32
|
+
* @param value - finite coordinate to format
|
|
33
|
+
* @returns formatted coordinate
|
|
34
|
+
* @throws {@link Error} `value` is not finite
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatPathCoordinate(value: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Builder of SVG path data.
|
|
39
|
+
*
|
|
40
|
+
* This formats coordinates with {@link formatPathCoordinate}. Paths may be reused, as each
|
|
41
|
+
* outline written into a path replaces its commands.
|
|
42
|
+
*/
|
|
43
|
+
export declare class Path {
|
|
44
|
+
#private;
|
|
45
|
+
/**
|
|
46
|
+
* Construct a new path without commands.
|
|
47
|
+
*/
|
|
48
|
+
constructor();
|
|
49
|
+
/**
|
|
50
|
+
* Start a new subpath.
|
|
51
|
+
*
|
|
52
|
+
* @param x - horizontal coordinate of start
|
|
53
|
+
* @param y - vertical coordinate of start
|
|
54
|
+
* @returns this path
|
|
55
|
+
* @throws {@link Error} a coordinate is not finite
|
|
56
|
+
*/
|
|
57
|
+
moveTo(x: number, y: number): this;
|
|
58
|
+
/**
|
|
59
|
+
* Append a straight line.
|
|
60
|
+
*
|
|
61
|
+
* @param x - horizontal coordinate of end
|
|
62
|
+
* @param y - vertical coordinate of end
|
|
63
|
+
* @returns this path
|
|
64
|
+
* @throws {@link Error} a coordinate is not finite
|
|
65
|
+
*/
|
|
66
|
+
lineTo(x: number, y: number): this;
|
|
67
|
+
/**
|
|
68
|
+
* Append a cubic Bezier curve.
|
|
69
|
+
*
|
|
70
|
+
* @param control0X - horizontal coordinate of first control point
|
|
71
|
+
* @param control0Y - vertical coordinate of first control point
|
|
72
|
+
* @param control1X - horizontal coordinate of second control point
|
|
73
|
+
* @param control1Y - vertical coordinate of second control point
|
|
74
|
+
* @param anchorX - horizontal coordinate of end
|
|
75
|
+
* @param anchorY - vertical coordinate of end
|
|
76
|
+
* @returns this path
|
|
77
|
+
* @throws {@link Error} a coordinate is not finite
|
|
78
|
+
*/
|
|
79
|
+
cubicTo(control0X: number, control0Y: number, control1X: number, control1Y: number, anchorX: number, anchorY: number): this;
|
|
80
|
+
/**
|
|
81
|
+
* Close the current subpath.
|
|
82
|
+
*
|
|
83
|
+
* @returns this path
|
|
84
|
+
*/
|
|
85
|
+
close(): this;
|
|
86
|
+
/**
|
|
87
|
+
* Remove all commands.
|
|
88
|
+
*
|
|
89
|
+
* @returns this path
|
|
90
|
+
*/
|
|
91
|
+
rewind(): this;
|
|
92
|
+
/**
|
|
93
|
+
* Serialize commands as SVG path data.
|
|
94
|
+
*
|
|
95
|
+
* @returns path data, such as `M0 0L1 0Z`
|
|
96
|
+
*/
|
|
97
|
+
toSvgPathData(): string;
|
|
98
|
+
/**
|
|
99
|
+
* Serialize commands as SVG path data.
|
|
100
|
+
*
|
|
101
|
+
* @returns path data
|
|
102
|
+
* @see {@link Path.toSvgPathData}
|
|
103
|
+
*/
|
|
104
|
+
toString(): string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Write curves into a path.
|
|
108
|
+
*
|
|
109
|
+
* @param cubics - closed outline of at least one curve
|
|
110
|
+
* @param path - path to replace commands of, if any
|
|
111
|
+
* @returns `path`, or a new path if `path` is `undefined`
|
|
112
|
+
* @throws {@link Error} `cubics` is empty, or a coordinate is not finite
|
|
113
|
+
*/
|
|
114
|
+
export declare function cubicsToPath(cubics: readonly Cubic[], path?: Path): Path;
|
|
115
|
+
/**
|
|
116
|
+
* Write the outline of a polygon into a path.
|
|
117
|
+
*
|
|
118
|
+
* @param polygon - polygon to write outline of
|
|
119
|
+
* @param options - start angle and repetition of outline, if any
|
|
120
|
+
* @param path - path to replace commands of, if any
|
|
121
|
+
* @returns `path`, or a new path if `path` is `undefined`
|
|
122
|
+
* @throws {@link Error} a coordinate is not finite
|
|
123
|
+
*/
|
|
124
|
+
export declare function roundedPolygonToPath(polygon: RoundedPolygon, options?: PathOptions, path?: Path): Path;
|
|
125
|
+
/**
|
|
126
|
+
* Write a frame of a morph into a path.
|
|
127
|
+
*
|
|
128
|
+
* The start angle, if any, applies around the center interpolated between the centers of both
|
|
129
|
+
* polygons.
|
|
130
|
+
*
|
|
131
|
+
* @param morph - morph to write frame of
|
|
132
|
+
* @param progress - finite progress of frame, extrapolating outside `[0, 1]`
|
|
133
|
+
* @param options - start angle and repetition of outline, if any
|
|
134
|
+
* @param path - path to replace commands of, if any
|
|
135
|
+
* @returns `path`, or a new path if `path` is `undefined`
|
|
136
|
+
* @throws {@link Error} `progress` or a coordinate is not finite
|
|
137
|
+
*/
|
|
138
|
+
export declare function morphToPath(morph: Morph, progress: number, options?: PathOptions, path?: Path): Path;
|
|
139
|
+
/**
|
|
140
|
+
* Serialize polygon outline as SVG path data.
|
|
141
|
+
*
|
|
142
|
+
* For example, a {@link ./material-shapes#MaterialShapes | Material shape} may be drawn in an
|
|
143
|
+
* `<svg viewBox="0 0 1 1">`, or as an SVG `<clipPath>` with `clipPathUnits="objectBoundingBox"`.
|
|
144
|
+
*
|
|
145
|
+
* @param polygon - polygon to serialize outline of
|
|
146
|
+
* @returns path data
|
|
147
|
+
* @throws {@link Error} a coordinate is not finite
|
|
148
|
+
*/
|
|
149
|
+
export declare function toSvgPath(polygon: RoundedPolygon): string;
|
|
150
|
+
/**
|
|
151
|
+
* Serialize polygon outline as a CSS `path()`.
|
|
152
|
+
*
|
|
153
|
+
* This maps the unit square onto a box, and centers the approximate bounds of the outline
|
|
154
|
+
* within the box. In other words, this fits a normalized polygon to the box, for example for
|
|
155
|
+
* `clip-path`.
|
|
156
|
+
*
|
|
157
|
+
* @param polygon - polygon to serialize outline of, normally within the unit square
|
|
158
|
+
* @param width - positive width of box, in CSS pixels
|
|
159
|
+
* @param height - positive height of box, in CSS pixels, or `undefined` for a square box
|
|
160
|
+
* @returns CSS `path()` function
|
|
161
|
+
* @throws {@link Error} `width` or `height` is not positive and finite, or a coordinate is not
|
|
162
|
+
* finite
|
|
163
|
+
*/
|
|
164
|
+
export declare function toCssPath(polygon: RoundedPolygon, width: number, height?: number): string;
|
|
165
|
+
/**
|
|
166
|
+
* Serialize morph frame as a CSS `path()`.
|
|
167
|
+
*
|
|
168
|
+
* @param morph - morph to serialize frame of, normally between polygons within the unit square
|
|
169
|
+
* @param progress - finite progress of frame, extrapolating outside `[0, 1]`
|
|
170
|
+
* @param width - positive width of box, in CSS pixels
|
|
171
|
+
* @param height - positive height of box, in CSS pixels, or `undefined` for a square box
|
|
172
|
+
* @returns CSS `path()` function
|
|
173
|
+
* @throws {@link Error} `progress` is not finite, `width` or `height` is not positive and finite,
|
|
174
|
+
* or a coordinate is not finite
|
|
175
|
+
* @see {@link toCssPath}
|
|
176
|
+
*/
|
|
177
|
+
export declare function morphToCssPath(morph: Morph, progress: number, width: number, height?: number): string;
|