@popcraft/kit 0.1.0
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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/index.js +160558 -0
- package/package.json +40 -0
- package/types/design-script.d.ts +39 -0
- package/types/lib/agent/design-script/build.d.ts +35 -0
- package/types/lib/agent/design-script/check.d.ts +11 -0
- package/types/lib/agent/design-script/helper-names.d.ts +1 -0
- package/types/lib/agent/design-script/kit-modules.d.ts +43 -0
- package/types/lib/agent/design-script/recorder.d.ts +52 -0
- package/types/lib/agent/design-script/replay.d.ts +13 -0
- package/types/lib/agent/design-script/run-node.d.ts +2 -0
- package/types/lib/ai/audio-models.d.ts +66 -0
- package/types/lib/ai/content.d.ts +27 -0
- package/types/lib/ai/limits.d.ts +42 -0
- package/types/lib/audio/presentation/loudness.d.ts +80 -0
- package/types/lib/audio/presentation/types.d.ts +112 -0
- package/types/lib/brand/apply.d.ts +25 -0
- package/types/lib/brand/review-kits.d.ts +10 -0
- package/types/lib/brand/types.d.ts +20 -0
- package/types/lib/code/hash.d.ts +2 -0
- package/types/lib/document/auto-layout.d.ts +10 -0
- package/types/lib/document/breakpoints.d.ts +45 -0
- package/types/lib/document/clone.d.ts +6 -0
- package/types/lib/document/color.d.ts +52 -0
- package/types/lib/document/detach.d.ts +12 -0
- package/types/lib/document/effects.d.ts +60 -0
- package/types/lib/document/expressions.d.ts +78 -0
- package/types/lib/document/instance-layout.d.ts +94 -0
- package/types/lib/document/instances.d.ts +63 -0
- package/types/lib/document/libraries.d.ts +97 -0
- package/types/lib/document/node-delta.d.ts +21 -0
- package/types/lib/document/page-tokens.d.ts +16 -0
- package/types/lib/document/photo-frames.d.ts +14 -0
- package/types/lib/document/print-pages.d.ts +85 -0
- package/types/lib/document/scene-graph.d.ts +194 -0
- package/types/lib/document/scene3d.d.ts +76 -0
- package/types/lib/document/shader-graph-effects.d.ts +8 -0
- package/types/lib/document/shader-graph.d.ts +134 -0
- package/types/lib/document/shader-params.d.ts +65 -0
- package/types/lib/document/shape-to-path.d.ts +20 -0
- package/types/lib/document/text-styles.d.ts +28 -0
- package/types/lib/document/text-tokens.d.ts +6 -0
- package/types/lib/document/transform.d.ts +79 -0
- package/types/lib/document/transform3d.d.ts +99 -0
- package/types/lib/document/trim.d.ts +35 -0
- package/types/lib/document/types.d.ts +2560 -0
- package/types/lib/document/variables.d.ts +14 -0
- package/types/lib/editor/easing.d.ts +46 -0
- package/types/lib/editor/modes/types.d.ts +131 -0
- package/types/lib/editor/prototype-connect.d.ts +49 -0
- package/types/lib/editor/smart-animate.d.ts +37 -0
- package/types/lib/engine/geometry/flatten.d.ts +2 -0
- package/types/lib/engine/geometry/shape-outline.d.ts +24 -0
- package/types/lib/engine/pixel/cells.d.ts +12 -0
- package/types/lib/engine/pixel/palettes.d.ts +25 -0
- package/types/lib/engine/readiness.d.ts +20 -0
- package/types/lib/engine/routing.d.ts +41 -0
- package/types/lib/engine/shader-graph-presets.d.ts +22 -0
- package/types/lib/engine/shader-presets-legacy.d.ts +7 -0
- package/types/lib/engine/shader-presets.d.ts +43 -0
- package/types/lib/engine/text/atlas.d.ts +120 -0
- package/types/lib/engine/text/emoji/segment.d.ts +15 -0
- package/types/lib/engine/text/fallback-fonts.d.ts +47 -0
- package/types/lib/engine/text/fontkit-lazy.d.ts +8 -0
- package/types/lib/engine/text/fonts.d.ts +33 -0
- package/types/lib/engine/text/glyph-linear.d.ts +22 -0
- package/types/lib/engine/text/google-fonts.d.ts +17 -0
- package/types/lib/engine/text/hyphenate/en-us.d.ts +6 -0
- package/types/lib/engine/text/hyphenate/liang.d.ts +21 -0
- package/types/lib/engine/text/layout-access.d.ts +16 -0
- package/types/lib/engine/text/layout.d.ts +168 -0
- package/types/lib/engine/text/lists.d.ts +16 -0
- package/types/lib/engine/text/measure.d.ts +58 -0
- package/types/lib/engine/text/outline-sdf.d.ts +34 -0
- package/types/lib/engine/text/shaper.d.ts +88 -0
- package/types/lib/engine/text/text-area.d.ts +16 -0
- package/types/lib/engine/text/text-fit.d.ts +51 -0
- package/types/lib/engine/text/text-path.d.ts +134 -0
- package/types/lib/engine/text/text-rings.d.ts +17 -0
- package/types/lib/engine/text/wrap-obstacles.d.ts +20 -0
- package/types/lib/i18n/catalogs.d.ts +10 -0
- package/types/lib/i18n/format.d.ts +27 -0
- package/types/lib/i18n/locales.d.ts +25 -0
- package/types/lib/i18n/pseudo.d.ts +10 -0
- package/types/lib/i18n/runtime.d.ts +27 -0
- package/types/lib/io/codecs/wav.d.ts +7 -0
- package/types/lib/io/codecs/webp.d.ts +7 -0
- package/types/lib/io/export-ir/children.d.ts +2 -0
- package/types/lib/io/json-export.d.ts +11 -0
- package/types/lib/media-library/types.d.ts +39 -0
- package/types/lib/motion/audio-analysis.d.ts +44 -0
- package/types/lib/motion/audio-clips.d.ts +92 -0
- package/types/lib/motion/audio-onsets.d.ts +13 -0
- package/types/lib/motion/audio-signals.d.ts +59 -0
- package/types/lib/motion/author.d.ts +80 -0
- package/types/lib/motion/composition.d.ts +99 -0
- package/types/lib/motion/instances.d.ts +95 -0
- package/types/lib/motion/key-selection.d.ts +100 -0
- package/types/lib/motion/keys.d.ts +41 -0
- package/types/lib/motion/layer-time-edit.d.ts +40 -0
- package/types/lib/motion/markers.d.ts +31 -0
- package/types/lib/motion/modifier-edit.d.ts +84 -0
- package/types/lib/motion/modifiers.d.ts +44 -0
- package/types/lib/motion/morph.d.ts +14 -0
- package/types/lib/motion/pose-layout.d.ts +6 -0
- package/types/lib/motion/pose.d.ts +115 -0
- package/types/lib/motion/presets.d.ts +148 -0
- package/types/lib/motion/properties.d.ts +74 -0
- package/types/lib/motion/sample-keys.d.ts +8 -0
- package/types/lib/motion/sample.d.ts +51 -0
- package/types/lib/motion/sound.d.ts +25 -0
- package/types/lib/motion/spatial-curve.d.ts +15 -0
- package/types/lib/motion/spatial.d.ts +38 -0
- package/types/lib/motion/text-animators.d.ts +79 -0
- package/types/lib/motion/text-units.d.ts +47 -0
- package/types/lib/motion/time.d.ts +58 -0
- package/types/lib/motion/transitions.d.ts +99 -0
- package/types/lib/motion/values.d.ts +12 -0
- package/types/lib/motion/video-clip.d.ts +63 -0
- package/types/lib/presets/page-presets.d.ts +50 -0
- package/types/lib/storage/media-hash.d.ts +4 -0
- package/types/lib/storage/media-refs.d.ts +2 -0
- package/types/lib/storage/media-store.d.ts +70 -0
- package/types/lib/templates/apply.d.ts +38 -0
- package/types/lib/templates/capture.d.ts +25 -0
- package/types/lib/templates/groups.d.ts +82 -0
- package/types/lib/templates/layout.d.ts +20 -0
- package/types/lib/templates/quality.d.ts +59 -0
- package/types/lib/templates/resize.d.ts +34 -0
- package/types/lib/templates/safe-areas.d.ts +42 -0
- package/types/lib/templates/text-measurer.d.ts +10 -0
- package/types/lib/templates/thumbnail.d.ts +134 -0
- package/types/lib/templates/types.d.ts +95 -0
- package/types/lib/templates/vocabulary.d.ts +50 -0
- package/types/lib/units/units.d.ts +23 -0
- package/types/packages/kit/src/index.d.ts +59 -0
- package/types/packages/runtime/src/expressions.d.ts +41 -0
- package/types/templates/src/app/shared.d.ts +29 -0
- package/types/templates/src/audio/beat-loop.d.ts +9 -0
- package/types/templates/src/audio/media.d.ts +42 -0
- package/types/templates/src/audio/music-synth.d.ts +57 -0
- package/types/templates/src/audio/music-worlds.d.ts +8 -0
- package/types/templates/src/audio/music.d.ts +19 -0
- package/types/templates/src/audio/studio/deck.d.ts +340 -0
- package/types/templates/src/audio/studio/dsp.d.ts +151 -0
- package/types/templates/src/audio/studio/fx.d.ts +96 -0
- package/types/templates/src/audio/studio/mix.d.ts +84 -0
- package/types/templates/src/audio/studio/voices.d.ts +120 -0
- package/types/templates/src/data/geometry.d.ts +16 -0
- package/types/templates/src/effects/shared.d.ts +17 -0
- package/types/templates/src/kit.d.ts +582 -0
- package/types/templates/src/motion3d/devices.d.ts +42 -0
- package/types/templates/src/motion3d/ui.d.ts +48 -0
- package/types/templates/src/saas/video-shared.d.ts +114 -0
- package/types/templates/src/saas/web-shared.d.ts +74 -0
- package/types/templates/src/shared/beat.d.ts +24 -0
- package/types/templates/src/shared/captions.d.ts +24 -0
- package/types/templates/src/shared/devices.d.ts +188 -0
- package/types/templates/src/shared/draw.d.ts +43 -0
- package/types/templates/src/shared/fit.d.ts +73 -0
- package/types/templates/src/shared/marks.d.ts +51 -0
- package/types/templates/src/shared/motion.d.ts +15 -0
- package/types/templates/src/shared/overlays.d.ts +80 -0
- package/types/templates/src/shared/pointer.d.ts +46 -0
- package/types/templates/src/shared/texture.d.ts +41 -0
- package/types/templates/src/shared/type.d.ts +6 -0
- package/types/templates/src/shared/window.d.ts +50 -0
- package/types/templates/src/social/shared.d.ts +66 -0
- package/types/templates/src/web/shared.d.ts +64 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { BaseNode, TransformRest } from './types.js';
|
|
2
|
+
export type Affine = readonly [a: number, b: number, c: number, d: number, e: number, f: number];
|
|
3
|
+
export interface Bounds {
|
|
4
|
+
minX: number;
|
|
5
|
+
minY: number;
|
|
6
|
+
maxX: number;
|
|
7
|
+
maxY: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const IDENTITY: Affine;
|
|
10
|
+
/** The node fields that place its box. Everything but the box is optional and defaults to the rest pose below. */
|
|
11
|
+
export type TransformFields = Pick<BaseNode, 'x' | 'y' | 'width' | 'height'> & TransformRest & Partial<Pick<BaseNode, 'rotation' | 'flipHorizontal' | 'flipVertical'>>;
|
|
12
|
+
/** The numeric transform fields a node may carry, and the value each takes when absent. */
|
|
13
|
+
/** (rotateX, rotateY and z place a layer of a 3D context: lib/document/transform3d.ts; the 2D matrix ignores them.) */
|
|
14
|
+
export declare const TRANSFORM_DEFAULTS: Readonly<Required<TransformRest>>;
|
|
15
|
+
export type TransformField = keyof TransformRest;
|
|
16
|
+
export declare const TRANSFORM_FIELDS: TransformField[];
|
|
17
|
+
/** A transform field's value, or its default when absent or not a finite number (a NaN scale would erase the node). */
|
|
18
|
+
export declare function restValue(node: TransformRest, field: TransformField): number;
|
|
19
|
+
/** The transform fields a node carries that are not finite numbers: they would collapse or erase its matrix. */
|
|
20
|
+
export declare function invalidTransformFields(node: TransformRest): TransformField[];
|
|
21
|
+
export declare function multiply(m: Affine, n: Affine): Affine;
|
|
22
|
+
export declare const determinant: (m: Affine) => number;
|
|
23
|
+
/** The inverse, or null when the matrix is singular (a zero scale): callers skip hit-testing and drawing then. */
|
|
24
|
+
export declare function invert(m: Affine): Affine | null;
|
|
25
|
+
export declare function apply(m: Affine, x: number, y: number): [number, number];
|
|
26
|
+
/** The linear part applied to a vector (no translation): offsets, directions, extents. */
|
|
27
|
+
export declare function applyLinear(m: Affine, x: number, y: number): [number, number];
|
|
28
|
+
export declare const translation: (x: number, y: number) => Affine;
|
|
29
|
+
export declare const isIdentity: (m: Affine) => boolean;
|
|
30
|
+
/** The flip each axis of a node applies: its flip flag, or a negative scale on that axis (either one mirrors). */
|
|
31
|
+
export declare function nodeFlips(node: TransformFields): {
|
|
32
|
+
flipX: boolean;
|
|
33
|
+
flipY: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The node's box (top-left origin, unscaled `width × height`) in its parent's box:
|
|
37
|
+
* `T(x + ax·w + tx, y + ay·h + ty) · R(rotation) · S(sx·flipX, sy·flipY) · T(−ax·w, −ay·h)`, with the anchor
|
|
38
|
+
* `(ax, ay)` a fraction of the box (0.5 is the centre; values outside 0..1 pivot outside the box).
|
|
39
|
+
*
|
|
40
|
+
* `ignoreFlips` for text: the GPU places glyphs without mirroring. `shiftX/shiftY` append `T(−shift)`: the frame a
|
|
41
|
+
* scrolled container gives its children. Written out rather than multiplied so a node at rest (scale 1, anchor
|
|
42
|
+
* 0.5, no translate) gets bit for bit the matrix it always had.
|
|
43
|
+
*/
|
|
44
|
+
export declare function localMatrix(node: TransformFields, ignoreFlips?: boolean, shiftX?: number, shiftY?: number): Affine;
|
|
45
|
+
/**
|
|
46
|
+
* Where the centre of the node's box lands in its parent's box. At the default anchor this is exactly
|
|
47
|
+
* `(x + w/2, y + h/2)`, which is what every centre-based caller always computed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function localCentre(node: TransformFields): [number, number];
|
|
50
|
+
export interface Decomposition {
|
|
51
|
+
tx: number;
|
|
52
|
+
ty: number;
|
|
53
|
+
rotation: number;
|
|
54
|
+
scaleX: number;
|
|
55
|
+
scaleY: number;
|
|
56
|
+
skew: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* QR decomposition `m = T(tx, ty) · R(rotation) · S(scaleX, scaleY) · Shear(skew)`, rotation in radians.
|
|
60
|
+
* `scaleX ≥ 0`; `scaleY` is negative when the matrix mirrors (negative determinant). A zero first column
|
|
61
|
+
* (scaleX 0) reports rotation 0 and takes the rest from the second column.
|
|
62
|
+
*/
|
|
63
|
+
export declare function decompose(m: Affine): Decomposition;
|
|
64
|
+
/**
|
|
65
|
+
* `m` with the given axes un-mirrored about the centre of its `w × h` box: `m · T(w/2, h/2) · S(±1, ±1) · T(−w/2, −h/2)`.
|
|
66
|
+
* The box centre lands where it did. Used to decompose a flipped placement into rotation and scale, and by the
|
|
67
|
+
* callers that never mirror (the GPU draws glyphs unflipped).
|
|
68
|
+
*/
|
|
69
|
+
export declare function withoutFlips(m: Affine, flipX: boolean, flipY: boolean, w: number, h: number): Affine;
|
|
70
|
+
/** `deg` moved by whole turns to lie within half a turn of `reference`, so 350° stays 350° rather than −10°. */
|
|
71
|
+
export declare function nearestAngle(deg: number, reference: number): number;
|
|
72
|
+
/** The four corners of a `w × h` box under `m`: top-left, top-right, bottom-right, bottom-left. */
|
|
73
|
+
export declare function boxCorners(m: Affine, w: number, h: number): [number, number][];
|
|
74
|
+
/** The axis-aligned bounds of a `w × h` box under `m`, grown by `pad` on every side. */
|
|
75
|
+
export declare function aabbOf(m: Affine, w: number, h: number, pad?: number): Bounds;
|
|
76
|
+
/** How much `m` scales lengths on average (√|det|): stroke overhang and blur radii grow by this much. */
|
|
77
|
+
export declare const lengthScale: (m: Affine) => number;
|
|
78
|
+
/** The larger of the two axis scales: a bounding circle of radius r grows to r times this. */
|
|
79
|
+
export declare const maxAxisScale: (m: Affine) => number;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type Affine, type TransformFields } from './transform.js';
|
|
2
|
+
import type { Scene3D } from './types.js';
|
|
3
|
+
export type Mat4 = readonly number[];
|
|
4
|
+
export type Vec4 = [x: number, y: number, z: number, w: number];
|
|
5
|
+
export declare const IDENTITY4: Mat4;
|
|
6
|
+
/** a · b. */
|
|
7
|
+
export declare function mul4(a: Mat4, b: Mat4): Mat4;
|
|
8
|
+
/** The product of `ms`, left to right. */
|
|
9
|
+
export declare const chain4: (...ms: Mat4[]) => Mat4;
|
|
10
|
+
/** M · (x, y, z, w). */
|
|
11
|
+
export declare function transform4(m: Mat4, x: number, y: number, z: number, w?: number): Vec4;
|
|
12
|
+
/** The inverse, or null when singular (a layer scaled to nothing, a camera inside its own plane). */
|
|
13
|
+
export declare function invert4(m: Mat4): Mat4 | null;
|
|
14
|
+
export declare const translate4: (x: number, y: number, z: number) => Mat4;
|
|
15
|
+
export declare const scale4: (x: number, y: number, z?: number) => Mat4;
|
|
16
|
+
/** CSS rotateX: positive tips the top edge away from the viewer (y down, z toward the viewer). */
|
|
17
|
+
export declare function rotateX4(deg: number): Mat4;
|
|
18
|
+
/** CSS rotateY: positive turns the right edge away from the viewer. */
|
|
19
|
+
export declare function rotateY4(deg: number): Mat4;
|
|
20
|
+
/** CSS rotate / rotateZ: clockwise on screen, exactly as the 2-D `rotation`. */
|
|
21
|
+
export declare function rotateZ4(deg: number): Mat4;
|
|
22
|
+
/** A 2-D affine as a 4×4 acting on x, y (and the homogeneous w), leaving z alone. */
|
|
23
|
+
export declare const fromAffine: (m: Affine) => Mat4;
|
|
24
|
+
/**
|
|
25
|
+
* A layer's box (top-left origin, unscaled `width × height`, z = 0) in its parent's 3D space:
|
|
26
|
+
* `T(x + ax·w + tx, y + ay·h + ty, z) · Rz(rotation) · Ry(rotateY) · Rx(rotateX) · S(sx·flipX, sy·flipY, 1) · T(−ax·w, −ay·h, 0)`.
|
|
27
|
+
* With no rotateX/rotateY/z it is the 2-D `localMatrix`, so a layer untouched in 3D lands where it always did.
|
|
28
|
+
*/
|
|
29
|
+
export declare function layerModel(node: TransformFields): Mat4;
|
|
30
|
+
/** Whether a node carries any 3D placement (it is drawn differently from its 2-D matrix inside a context). */
|
|
31
|
+
export declare const has3DPlacement: (n: TransformFields) => boolean;
|
|
32
|
+
/** The film width a focal length is measured against (a full-frame 35 mm still). */
|
|
33
|
+
export declare const FILM_MM = 36;
|
|
34
|
+
/** The default lens: CSS `perspective: 2000px` on a 1920-wide context is ~37.5 mm; 50 mm is the classic normal. */
|
|
35
|
+
export declare const DEFAULT_FOCAL_MM = 50;
|
|
36
|
+
/** Camera-space depth (px) in front of the eye where geometry is clipped. */
|
|
37
|
+
export declare const NEAR_PX = 1;
|
|
38
|
+
/** The zoom distance in px (CSS `perspective`) of a focal length, for a context `width` px wide. */
|
|
39
|
+
export declare const zoomPx: (focalMm: number, width: number) => number;
|
|
40
|
+
/** The focal length (mm) that gives the CSS `perspective` `px` for a context `width` px wide. */
|
|
41
|
+
export declare const focalFromPerspective: (px: number, width: number) => number;
|
|
42
|
+
/** The horizontal field of view (degrees) a focal length gives: derived, never stored. */
|
|
43
|
+
export declare const fovDegrees: (focalMm: number) => number;
|
|
44
|
+
export interface SceneFrame {
|
|
45
|
+
/** Context space → camera space. */
|
|
46
|
+
view: Mat4;
|
|
47
|
+
/** Camera space → the context's box, homogeneous (divide by w): the CSS perspective projection, depth for near clipping in z. */
|
|
48
|
+
projection: Mat4;
|
|
49
|
+
/** The camera's eye in context space. */
|
|
50
|
+
eye: [number, number, number];
|
|
51
|
+
/** The zoom distance (px). */
|
|
52
|
+
zoom: number;
|
|
53
|
+
/** The perspective origin in the box (px). */
|
|
54
|
+
origin: [number, number];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The camera of a context `w × h`: eye = point of interest + orbit · (0, 0, zoom), then pan/tilt/roll about the eye,
|
|
58
|
+
* the whole rig offset by (x, y, z). An untouched camera is the CSS viewer: at the zoom distance in front of the
|
|
59
|
+
* perspective origin, so a layer at z 0 draws at exactly its flat size and place.
|
|
60
|
+
*/
|
|
61
|
+
export declare function sceneFrame(scene: Scene3D, w: number, h: number): SceneFrame;
|
|
62
|
+
/**
|
|
63
|
+
* Camera space → the context box, homogeneous: X = zoom·x − ox·z, Y = zoom·y − oy·z, W = −z (the distance in front),
|
|
64
|
+
* Z = W − NEAR_PX. The GPU keeps 0 ≤ Z ≤ W, so what is behind the near plane is clipped (never drawn inverted).
|
|
65
|
+
*/
|
|
66
|
+
export declare const perspectiveProjection: (zoom: number, ox: number, oy: number) => Mat4;
|
|
67
|
+
/**
|
|
68
|
+
* The convex polygon `pts` (homogeneous clip-space points, w = distance in front of the eye) clipped to w ≥ `near`
|
|
69
|
+
* (Sutherland–Hodgman against one plane). A polygon crossing the camera loses the part behind it; one entirely
|
|
70
|
+
* behind comes back empty. Every point returned has w ≥ near, so dividing by w never flips it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function clipNear(pts: readonly Vec4[], near?: number): Vec4[];
|
|
73
|
+
/** A convex polygon in a layer's plane (local x, y) through `m` (local → homogeneous 2-D), clipped at the near plane and divided. */
|
|
74
|
+
export declare function projectPolygon(m: Mat4, pts: readonly (readonly [number, number])[]): [number, number][];
|
|
75
|
+
/** A layer's `rect` (local x0, y0, x1, y1) through `m`: the outline on screen (see `projectPolygon`). */
|
|
76
|
+
export declare const projectRect: (m: Mat4, x0: number, y0: number, x1: number, y1: number) => [number, number][];
|
|
77
|
+
/**
|
|
78
|
+
* Where the screen point (sx, sy) — in the context box — lands on a layer's plane: its local (x, y), or null when
|
|
79
|
+
* the ray misses it (edge on) or meets it behind the eye. `modelView` maps the layer's box to camera space.
|
|
80
|
+
*/
|
|
81
|
+
export declare function unprojectToLayer(modelView: Mat4, frame: Pick<SceneFrame, 'zoom' | 'origin'>, sx: number, sy: number): [number, number] | null;
|
|
82
|
+
/**
|
|
83
|
+
* The largest texel density (device px per local px) of the local point (x, y) under `m` (local → homogeneous
|
|
84
|
+
* device px): the larger singular value of the projection's 2×2 Jacobian there. Infinity at or behind the eye.
|
|
85
|
+
*/
|
|
86
|
+
export declare function densityAt(m: Mat4, x: number, y: number): number;
|
|
87
|
+
/** The density a layer's rect needs: the largest at its corners (a plane's density peaks at a corner). */
|
|
88
|
+
export declare function rectDensity(m: Mat4, x0: number, y0: number, x1: number, y1: number): number;
|
|
89
|
+
/** The smallest raster scale a layer is flattened at, however far away it is. */
|
|
90
|
+
export declare const MIN_RASTER_SCALE: number;
|
|
91
|
+
/** The largest: past this a card rushing at the camera is magnified rather than re-rasterised bigger. */
|
|
92
|
+
export declare const MAX_RASTER_SCALE = 4;
|
|
93
|
+
/**
|
|
94
|
+
* A density quantised up to a power of √2, clamped to [MIN, MAX] and so that `extent` (the layer's larger side, px)
|
|
95
|
+
* fits `maxTexels`: small camera moves land in the same bucket and reuse the flattened texture.
|
|
96
|
+
*/
|
|
97
|
+
export declare function rasterBucket(density: number, extent: number, maxTexels: number): number;
|
|
98
|
+
/** Whether a texture flattened at `cached` still serves a layer wanting `wanted`: no coarser, and at most 2× finer. */
|
|
99
|
+
export declare const bucketServes: (cached: number, wanted: number) => boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AnyNode, StrokeTrim } from './types.js';
|
|
2
|
+
export declare const TRIM_REST: Readonly<StrokeTrim>;
|
|
3
|
+
/** Whether the layer can carry a trim: an outline of its own with a stroke that follows it (not a brush stroke or an arc). */
|
|
4
|
+
export declare function canTrim(node: AnyNode): boolean;
|
|
5
|
+
/** The layer's trim, hiding any of the stroke or not. */
|
|
6
|
+
export declare function trimOf(node: AnyNode): StrokeTrim | undefined;
|
|
7
|
+
/** Whether the trim leaves the whole line. */
|
|
8
|
+
export declare function isFullTrim(t: StrokeTrim): boolean;
|
|
9
|
+
/** The layer's trim when it hides some of the stroke. */
|
|
10
|
+
export declare function activeTrim(node: AnyNode): StrokeTrim | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The visible stretches as fractions of the length, in order along the line: one, or two when the offset carries
|
|
13
|
+
* the stretch past the end and round to the start. `[[0, 1]]` is the whole line, `[]` none of it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function trimSpans(t: StrokeTrim): [number, number][];
|
|
16
|
+
/** Flattened outlines cut to the trim: what the stroke follows. */
|
|
17
|
+
export declare function trimPolylines(polys: number[][], t: StrokeTrim): number[][];
|
|
18
|
+
/**
|
|
19
|
+
* The dash a layer's stroke draws with: the first visible stroke's `[dash, gap]` (the first two entries of its
|
|
20
|
+
* `dashPattern`, as the shape shader and the exporters read it), or undefined for a solid line.
|
|
21
|
+
*/
|
|
22
|
+
export declare function dashOf(node: AnyNode): [number, number] | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Flattened outlines cut into dashes: `on` drawn, `off` skipped, by arc length from each polyline's start (so a
|
|
25
|
+
* trimmed line, dashed after the trim, starts on a dash, as SVG, PDF and Lottie dash a trimmed path).
|
|
26
|
+
*/
|
|
27
|
+
export declare function dashPolylines(polys: number[][], on: number, off: number): number[][];
|
|
28
|
+
/**
|
|
29
|
+
* A trimmed shape as the vector the canvas draws it with (the shape shader has no trim): the same box, paints and
|
|
30
|
+
* effects over `shapeToVectorPath`'s outline. One object per shape object, so the vector's `paths` keep their identity
|
|
31
|
+
* while the shape is unchanged and the geometry cache holds.
|
|
32
|
+
*/
|
|
33
|
+
export declare function trimmedShapeAsVector(node: AnyNode): AnyNode;
|
|
34
|
+
/** `nodes` with every trimmed shape drawn as a vector (the same map when there is none). Memoised per map. */
|
|
35
|
+
export declare function withTrimmedShapesAsVectors(nodes: Record<string, AnyNode>): Record<string, AnyNode>;
|