@twick/2d 0.15.8 → 0.15.10

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.
@@ -0,0 +1,2112 @@
1
+ import * as _twick_core from '@twick/core';
2
+ import { SimpleSignal, SignalValue, Vector2Signal, PossibleColor, PossibleVector2, Color, Vector2, Signal, SignalContext, TimingFunction, ThreadGenerator, InterpolationFunction, WebGLConvertible, PlaybackState, ReferenceReceiver, Promisable, SimpleVector2Signal, SpacingSignal, ColorSignal, PossibleSpacing, BBox, SerializedVector2, Origin } from '@twick/core';
3
+
4
+ /**
5
+ * All possible CSS filter names.
6
+ *
7
+ * @internal
8
+ */
9
+ type FilterName = 'invert' | 'sepia' | 'grayscale' | 'brightness' | 'contrast' | 'saturate' | 'hue' | 'blur';
10
+ /**
11
+ * Definitions of all possible CSS filters.
12
+ *
13
+ * @internal
14
+ */
15
+ declare const FILTERS: Record<string, Partial<FilterProps>>;
16
+ /**
17
+ * A unified abstraction for all CSS filters.
18
+ */
19
+ interface FilterProps {
20
+ name: string;
21
+ value: SignalValue<number>;
22
+ unit: string;
23
+ scale: number;
24
+ transform: boolean;
25
+ default: number;
26
+ }
27
+ declare class Filter {
28
+ get name(): string;
29
+ get default(): number;
30
+ readonly value: SimpleSignal<number, Filter>;
31
+ private readonly props;
32
+ constructor(props: Partial<FilterProps>);
33
+ isActive(): boolean;
34
+ serialize(matrix: DOMMatrix): string;
35
+ }
36
+ /**
37
+ * Create an {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/invert | invert} filter.
38
+ *
39
+ * @param value - The value of the filter.
40
+ */
41
+ declare function invert(value?: SignalValue<number>): Filter;
42
+ /**
43
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/sepia | sepia} filter.
44
+ *
45
+ * @param value - The value of the filter.
46
+ */
47
+ declare function sepia(value?: SignalValue<number>): Filter;
48
+ /**
49
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/grayscale | grayscale} filter.
50
+ *
51
+ * @param value - The value of the filter.
52
+ */
53
+ declare function grayscale(value?: SignalValue<number>): Filter;
54
+ /**
55
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/brightness | brightness} filter.
56
+ *
57
+ * @param value - The value of the filter.
58
+ */
59
+ declare function brightness(value?: SignalValue<number>): Filter;
60
+ /**
61
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/contrast | contrast} filter.
62
+ *
63
+ * @param value - The value of the filter.
64
+ */
65
+ declare function contrast(value?: SignalValue<number>): Filter;
66
+ /**
67
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/saturate | saturate} filter.
68
+ *
69
+ * @param value - The value of the filter.
70
+ */
71
+ declare function saturate(value?: SignalValue<number>): Filter;
72
+ /**
73
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/hue-rotate | hue} filter.
74
+ *
75
+ * @param value - The value of the filter in degrees.
76
+ */
77
+ declare function hue(value?: SignalValue<number>): Filter;
78
+ /**
79
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/blur | blur} filter.
80
+ *
81
+ * @param value - The value of the filter in pixels.
82
+ */
83
+ declare function blur(value?: SignalValue<number>): Filter;
84
+
85
+ type GradientType = 'linear' | 'conic' | 'radial';
86
+ interface GradientStop {
87
+ offset: SignalValue<number>;
88
+ color: SignalValue<PossibleColor>;
89
+ }
90
+ interface GradientProps {
91
+ type?: SignalValue<GradientType>;
92
+ fromX?: SignalValue<number>;
93
+ fromY?: SignalValue<number>;
94
+ from?: SignalValue<PossibleVector2>;
95
+ toX?: SignalValue<number>;
96
+ toY?: SignalValue<number>;
97
+ to?: SignalValue<PossibleVector2>;
98
+ angle?: SignalValue<number>;
99
+ fromRadius?: SignalValue<number>;
100
+ toRadius?: SignalValue<number>;
101
+ stops?: GradientStop[];
102
+ }
103
+ declare class Gradient {
104
+ readonly type: SimpleSignal<GradientType, this>;
105
+ readonly from: Vector2Signal<this>;
106
+ readonly to: Vector2Signal<this>;
107
+ readonly angle: SimpleSignal<number, this>;
108
+ readonly fromRadius: SimpleSignal<number, this>;
109
+ readonly toRadius: SimpleSignal<number, this>;
110
+ readonly stops: SimpleSignal<GradientStop[], this>;
111
+ constructor(props: GradientProps);
112
+ canvasGradient(context: CanvasRenderingContext2D): CanvasGradient;
113
+ }
114
+
115
+ type CanvasRepetition = null | 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
116
+ interface PatternProps {
117
+ image: CanvasImageSource;
118
+ repetition?: CanvasRepetition;
119
+ }
120
+ declare class Pattern {
121
+ readonly image: SimpleSignal<CanvasImageSource, this>;
122
+ readonly repetition: SimpleSignal<CanvasRepetition, this>;
123
+ constructor(props: PatternProps);
124
+ canvasPattern(context: CanvasRenderingContext2D): CanvasPattern | null;
125
+ }
126
+
127
+ type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
128
+ type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
129
+ type FlexBasis = Length | 'content' | 'max-content' | 'min-content' | 'fit-content' | null;
130
+ type FlexContent = 'center' | 'start' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch';
131
+ type FlexItems = 'center' | 'start' | 'end' | 'stretch' | 'baseline';
132
+ type TextWrap = boolean | 'pre' | 'balance';
133
+ type LayoutMode = boolean | null;
134
+ /**
135
+ * Represents a length used by most layout properties.
136
+ *
137
+ * @remarks
138
+ * The value can be either:
139
+ * - `number` - the desired length in pixels
140
+ * - `${number}%` - a string with the desired length in percents, for example
141
+ * `'50%'`
142
+ */
143
+ type Length = number | `${number}%`;
144
+ /**
145
+ * Represents a desired length used internally by layout Nodes.
146
+ *
147
+ * @remarks
148
+ * When the desired length is set to `null` it represents a default value for
149
+ * whatever property it describes.
150
+ */
151
+ type DesiredLength = Length | null;
152
+ /**
153
+ * Represents a length limit used by layout properties such as `max-width`.
154
+ */
155
+ type LengthLimit = Length | null | 'max-content' | 'min-content';
156
+ type PossibleCanvasStyle = null | PossibleColor | Gradient | Pattern;
157
+ type CanvasStyle = null | Color | Gradient | Pattern;
158
+
159
+ interface CurveDrawingInfo {
160
+ path: Path2D;
161
+ arrowSize: number;
162
+ endPoint: Vector2;
163
+ endTangent: Vector2;
164
+ startPoint: Vector2;
165
+ startTangent: Vector2;
166
+ startOffset: number;
167
+ }
168
+
169
+ interface CurvePoint {
170
+ position: Vector2;
171
+ /**
172
+ * @deprecated
173
+ * The tangent is currently inconsistent for different types of curves and may
174
+ * sometimes return the normal of the point, instead. This will be fixed in
175
+ * the next major version but is kept as is for now for backwards
176
+ * compatibility reasons. To always get the real tangent of the point, you can
177
+ * use `normal.flipped.perpendicular`, instead.
178
+ */
179
+ tangent: Vector2;
180
+ normal: Vector2;
181
+ }
182
+
183
+ declare abstract class Segment {
184
+ abstract readonly points: Vector2[];
185
+ abstract draw(context: CanvasRenderingContext2D | Path2D, start: number, end: number, move: boolean): [CurvePoint, CurvePoint];
186
+ abstract getPoint(distance: number): CurvePoint;
187
+ abstract get arcLength(): number;
188
+ }
189
+
190
+ interface CurveProfile {
191
+ arcLength: number;
192
+ segments: Segment[];
193
+ minSin: number;
194
+ }
195
+
196
+ type CanvasStyleSignal<T> = Signal<PossibleCanvasStyle, CanvasStyle, T>;
197
+ declare function canvasStyleSignal(): PropertyDecorator;
198
+
199
+ type FiltersSignal<TOwner> = Signal<Filter[], Filter[], TOwner, FiltersSignalContext<TOwner>> & {
200
+ [K in FilterName]: SimpleSignal<number, TOwner>;
201
+ };
202
+ declare class FiltersSignalContext<TOwner> extends SignalContext<Filter[], Filter[], TOwner> {
203
+ constructor(initial: Filter[], owner: TOwner);
204
+ tweener(value: SignalValue<Filter[]>, duration: number, timingFunction: TimingFunction): ThreadGenerator;
205
+ }
206
+ declare function filtersSignal(): PropertyDecorator;
207
+
208
+ /**
209
+ * @internal
210
+ */
211
+ declare const NODE_NAME: unique symbol;
212
+ /**
213
+ * @internal
214
+ */
215
+ declare function nodeName(name: string): (target: any) => void;
216
+
217
+ interface PropertyMetadata<T> {
218
+ default?: T;
219
+ interpolationFunction?: InterpolationFunction<T>;
220
+ parser?: (value: any) => T;
221
+ getter?: () => T;
222
+ setter?: (value: any) => void;
223
+ tweener?: (value: T, duration: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<T>) => void;
224
+ cloneable?: boolean;
225
+ inspectable?: boolean;
226
+ compoundParent?: string;
227
+ compound?: boolean;
228
+ compoundEntries: [string, string][];
229
+ }
230
+ declare function getPropertyMeta<T>(object: any, key: string | symbol): PropertyMetadata<T> | null;
231
+ declare function getPropertyMetaOrCreate<T>(object: any, key: string | symbol): PropertyMetadata<T>;
232
+ declare function getPropertiesOf(value: any): Record<string, PropertyMetadata<any>>;
233
+ declare function initializeSignals(instance: any, props: Record<string, any>): void;
234
+ /**
235
+ * Create a signal decorator.
236
+ *
237
+ * @remarks
238
+ * This decorator turns the given property into a signal.
239
+ *
240
+ * The class using this decorator can implement the following methods:
241
+ * - `get[PropertyName]` - A property getter.
242
+ * - `get[PropertyName]` - A property setter.
243
+ * - `tween[PropertyName]` - A tween provider.
244
+ *
245
+ * @example
246
+ * ```ts
247
+ * class Example {
248
+ * \@property()
249
+ * public declare length: Signal<number, this>;
250
+ * }
251
+ * ```
252
+ */
253
+ declare function signal<T>(): PropertyDecorator;
254
+ /**
255
+ * Create an initial signal value decorator.
256
+ *
257
+ * @remarks
258
+ * This decorator specifies the initial value of a property.
259
+ *
260
+ * Must be specified before the {@link signal} decorator.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * class Example {
265
+ * \@initial(1)
266
+ * \@property()
267
+ * public declare length: Signal<number, this>;
268
+ * }
269
+ * ```
270
+ *
271
+ * @param value - The initial value of the property.
272
+ */
273
+ declare function initial<T>(value: T): PropertyDecorator;
274
+ /**
275
+ * Create a signal interpolation function decorator.
276
+ *
277
+ * @remarks
278
+ * This decorator specifies the interpolation function of a property.
279
+ * The interpolation function is used when tweening between different values.
280
+ *
281
+ * Must be specified before the {@link signal} decorator.
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * class Example {
286
+ * \@interpolation(textLerp)
287
+ * \@property()
288
+ * public declare text: Signal<string, this>;
289
+ * }
290
+ * ```
291
+ *
292
+ * @param value - The interpolation function for the property.
293
+ */
294
+ declare function interpolation<T>(value: InterpolationFunction<T>): PropertyDecorator;
295
+ /**
296
+ * Create a signal parser decorator.
297
+ *
298
+ * @remarks
299
+ * This decorator specifies the parser of a property.
300
+ * Instead of returning the raw value, its passed as the first parameter to the
301
+ * parser and the resulting value is returned.
302
+ *
303
+ * If the wrapper class has a method called `lerp` it will be set as the
304
+ * default interpolation function for the property.
305
+ *
306
+ * Must be specified before the {@link signal} decorator.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * class Example {
311
+ * \@wrapper(Vector2)
312
+ * \@property()
313
+ * public declare offset: Signal<Vector2, this>;
314
+ * }
315
+ * ```
316
+ *
317
+ * @param value - The wrapper class for the property.
318
+ */
319
+ declare function parser<T>(value: (value: any) => T): PropertyDecorator;
320
+ /**
321
+ * Create a signal wrapper decorator.
322
+ *
323
+ * @remarks
324
+ * This is a shortcut decorator for setting both the {@link parser} and
325
+ * {@link interpolation}.
326
+ *
327
+ * The interpolation function will be set only if the wrapper class has a method
328
+ * called `lerp`, which will be used as said function.
329
+ *
330
+ * Must be specified before the {@link signal} decorator.
331
+ *
332
+ * @example
333
+ * ```ts
334
+ * class Example {
335
+ * \@wrapper(Vector2)
336
+ * \@property()
337
+ * public declare offset: Signal<Vector2, this>;
338
+ *
339
+ * // same as:
340
+ * \@parser(value => new Vector2(value))
341
+ * \@interpolation(Vector2.lerp)
342
+ * \@property()
343
+ * public declare offset: Signal<Vector2, this>;
344
+ * }
345
+ * ```
346
+ *
347
+ * @param value - The wrapper class for the property.
348
+ */
349
+ declare function wrapper<T>(value: (new (value: any) => T) & {
350
+ lerp?: InterpolationFunction<T>;
351
+ }): PropertyDecorator;
352
+ /**
353
+ * Create a cloneable property decorator.
354
+ *
355
+ * @remarks
356
+ * This decorator specifies whether the property should be copied over when
357
+ * cloning the node.
358
+ *
359
+ * By default, any property is cloneable.
360
+ *
361
+ * Must be specified before the {@link signal} decorator.
362
+ *
363
+ * @example
364
+ * ```ts
365
+ * class Example {
366
+ * \@clone(false)
367
+ * \@property()
368
+ * public declare length: Signal<number, this>;
369
+ * }
370
+ * ```
371
+ *
372
+ * @param value - Whether the property should be cloneable.
373
+ */
374
+ declare function cloneable<T>(value?: boolean): PropertyDecorator;
375
+ /**
376
+ * Create an inspectable property decorator.
377
+ *
378
+ * @remarks
379
+ * This decorator specifies whether the property should be visible in the
380
+ * inspector.
381
+ *
382
+ * By default, any property is inspectable.
383
+ *
384
+ * Must be specified before the {@link signal} decorator.
385
+ *
386
+ * @example
387
+ * ```ts
388
+ * class Example {
389
+ * \@inspectable(false)
390
+ * \@property()
391
+ * public declare hiddenLength: Signal<number, this>;
392
+ * }
393
+ * ```
394
+ *
395
+ * @param value - Whether the property should be inspectable.
396
+ */
397
+ declare function inspectable<T>(value?: boolean): PropertyDecorator;
398
+
399
+ type Vector2LengthSignal<TOwner> = Signal<PossibleVector2<Length>, Vector2, TOwner> & {
400
+ x: Signal<Length, number, TOwner>;
401
+ y: Signal<Length, number, TOwner>;
402
+ };
403
+ declare function vector2Signal(prefix?: string | Record<string, string>): PropertyDecorator;
404
+
405
+ /**
406
+ * Describes a shader program used to apply effects to nodes.
407
+ *
408
+ * @experimental
409
+ */
410
+ interface ShaderConfig {
411
+ /**
412
+ * The source code of the fragment shader.
413
+ *
414
+ * @example
415
+ * ```glsl
416
+ * #version 300 es
417
+ * precision highp float;
418
+ *
419
+ * #include "@twick/core/shaders/common.glsl"
420
+ *
421
+ * void main() {
422
+ * out_color = texture(core_source_tx, source_uv);
423
+ * }
424
+ * ```
425
+ */
426
+ fragment: string;
427
+ /**
428
+ * Custom uniforms to be passed to the shader.
429
+ *
430
+ * @remarks
431
+ * The keys of this object will be used as the uniform names.
432
+ * The values can be either a number or an array of numbers.
433
+ * The following table shows how the values will be mapped to GLSL types.
434
+ *
435
+ * | TypeScript | GLSL |
436
+ * | ---------------------------------- | ------- |
437
+ * | `number` | `float` |
438
+ * | `[number, number]` | `vec2` |
439
+ * | `[number, number, number]` | `vec3` |
440
+ * | `[number, number, number, number]` | `vec4` |
441
+ *
442
+ * @example
443
+ * ```ts
444
+ * const shader = {
445
+ * // ...
446
+ * uniforms: {
447
+ * my_value: () => 1,
448
+ * my_vector: [1, 2, 3],
449
+ * },
450
+ * };
451
+ * ```
452
+ *
453
+ * ```glsl
454
+ * uniform float my_value;
455
+ * uniform vec3 my_vector;
456
+ * ```
457
+ */
458
+ uniforms?: Record<string, SignalValue<number | number[] | WebGLConvertible>>;
459
+ /**
460
+ * A custom hook run before the shader is used.
461
+ *
462
+ * @remarks
463
+ * Gives you low-level access to the WebGL context and the shader program.
464
+ *
465
+ * @param gl - WebGL context.
466
+ * @param program - The shader program.
467
+ */
468
+ setup?: (gl: WebGL2RenderingContext, program: WebGLProgram) => void;
469
+ /**
470
+ * A custom hook run after the shader is used.
471
+ *
472
+ * @remarks
473
+ * Gives you low-level access to the WebGL context and the shader program.
474
+ * Can be used to clean up resources created in the {@link setup} hook.
475
+ *
476
+ * @param gl - WebGL context.
477
+ * @param program - The shader program.
478
+ */
479
+ teardown?: (gl: WebGL2RenderingContext, program: WebGLProgram) => void;
480
+ }
481
+ type PossibleShaderConfig = (ShaderConfig | string)[] | ShaderConfig | string | null;
482
+
483
+ interface View2DProps extends RectProps {
484
+ assetHash: string;
485
+ }
486
+ declare class View2D extends Rect {
487
+ static shadowRoot: ShadowRoot;
488
+ readonly playbackState: SimpleSignal<PlaybackState, this>;
489
+ readonly globalTime: SimpleSignal<number, this>;
490
+ readonly fps: SimpleSignal<number, this>;
491
+ readonly assetHash: SimpleSignal<string, this>;
492
+ constructor(props: View2DProps);
493
+ dispose(): void;
494
+ render(context: CanvasRenderingContext2D): Promise<void>;
495
+ /**
496
+ * Find a node by its key.
497
+ *
498
+ * @param key - The key of the node.
499
+ */
500
+ findKey<T extends Node = Node>(key: string): T | null;
501
+ protected requestLayoutUpdate(): void;
502
+ protected requestFontUpdate(): void;
503
+ view(): View2D;
504
+ }
505
+
506
+ type ComponentChild = Node | object | string | number | bigint | boolean | null | undefined;
507
+ type ComponentChildren = ComponentChild | ComponentChild[];
508
+ type NodeChildren = Node | Node[];
509
+ type PropsOf<T> = T extends NodeConstructor<infer P> ? P : T extends FunctionComponent<infer P> ? P : never;
510
+ interface JSXProps {
511
+ children?: ComponentChildren;
512
+ ref?: ReferenceReceiver<Node>;
513
+ }
514
+ interface FunctionComponent<T = any> {
515
+ (props: T): Node | null;
516
+ }
517
+ interface NodeConstructor<TProps = any, TNode = Node> {
518
+ new (props: TProps): TNode;
519
+ }
520
+
521
+ type NodeState = NodeProps & Record<string, any>;
522
+ interface NodeProps {
523
+ ref?: ReferenceReceiver<any>;
524
+ children?: SignalValue<ComponentChildren>;
525
+ /**
526
+ * @deprecated Use {@link children} instead.
527
+ */
528
+ spawner?: SignalValue<ComponentChildren>;
529
+ key?: string;
530
+ x?: SignalValue<number>;
531
+ y?: SignalValue<number>;
532
+ position?: SignalValue<PossibleVector2>;
533
+ rotation?: SignalValue<number>;
534
+ scaleX?: SignalValue<number>;
535
+ scaleY?: SignalValue<number>;
536
+ scale?: SignalValue<PossibleVector2>;
537
+ skewX?: SignalValue<number>;
538
+ skewY?: SignalValue<number>;
539
+ skew?: SignalValue<PossibleVector2>;
540
+ zIndex?: SignalValue<number>;
541
+ opacity?: SignalValue<number>;
542
+ filters?: SignalValue<Filter[]>;
543
+ shadowColor?: SignalValue<PossibleColor>;
544
+ shadowBlur?: SignalValue<number>;
545
+ shadowOffsetX?: SignalValue<number>;
546
+ shadowOffsetY?: SignalValue<number>;
547
+ shadowOffset?: SignalValue<PossibleVector2>;
548
+ cache?: SignalValue<boolean>;
549
+ /**
550
+ * {@inheritDoc Node.cachePadding}
551
+ */
552
+ cachePaddingTop?: SignalValue<number>;
553
+ /**
554
+ * {@inheritDoc Node.cachePadding}
555
+ */
556
+ cachePaddingBottom?: SignalValue<number>;
557
+ /**
558
+ * {@inheritDoc Node.cachePadding}
559
+ */
560
+ cachePaddingLeft?: SignalValue<number>;
561
+ /**
562
+ * {@inheritDoc Node.cachePadding}
563
+ */
564
+ cachePaddingRight?: SignalValue<number>;
565
+ /**
566
+ * {@inheritDoc Node.cachePadding}
567
+ */
568
+ cachePadding?: SignalValue<PossibleSpacing>;
569
+ composite?: SignalValue<boolean>;
570
+ compositeOperation?: SignalValue<GlobalCompositeOperation>;
571
+ /**
572
+ * @experimental
573
+ */
574
+ shaders?: PossibleShaderConfig;
575
+ }
576
+ declare class Node implements Promisable<Node> {
577
+ /**
578
+ * @internal
579
+ */
580
+ readonly [NODE_NAME]: string;
581
+ isClass: boolean;
582
+ /**
583
+ * Represents the position of this node in local space of its parent.
584
+ *
585
+ * @example
586
+ * Initializing the position:
587
+ * ```tsx
588
+ * // with a possible vector:
589
+ * <Node position={[1, 2]} />
590
+ * // with individual components:
591
+ * <Node x={1} y={2} />
592
+ * ```
593
+ *
594
+ * Accessing the position:
595
+ * ```tsx
596
+ * // retrieving the vector:
597
+ * const position = node.position();
598
+ * // retrieving an individual component:
599
+ * const x = node.position.x();
600
+ * ```
601
+ *
602
+ * Setting the position:
603
+ * ```tsx
604
+ * // with a possible vector:
605
+ * node.position([1, 2]);
606
+ * node.position(() => [1, 2]);
607
+ * // with individual components:
608
+ * node.position.x(1);
609
+ * node.position.x(() => 1);
610
+ * ```
611
+ */
612
+ readonly position: Vector2Signal<this>;
613
+ get x(): SimpleSignal<number, this>;
614
+ get y(): SimpleSignal<number, this>;
615
+ /**
616
+ * A helper signal for operating on the position in world space.
617
+ *
618
+ * @remarks
619
+ * Retrieving the position using this signal returns the position in world
620
+ * space. Similarly, setting the position using this signal transforms the
621
+ * new value to local space.
622
+ *
623
+ * If the new value is a function, the position of this node will be
624
+ * continuously updated to always match the position returned by the function.
625
+ * This can be useful to "pin" the node in a specific place or to make it
626
+ * follow another node's position.
627
+ *
628
+ * Unlike {@link position}, this signal is not compound - it doesn't contain
629
+ * separate signals for the `x` and `y` components.
630
+ */
631
+ readonly absolutePosition: SimpleVector2Signal<this>;
632
+ protected getAbsolutePosition(): Vector2;
633
+ protected setAbsolutePosition(value: SignalValue<PossibleVector2>): void;
634
+ /**
635
+ * Represents the rotation (in degrees) of this node relative to its parent.
636
+ */
637
+ readonly rotation: SimpleSignal<number, this>;
638
+ /**
639
+ * A helper signal for operating on the rotation in world space.
640
+ *
641
+ * @remarks
642
+ * Retrieving the rotation using this signal returns the rotation in world
643
+ * space. Similarly, setting the rotation using this signal transforms the
644
+ * new value to local space.
645
+ *
646
+ * If the new value is a function, the rotation of this node will be
647
+ * continuously updated to always match the rotation returned by the function.
648
+ */
649
+ readonly absoluteRotation: SimpleSignal<number, this>;
650
+ protected getAbsoluteRotation(): number;
651
+ protected setAbsoluteRotation(value: SignalValue<number>): void;
652
+ /**
653
+ * Represents the scale of this node in local space of its parent.
654
+ *
655
+ * @example
656
+ * Initializing the scale:
657
+ * ```tsx
658
+ * // with a possible vector:
659
+ * <Node scale={[1, 2]} />
660
+ * // with individual components:
661
+ * <Node scaleX={1} scaleY={2} />
662
+ * ```
663
+ *
664
+ * Accessing the scale:
665
+ * ```tsx
666
+ * // retrieving the vector:
667
+ * const scale = node.scale();
668
+ * // retrieving an individual component:
669
+ * const scaleX = node.scale.x();
670
+ * ```
671
+ *
672
+ * Setting the scale:
673
+ * ```tsx
674
+ * // with a possible vector:
675
+ * node.scale([1, 2]);
676
+ * node.scale(() => [1, 2]);
677
+ * // with individual components:
678
+ * node.scale.x(1);
679
+ * node.scale.x(() => 1);
680
+ * ```
681
+ */
682
+ readonly scale: Vector2Signal<this>;
683
+ /**
684
+ * Represents the skew of this node in local space of its parent.
685
+ *
686
+ * @example
687
+ * Initializing the skew:
688
+ * ```tsx
689
+ * // with a possible vector:
690
+ * <Node skew={[40, 20]} />
691
+ * // with individual components:
692
+ * <Node skewX={40} skewY={20} />
693
+ * ```
694
+ *
695
+ * Accessing the skew:
696
+ * ```tsx
697
+ * // retrieving the vector:
698
+ * const skew = node.skew();
699
+ * // retrieving an individual component:
700
+ * const skewX = node.skew.x();
701
+ * ```
702
+ *
703
+ * Setting the skew:
704
+ * ```tsx
705
+ * // with a possible vector:
706
+ * node.skew([40, 20]);
707
+ * node.skew(() => [40, 20]);
708
+ * // with individual components:
709
+ * node.skew.x(40);
710
+ * node.skew.x(() => 40);
711
+ * ```
712
+ */
713
+ readonly skew: Vector2Signal<this>;
714
+ /**
715
+ * A helper signal for operating on the scale in world space.
716
+ *
717
+ * @remarks
718
+ * Retrieving the scale using this signal returns the scale in world space.
719
+ * Similarly, setting the scale using this signal transforms the new value to
720
+ * local space.
721
+ *
722
+ * If the new value is a function, the scale of this node will be continuously
723
+ * updated to always match the position returned by the function.
724
+ *
725
+ * Unlike {@link scale}, this signal is not compound - it doesn't contain
726
+ * separate signals for the `x` and `y` components.
727
+ */
728
+ readonly absoluteScale: SimpleVector2Signal<this>;
729
+ protected getAbsoluteScale(): Vector2;
730
+ protected setAbsoluteScale(value: SignalValue<PossibleVector2>): void;
731
+ private getRelativeScale;
732
+ readonly zIndex: SimpleSignal<number, this>;
733
+ readonly cache: SimpleSignal<boolean, this>;
734
+ /**
735
+ * Controls the padding of the cached canvas used by this node.
736
+ *
737
+ * @remarks
738
+ * By default, the size of the cache is determined based on the bounding box
739
+ * of the node and its children. That includes effects such as stroke or
740
+ * shadow. This property can be used to expand the cache area further.
741
+ * Usually used to account for custom effects created by {@link shaders}.
742
+ */
743
+ readonly cachePadding: SpacingSignal<this>;
744
+ readonly composite: SimpleSignal<boolean, this>;
745
+ readonly compositeOperation: SimpleSignal<GlobalCompositeOperation, this>;
746
+ private readonly compositeOverride;
747
+ protected tweenCompositeOperation(value: SignalValue<GlobalCompositeOperation>, time: number, timingFunction: TimingFunction): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>;
748
+ /**
749
+ * Represents the opacity of this node in the range 0-1.
750
+ *
751
+ * @remarks
752
+ * The value is clamped to the range 0-1.
753
+ */
754
+ readonly opacity: SimpleSignal<number, this>;
755
+ absoluteOpacity(): number;
756
+ readonly filters: FiltersSignal<this>;
757
+ readonly shadowColor: ColorSignal<this>;
758
+ readonly shadowBlur: SimpleSignal<number, this>;
759
+ readonly shadowOffset: Vector2Signal<this>;
760
+ /**
761
+ * @experimental
762
+ */
763
+ readonly shaders: Signal<PossibleShaderConfig, ShaderConfig[], this>;
764
+ protected hasFilters(): boolean;
765
+ protected hasShadow(): boolean;
766
+ protected filterString(): string;
767
+ /**
768
+ * @deprecated Use {@link children} instead.
769
+ */
770
+ protected readonly spawner: SimpleSignal<ComponentChildren, this>;
771
+ protected getSpawner(): ComponentChildren;
772
+ protected setSpawner(value: SignalValue<ComponentChildren>): void;
773
+ readonly children: Signal<ComponentChildren, Node[], this>;
774
+ protected setChildren(value: SignalValue<ComponentChildren>): void;
775
+ protected getChildren(): Node[];
776
+ protected spawnedChildren(): Node[];
777
+ protected sortedChildren(): Node[];
778
+ protected view2D: View2D;
779
+ private stateStack;
780
+ protected realChildren: Node[];
781
+ protected hasSpawnedChildren: boolean;
782
+ private unregister;
783
+ readonly parent: SimpleSignal<Node | null, void>;
784
+ readonly properties: Record<string, PropertyMetadata<any>>;
785
+ readonly key: string;
786
+ readonly creationStack?: string;
787
+ constructor({ children, spawner, key, ...rest }: NodeProps);
788
+ /**
789
+ * Get the local-to-world matrix for this node.
790
+ *
791
+ * @remarks
792
+ * This matrix transforms vectors from local space of this node to world
793
+ * space.
794
+ *
795
+ * @example
796
+ * Calculate the absolute position of a point located 200 pixels to the right
797
+ * of the node:
798
+ * ```ts
799
+ * const local = new Vector2(0, 200);
800
+ * const world = transformVectorAsPoint(local, node.localToWorld());
801
+ * ```
802
+ */
803
+ localToWorld(): DOMMatrix;
804
+ /**
805
+ * Get the world-to-local matrix for this node.
806
+ *
807
+ * @remarks
808
+ * This matrix transforms vectors from world space to local space of this
809
+ * node.
810
+ *
811
+ * @example
812
+ * Calculate the position relative to this node for a point located in the
813
+ * top-left corner of the screen:
814
+ * ```ts
815
+ * const world = new Vector2(0, 0);
816
+ * const local = transformVectorAsPoint(world, node.worldToLocal());
817
+ * ```
818
+ */
819
+ worldToLocal(): DOMMatrix;
820
+ /**
821
+ * Get the world-to-parent matrix for this node.
822
+ *
823
+ * @remarks
824
+ * This matrix transforms vectors from world space to local space of this
825
+ * node's parent.
826
+ */
827
+ worldToParent(): DOMMatrix;
828
+ /**
829
+ * Get the local-to-parent matrix for this node.
830
+ *
831
+ * @remarks
832
+ * This matrix transforms vectors from local space of this node to local space
833
+ * of this node's parent.
834
+ */
835
+ localToParent(): DOMMatrix;
836
+ /**
837
+ * A matrix mapping composite space to world space.
838
+ *
839
+ * @remarks
840
+ * Certain effects such as blur and shadows ignore the current transformation.
841
+ * This matrix can be used to transform their parameters so that the effect
842
+ * appears relative to the closest composite root.
843
+ */
844
+ compositeToWorld(): DOMMatrix;
845
+ protected compositeRoot(): Node | null;
846
+ compositeToLocal(): DOMMatrix;
847
+ view(): View2D;
848
+ /**
849
+ * Add the given node(s) as the children of this node.
850
+ *
851
+ * @remarks
852
+ * The nodes will be appended at the end of the children list.
853
+ *
854
+ * @example
855
+ * ```tsx
856
+ * const node = <Layout />;
857
+ * node.add(<Rect />);
858
+ * node.add(<Circle />);
859
+ * ```
860
+ * Result:
861
+ * ```mermaid
862
+ * graph TD;
863
+ * layout([Layout])
864
+ * circle([Circle])
865
+ * rect([Rect])
866
+ * layout-->rect;
867
+ * layout-->circle;
868
+ * ```
869
+ *
870
+ * @param node - A node or an array of nodes to append.
871
+ */
872
+ add(node: ComponentChildren): this;
873
+ /**
874
+ * Insert the given node(s) at the specified index in the children list.
875
+ *
876
+ * @example
877
+ * ```tsx
878
+ * const node = (
879
+ * <Layout>
880
+ * <Rect />
881
+ * <Circle />
882
+ * </Layout>
883
+ * );
884
+ *
885
+ * node.insert(<Txt />, 1);
886
+ * ```
887
+ *
888
+ * Result:
889
+ * ```mermaid
890
+ * graph TD;
891
+ * layout([Layout])
892
+ * circle([Circle])
893
+ * text([Text])
894
+ * rect([Rect])
895
+ * layout-->rect;
896
+ * layout-->text;
897
+ * layout-->circle;
898
+ * ```
899
+ *
900
+ * @param node - A node or an array of nodes to insert.
901
+ * @param index - An index at which to insert the node(s).
902
+ */
903
+ insert(node: ComponentChildren, index?: number): this;
904
+ /**
905
+ * Remove this node from the tree.
906
+ */
907
+ remove(): this;
908
+ /**
909
+ * Rearrange this node in relation to its siblings.
910
+ *
911
+ * @remarks
912
+ * Children are rendered starting from the beginning of the children list.
913
+ * We can change the rendering order by rearranging said list.
914
+ *
915
+ * A positive `by` arguments move the node up (it will be rendered on top of
916
+ * the elements it has passed). Negative values move it down.
917
+ *
918
+ * @param by - Number of places by which the node should be moved.
919
+ */
920
+ move(by?: number): this;
921
+ /**
922
+ * Move the node up in relation to its siblings.
923
+ *
924
+ * @remarks
925
+ * The node will exchange places with the sibling right above it (if any) and
926
+ * from then on will be rendered on top of it.
927
+ */
928
+ moveUp(): this;
929
+ /**
930
+ * Move the node down in relation to its siblings.
931
+ *
932
+ * @remarks
933
+ * The node will exchange places with the sibling right below it (if any) and
934
+ * from then on will be rendered under it.
935
+ */
936
+ moveDown(): this;
937
+ /**
938
+ * Move the node to the top in relation to its siblings.
939
+ *
940
+ * @remarks
941
+ * The node will be placed at the end of the children list and from then on
942
+ * will be rendered on top of all of its siblings.
943
+ */
944
+ moveToTop(): this;
945
+ /**
946
+ * Move the node to the bottom in relation to its siblings.
947
+ *
948
+ * @remarks
949
+ * The node will be placed at the beginning of the children list and from then
950
+ * on will be rendered below all of its siblings.
951
+ */
952
+ moveToBottom(): this;
953
+ /**
954
+ * Move the node to the provided position relative to its siblings.
955
+ *
956
+ * @remarks
957
+ * If the node is getting moved to a lower position, it will be placed below
958
+ * the sibling that's currently at the provided index (if any).
959
+ * If the node is getting moved to a higher position, it will be placed above
960
+ * the sibling that's currently at the provided index (if any).
961
+ *
962
+ * @param index - The index to move the node to.
963
+ */
964
+ moveTo(index: number): this;
965
+ /**
966
+ * Move the node below the provided node in the parent's layout.
967
+ *
968
+ * @remarks
969
+ * The node will be moved below the provided node and from then on will be
970
+ * rendered below it. By default, if the node is already positioned lower than
971
+ * the sibling node, it will not get moved.
972
+ *
973
+ * @param node - The sibling node below which to move.
974
+ * @param directlyBelow - Whether the node should be positioned directly below
975
+ * the sibling. When true, will move the node even if
976
+ * it is already positioned below the sibling.
977
+ */
978
+ moveBelow(node: Node, directlyBelow?: boolean): this;
979
+ /**
980
+ * Move the node above the provided node in the parent's layout.
981
+ *
982
+ * @remarks
983
+ * The node will be moved above the provided node and from then on will be
984
+ * rendered on top of it. By default, if the node is already positioned
985
+ * higher than the sibling node, it will not get moved.
986
+ *
987
+ * @param node - The sibling node below which to move.
988
+ * @param directlyAbove - Whether the node should be positioned directly above the
989
+ * sibling. When true, will move the node even if it is
990
+ * already positioned above the sibling.
991
+ */
992
+ moveAbove(node: Node, directlyAbove?: boolean): this;
993
+ /**
994
+ * Change the parent of this node while keeping the absolute transform.
995
+ *
996
+ * @remarks
997
+ * After performing this operation, the node will stay in the same place
998
+ * visually, but its parent will be changed.
999
+ *
1000
+ * @param newParent - The new parent of this node.
1001
+ */
1002
+ reparent(newParent: Node): void;
1003
+ /**
1004
+ * Remove all children of this node.
1005
+ */
1006
+ removeChildren(): void;
1007
+ /**
1008
+ * Get the current children of this node.
1009
+ *
1010
+ * @remarks
1011
+ * Unlike {@link children}, this method does not have any side effects.
1012
+ * It does not register the `children` signal as a dependency, and it does not
1013
+ * spawn any children. It can be used to safely retrieve the current state of
1014
+ * the scene graph for debugging purposes.
1015
+ */
1016
+ peekChildren(): readonly Node[];
1017
+ /**
1018
+ * Find all descendants of this node that match the given predicate.
1019
+ *
1020
+ * @param predicate - A function that returns true if the node matches.
1021
+ */
1022
+ findAll<T extends Node>(predicate: (node: any) => node is T): T[];
1023
+ /**
1024
+ * Find all descendants of this node that match the given predicate.
1025
+ *
1026
+ * @param predicate - A function that returns true if the node matches.
1027
+ */
1028
+ findAll<T extends Node = Node>(predicate: (node: any) => boolean): T[];
1029
+ /**
1030
+ * Find the first descendant of this node that matches the given predicate.
1031
+ *
1032
+ * @param predicate - A function that returns true if the node matches.
1033
+ */
1034
+ findFirst<T extends Node>(predicate: (node: Node) => node is T): T | null;
1035
+ /**
1036
+ * Find the first descendant of this node that matches the given predicate.
1037
+ *
1038
+ * @param predicate - A function that returns true if the node matches.
1039
+ */
1040
+ findFirst<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
1041
+ /**
1042
+ * Find the last descendant of this node that matches the given predicate.
1043
+ *
1044
+ * @param predicate - A function that returns true if the node matches.
1045
+ */
1046
+ findLast<T extends Node>(predicate: (node: Node) => node is T): T | null;
1047
+ /**
1048
+ * Find the last descendant of this node that matches the given predicate.
1049
+ *
1050
+ * @param predicate - A function that returns true if the node matches.
1051
+ */
1052
+ findLast<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
1053
+ /**
1054
+ * Find the closest ancestor of this node that matches the given predicate.
1055
+ *
1056
+ * @param predicate - A function that returns true if the node matches.
1057
+ */
1058
+ findAncestor<T extends Node>(predicate: (node: Node) => node is T): T | null;
1059
+ /**
1060
+ * Find the closest ancestor of this node that matches the given predicate.
1061
+ *
1062
+ * @param predicate - A function that returns true if the node matches.
1063
+ */
1064
+ findAncestor<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
1065
+ /**
1066
+ * Get the nth children cast to the specified type.
1067
+ *
1068
+ * @param index - The index of the child to retrieve.
1069
+ */
1070
+ childAs<T extends Node = Node>(index: number): T | null;
1071
+ /**
1072
+ * Get the children array cast to the specified type.
1073
+ */
1074
+ childrenAs<T extends Node = Node>(): T[];
1075
+ /**
1076
+ * Get the parent cast to the specified type.
1077
+ */
1078
+ parentAs<T extends Node = Node>(): T | null;
1079
+ /**
1080
+ * Prepare this node to be disposed of.
1081
+ *
1082
+ * @remarks
1083
+ * This method is called automatically when a scene is refreshed. It will
1084
+ * be called even if the node is not currently attached to the tree.
1085
+ *
1086
+ * The goal of this method is to clean any external references to allow the
1087
+ * node to be garbage collected.
1088
+ */
1089
+ dispose(): void;
1090
+ /**
1091
+ * Create a copy of this node.
1092
+ *
1093
+ * @param customProps - Properties to override.
1094
+ */
1095
+ clone(customProps?: NodeState): this;
1096
+ /**
1097
+ * Create a copy of this node.
1098
+ *
1099
+ * @remarks
1100
+ * Unlike {@link clone}, a snapshot clone calculates any reactive properties
1101
+ * at the moment of cloning and passes the raw values to the copy.
1102
+ *
1103
+ * @param customProps - Properties to override.
1104
+ */
1105
+ snapshotClone(customProps?: NodeState): this;
1106
+ /**
1107
+ * Create a reactive copy of this node.
1108
+ *
1109
+ * @remarks
1110
+ * A reactive copy has all its properties dynamically updated to match the
1111
+ * source node.
1112
+ *
1113
+ * @param customProps - Properties to override.
1114
+ */
1115
+ reactiveClone(customProps?: NodeState): this;
1116
+ /**
1117
+ * Create an instance of this node's class.
1118
+ *
1119
+ * @param props - Properties to pass to the constructor.
1120
+ */
1121
+ instantiate(props?: NodeProps): this;
1122
+ /**
1123
+ * Set the children without parsing them.
1124
+ *
1125
+ * @remarks
1126
+ * This method assumes that the caller took care of parsing the children and
1127
+ * updating the hierarchy.
1128
+ *
1129
+ * @param value - The children to set.
1130
+ */
1131
+ protected setParsedChildren(value: Node[]): void;
1132
+ protected spawnChildren(reactive: boolean, children: ComponentChildren): void;
1133
+ /**
1134
+ * Parse any `ComponentChildren` into an array of nodes.
1135
+ *
1136
+ * @param children - The children to parse.
1137
+ */
1138
+ protected parseChildren(children: ComponentChildren): Node[];
1139
+ /**
1140
+ * Remove the given child.
1141
+ */
1142
+ protected removeChild(child: Node): void;
1143
+ /**
1144
+ * Whether this node should be cached or not.
1145
+ */
1146
+ protected requiresCache(): boolean;
1147
+ protected cacheCanvas(): CanvasRenderingContext2D;
1148
+ /**
1149
+ * Get a cache canvas with the contents of this node rendered onto it.
1150
+ */
1151
+ protected cachedCanvas(): Promise<CanvasRenderingContext2D>;
1152
+ /**
1153
+ * Get a bounding box for the contents rendered by this node.
1154
+ *
1155
+ * @remarks
1156
+ * The returned bounding box should be in local space.
1157
+ */
1158
+ protected getCacheBBox(): BBox;
1159
+ /**
1160
+ * Get a bounding box for the contents rendered by this node as well
1161
+ * as its children.
1162
+ */
1163
+ cacheBBox(): BBox;
1164
+ /**
1165
+ * Get a bounding box for the contents rendered by this node (including
1166
+ * effects applied after caching).
1167
+ *
1168
+ * @remarks
1169
+ * The returned bounding box should be in local space.
1170
+ */
1171
+ protected fullCacheBBox(): BBox;
1172
+ /**
1173
+ * Get a bounding box in world space for the contents rendered by this node as
1174
+ * well as its children.
1175
+ *
1176
+ * @remarks
1177
+ * This is the same the bounding box returned by {@link cacheBBox} only
1178
+ * transformed to world space.
1179
+ */
1180
+ protected worldSpaceCacheBBox(): BBox;
1181
+ protected parentWorldSpaceCacheBBox(): BBox;
1182
+ /**
1183
+ * Prepare the given context for drawing a cached node onto it.
1184
+ *
1185
+ * @remarks
1186
+ * This method is called before the contents of the cache canvas are drawn
1187
+ * on the screen. It can be used to apply effects to the entire node together
1188
+ * with its children, instead of applying them individually.
1189
+ * Effects such as transparency, shadows, and filters use this technique.
1190
+ *
1191
+ * Whether the node is cached is decided by the {@link requiresCache} method.
1192
+ *
1193
+ * @param context - The context using which the cache will be drawn.
1194
+ */
1195
+ protected setupDrawFromCache(context: CanvasRenderingContext2D): void;
1196
+ protected renderFromSource(context: CanvasRenderingContext2D, source: CanvasImageSource, x: number, y: number): void;
1197
+ private shaderCanvas;
1198
+ /**
1199
+ * Render this node onto the given canvas.
1200
+ *
1201
+ * @param context - The context to draw with.
1202
+ */
1203
+ render(context: CanvasRenderingContext2D): Promise<void>;
1204
+ /**
1205
+ * Draw this node onto the canvas.
1206
+ *
1207
+ * @remarks
1208
+ * This method is used when drawing directly onto the screen as well as onto
1209
+ * the cache canvas.
1210
+ * It assumes that the context have already been transformed to local space.
1211
+ *
1212
+ * @param context - The context to draw with.
1213
+ */
1214
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
1215
+ protected drawChildren(context: CanvasRenderingContext2D): Promise<void>;
1216
+ /**
1217
+ * Draw an overlay for this node.
1218
+ *
1219
+ * @remarks
1220
+ * The overlay for the currently inspected node is displayed on top of the
1221
+ * canvas.
1222
+ *
1223
+ * The provided context is in screen space. The local-to-screen matrix can be
1224
+ * used to transform all shapes that need to be displayed.
1225
+ * This approach allows to keep the line widths and gizmo sizes consistent,
1226
+ * no matter how zoomed-in the view is.
1227
+ *
1228
+ * @param context - The context to draw with.
1229
+ * @param matrix - A local-to-screen matrix.
1230
+ */
1231
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
1232
+ protected transformContext(context: CanvasRenderingContext2D): void;
1233
+ /**
1234
+ * Try to find a node intersecting the given position.
1235
+ *
1236
+ * @param position - The searched position.
1237
+ */
1238
+ hit(position: Vector2): Node | null;
1239
+ /**
1240
+ * Collect all asynchronous resources used by this node.
1241
+ */
1242
+ protected collectAsyncResources(): void;
1243
+ /**
1244
+ * Wait for any asynchronous resources that this node or its children have.
1245
+ *
1246
+ * @remarks
1247
+ * Certain resources like images are always loaded asynchronously.
1248
+ * Awaiting this method makes sure that all such resources are done loading
1249
+ * before continuing the animation.
1250
+ */
1251
+ toPromise(): Promise<this>;
1252
+ /**
1253
+ * Return a snapshot of the node's current signal values.
1254
+ *
1255
+ * @remarks
1256
+ * This method will calculate the values of any reactive properties of the
1257
+ * node at the time the method is called.
1258
+ */
1259
+ getState(): NodeState;
1260
+ /**
1261
+ * Apply the given state to the node, setting all matching signal values to
1262
+ * the provided values.
1263
+ *
1264
+ * @param state - The state to apply to the node.
1265
+ */
1266
+ applyState(state: NodeState): void;
1267
+ /**
1268
+ * Smoothly transition between the current state of the node and the given
1269
+ * state.
1270
+ *
1271
+ * @param state - The state to transition to.
1272
+ * @param duration - The duration of the transition.
1273
+ * @param timing - The timing function to use for the transition.
1274
+ */
1275
+ applyState(state: NodeState, duration: number, timing?: TimingFunction): ThreadGenerator;
1276
+ /**
1277
+ * Push a snapshot of the node's current state onto the node's state stack.
1278
+ *
1279
+ * @remarks
1280
+ * This method can be used together with the {@link restore} method to save a
1281
+ * node's current state and later restore it. It is possible to store more
1282
+ * than one state by calling `save` method multiple times.
1283
+ */
1284
+ save(): void;
1285
+ /**
1286
+ * Restore the node to its last saved state.
1287
+ *
1288
+ * @remarks
1289
+ * This method can be used together with the {@link save} method to restore a
1290
+ * node to a previously saved state. Restoring a node to a previous state
1291
+ * removes that state from the state stack.
1292
+ *
1293
+ * @example
1294
+ * ```tsx
1295
+ * const node = <Circle width={100} height={100} fill={"lightseagreen"} />
1296
+ *
1297
+ * view.add(node);
1298
+ *
1299
+ * // Save the node's current state
1300
+ * node.save();
1301
+ *
1302
+ * // Modify some of the node's properties
1303
+ * yield* node.scale(2, 1);
1304
+ * yield* node.fill('hotpink', 1);
1305
+ *
1306
+ * // Restore the node to its saved state
1307
+ * node.restore();
1308
+ * ```
1309
+ */
1310
+ restore(): void;
1311
+ /**
1312
+ * Tween the node to its last saved state.
1313
+ *
1314
+ * @remarks
1315
+ * This method can be used together with the {@link save} method to restore a
1316
+ * node to a previously saved state. Restoring a node to a previous state
1317
+ * removes that state from the state stack.
1318
+ *
1319
+ * @example
1320
+ * ```tsx
1321
+ * const node = <Circle width={100} height={100} fill={"lightseagreen"} />
1322
+ *
1323
+ * view.add(node);
1324
+ *
1325
+ * // Save the node's current state
1326
+ * node.save();
1327
+ *
1328
+ * // Modify some of the node's properties
1329
+ * yield* node.scale(2, 1);
1330
+ * yield* node.fill('hotpink', 1);
1331
+ *
1332
+ * // Tween the node to its saved state over 1 second
1333
+ * yield* node.restore(1);
1334
+ * ```
1335
+ *
1336
+ * @param duration - The duration of the transition.
1337
+ * @param timing - The timing function to use for the transition.
1338
+ */
1339
+ restore(duration: number, timing?: TimingFunction): ThreadGenerator;
1340
+ [Symbol.iterator](): Generator<{
1341
+ meta: PropertyMetadata<any>;
1342
+ signal: SimpleSignal<any>;
1343
+ key: string;
1344
+ }, void, unknown>;
1345
+ private signalByKey;
1346
+ private reversedChildren;
1347
+ }
1348
+
1349
+ interface LayoutProps extends NodeProps {
1350
+ layout?: LayoutMode;
1351
+ tagName?: keyof HTMLElementTagNameMap;
1352
+ width?: SignalValue<Length>;
1353
+ height?: SignalValue<Length>;
1354
+ maxWidth?: SignalValue<LengthLimit>;
1355
+ maxHeight?: SignalValue<LengthLimit>;
1356
+ minWidth?: SignalValue<LengthLimit>;
1357
+ minHeight?: SignalValue<LengthLimit>;
1358
+ ratio?: SignalValue<number>;
1359
+ marginTop?: SignalValue<number>;
1360
+ marginBottom?: SignalValue<number>;
1361
+ marginLeft?: SignalValue<number>;
1362
+ marginRight?: SignalValue<number>;
1363
+ margin?: SignalValue<PossibleSpacing>;
1364
+ paddingTop?: SignalValue<number>;
1365
+ paddingBottom?: SignalValue<number>;
1366
+ paddingLeft?: SignalValue<number>;
1367
+ paddingRight?: SignalValue<number>;
1368
+ padding?: SignalValue<PossibleSpacing>;
1369
+ direction?: SignalValue<FlexDirection>;
1370
+ basis?: SignalValue<FlexBasis>;
1371
+ grow?: SignalValue<number>;
1372
+ shrink?: SignalValue<number>;
1373
+ wrap?: SignalValue<FlexWrap>;
1374
+ justifyContent?: SignalValue<FlexContent>;
1375
+ alignContent?: SignalValue<FlexContent>;
1376
+ alignItems?: SignalValue<FlexItems>;
1377
+ alignSelf?: SignalValue<FlexItems>;
1378
+ rowGap?: SignalValue<Length>;
1379
+ columnGap?: SignalValue<Length>;
1380
+ gap?: SignalValue<Length>;
1381
+ fontFamily?: SignalValue<string>;
1382
+ fontSize?: SignalValue<number>;
1383
+ fontStyle?: SignalValue<string>;
1384
+ fontWeight?: SignalValue<number>;
1385
+ lineHeight?: SignalValue<Length>;
1386
+ letterSpacing?: SignalValue<number>;
1387
+ textWrap?: SignalValue<TextWrap>;
1388
+ textDirection?: SignalValue<CanvasDirection>;
1389
+ textAlign?: SignalValue<CanvasTextAlign>;
1390
+ size?: SignalValue<PossibleVector2<Length>>;
1391
+ offsetX?: SignalValue<number>;
1392
+ offsetY?: SignalValue<number>;
1393
+ offset?: SignalValue<PossibleVector2>;
1394
+ /**
1395
+ * The position of the center of this node.
1396
+ *
1397
+ * @remarks
1398
+ * This shortcut property will set the node's position so that the center ends
1399
+ * up in the given place.
1400
+ * If present, overrides the {@link NodeProps.position} property.
1401
+ * When {@link offset} is not set, this will be the same as the
1402
+ * {@link NodeProps.position}.
1403
+ */
1404
+ middle?: SignalValue<PossibleVector2>;
1405
+ /**
1406
+ * The position of the top edge of this node.
1407
+ *
1408
+ * @remarks
1409
+ * This shortcut property will set the node's position so that the top edge
1410
+ * ends up in the given place.
1411
+ * If present, overrides the {@link NodeProps.position} property.
1412
+ */
1413
+ top?: SignalValue<PossibleVector2>;
1414
+ /**
1415
+ * The position of the bottom edge of this node.
1416
+ *
1417
+ * @remarks
1418
+ * This shortcut property will set the node's position so that the bottom edge
1419
+ * ends up in the given place.
1420
+ * If present, overrides the {@link NodeProps.position} property.
1421
+ */
1422
+ bottom?: SignalValue<PossibleVector2>;
1423
+ /**
1424
+ * The position of the left edge of this node.
1425
+ *
1426
+ * @remarks
1427
+ * This shortcut property will set the node's position so that the left edge
1428
+ * ends up in the given place.
1429
+ * If present, overrides the {@link NodeProps.position} property.
1430
+ */
1431
+ left?: SignalValue<PossibleVector2>;
1432
+ /**
1433
+ * The position of the right edge of this node.
1434
+ *
1435
+ * @remarks
1436
+ * This shortcut property will set the node's position so that the right edge
1437
+ * ends up in the given place.
1438
+ * If present, overrides the {@link NodeProps.position} property.
1439
+ */
1440
+ right?: SignalValue<PossibleVector2>;
1441
+ /**
1442
+ * The position of the top left corner of this node.
1443
+ *
1444
+ * @remarks
1445
+ * This shortcut property will set the node's position so that the top left
1446
+ * corner ends up in the given place.
1447
+ * If present, overrides the {@link NodeProps.position} property.
1448
+ */
1449
+ topLeft?: SignalValue<PossibleVector2>;
1450
+ /**
1451
+ * The position of the top right corner of this node.
1452
+ *
1453
+ * @remarks
1454
+ * This shortcut property will set the node's position so that the top right
1455
+ * corner ends up in the given place.
1456
+ * If present, overrides the {@link NodeProps.position} property.
1457
+ */
1458
+ topRight?: SignalValue<PossibleVector2>;
1459
+ /**
1460
+ * The position of the bottom left corner of this node.
1461
+ *
1462
+ * @remarks
1463
+ * This shortcut property will set the node's position so that the bottom left
1464
+ * corner ends up in the given place.
1465
+ * If present, overrides the {@link NodeProps.position} property.
1466
+ */
1467
+ bottomLeft?: SignalValue<PossibleVector2>;
1468
+ /**
1469
+ * The position of the bottom right corner of this node.
1470
+ *
1471
+ * @remarks
1472
+ * This shortcut property will set the node's position so that the bottom
1473
+ * right corner ends up in the given place.
1474
+ * If present, overrides the {@link NodeProps.position} property.
1475
+ */
1476
+ bottomRight?: SignalValue<PossibleVector2>;
1477
+ clip?: SignalValue<boolean>;
1478
+ }
1479
+ declare class Layout extends Node {
1480
+ readonly layout: SimpleSignal<LayoutMode, this>;
1481
+ readonly maxWidth: SimpleSignal<LengthLimit, this>;
1482
+ readonly maxHeight: SimpleSignal<LengthLimit, this>;
1483
+ readonly minWidth: SimpleSignal<LengthLimit, this>;
1484
+ readonly minHeight: SimpleSignal<LengthLimit, this>;
1485
+ readonly ratio: SimpleSignal<number | null, this>;
1486
+ readonly margin: SpacingSignal<this>;
1487
+ readonly padding: SpacingSignal<this>;
1488
+ readonly direction: SimpleSignal<FlexDirection, this>;
1489
+ readonly basis: SimpleSignal<FlexBasis, this>;
1490
+ readonly grow: SimpleSignal<number, this>;
1491
+ readonly shrink: SimpleSignal<number, this>;
1492
+ readonly wrap: SimpleSignal<FlexWrap, this>;
1493
+ readonly justifyContent: SimpleSignal<FlexContent, this>;
1494
+ readonly alignContent: SimpleSignal<FlexContent, this>;
1495
+ readonly alignItems: SimpleSignal<FlexItems, this>;
1496
+ readonly alignSelf: SimpleSignal<FlexItems, this>;
1497
+ readonly gap: Vector2LengthSignal<this>;
1498
+ get columnGap(): Signal<Length, number, this>;
1499
+ get rowGap(): Signal<Length, number, this>;
1500
+ readonly fontFamily: SimpleSignal<string, this>;
1501
+ readonly fontSize: SimpleSignal<number, this>;
1502
+ readonly fontStyle: SimpleSignal<string, this>;
1503
+ readonly fontWeight: SimpleSignal<number, this>;
1504
+ readonly lineHeight: SimpleSignal<Length, this>;
1505
+ readonly letterSpacing: SimpleSignal<number, this>;
1506
+ readonly textWrap: SimpleSignal<TextWrap, this>;
1507
+ readonly textDirection: SimpleSignal<CanvasDirection, this>;
1508
+ readonly textAlign: SimpleSignal<CanvasTextAlign, this>;
1509
+ protected getX(): number;
1510
+ protected setX(value: SignalValue<number>): void;
1511
+ protected getY(): number;
1512
+ protected setY(value: SignalValue<number>): void;
1513
+ /**
1514
+ * Represents the size of this node.
1515
+ *
1516
+ * @remarks
1517
+ * A size is a two-dimensional vector, where `x` represents the `width`, and `y`
1518
+ * represents the `height`.
1519
+ *
1520
+ * The value of both x and y is of type {@link partials.Length} which is
1521
+ * either:
1522
+ * - `number` - the desired length in pixels
1523
+ * - `${number}%` - a string with the desired length in percents, for example
1524
+ * `'50%'`
1525
+ * - `null` - an automatic length
1526
+ *
1527
+ * When retrieving the size, all units are converted to pixels, using the
1528
+ * current state of the layout. For example, retrieving the width set to
1529
+ * `'50%'`, while the parent has a width of `200px` will result in the number
1530
+ * `100` being returned.
1531
+ *
1532
+ * When the node is not part of the layout, setting its size using percents
1533
+ * refers to the size of the entire scene.
1534
+ *
1535
+ * @example
1536
+ * Initializing the size:
1537
+ * ```tsx
1538
+ * // with a possible vector:
1539
+ * <Node size={['50%', 200]} />
1540
+ * // with individual components:
1541
+ * <Node width={'50%'} height={200} />
1542
+ * ```
1543
+ *
1544
+ * Accessing the size:
1545
+ * ```tsx
1546
+ * // retrieving the vector:
1547
+ * const size = node.size();
1548
+ * // retrieving an individual component:
1549
+ * const width = node.size.x();
1550
+ * ```
1551
+ *
1552
+ * Setting the size:
1553
+ * ```tsx
1554
+ * // with a possible vector:
1555
+ * node.size(['50%', 200]);
1556
+ * node.size(() => ['50%', 200]);
1557
+ * // with individual components:
1558
+ * node.size.x('50%');
1559
+ * node.size.x(() => '50%');
1560
+ * ```
1561
+ */
1562
+ readonly size: Vector2LengthSignal<this>;
1563
+ get width(): Signal<Length, number, this>;
1564
+ get height(): Signal<Length, number, this>;
1565
+ protected getWidth(): number;
1566
+ protected setWidth(value: SignalValue<Length>): void;
1567
+ protected tweenWidth(value: SignalValue<Length>, time: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<Length>): ThreadGenerator;
1568
+ protected getHeight(): number;
1569
+ protected setHeight(value: SignalValue<Length>): void;
1570
+ protected tweenHeight(value: SignalValue<Length>, time: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<Length>): ThreadGenerator;
1571
+ /**
1572
+ * Get the desired size of this node.
1573
+ *
1574
+ * @remarks
1575
+ * This method can be used to control the size using external factors.
1576
+ * By default, the returned size is the same as the one declared by the user.
1577
+ */
1578
+ protected desiredSize(): SerializedVector2<DesiredLength>;
1579
+ protected tweenSize(value: SignalValue<SerializedVector2<Length>>, time: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<Vector2>): ThreadGenerator;
1580
+ /**
1581
+ * Represents the offset of this node's origin.
1582
+ *
1583
+ * @remarks
1584
+ * By default, the origin of a node is located at its center. The origin
1585
+ * serves as the pivot point when rotating and scaling a node, but it doesn't
1586
+ * affect the placement of its children.
1587
+ *
1588
+ * The value is relative to the size of this node. A value of `1` means as far
1589
+ * to the right/bottom as possible. Here are a few examples of offsets:
1590
+ * - `[-1, -1]` - top left corner
1591
+ * - `[1, -1]` - top right corner
1592
+ * - `[0, 1]` - bottom edge
1593
+ * - `[-1, 1]` - bottom left corner
1594
+ */
1595
+ readonly offset: Vector2Signal<this>;
1596
+ /**
1597
+ * The position of the center of this node.
1598
+ *
1599
+ * @remarks
1600
+ * When set, this shortcut property will modify the node's position so that
1601
+ * the center ends up in the given place.
1602
+ *
1603
+ * If the {@link offset} has not been changed, this will be the same as the
1604
+ * {@link position}.
1605
+ *
1606
+ * When retrieved, it will return the position of the center in the parent
1607
+ * space.
1608
+ */
1609
+ readonly middle: SimpleVector2Signal<this>;
1610
+ /**
1611
+ * The position of the top edge of this node.
1612
+ *
1613
+ * @remarks
1614
+ * When set, this shortcut property will modify the node's position so that
1615
+ * the top edge ends up in the given place.
1616
+ *
1617
+ * When retrieved, it will return the position of the top edge in the parent
1618
+ * space.
1619
+ */
1620
+ readonly top: SimpleVector2Signal<this>;
1621
+ /**
1622
+ * The position of the bottom edge of this node.
1623
+ *
1624
+ * @remarks
1625
+ * When set, this shortcut property will modify the node's position so that
1626
+ * the bottom edge ends up in the given place.
1627
+ *
1628
+ * When retrieved, it will return the position of the bottom edge in the
1629
+ * parent space.
1630
+ */
1631
+ readonly bottom: SimpleVector2Signal<this>;
1632
+ /**
1633
+ * The position of the left edge of this node.
1634
+ *
1635
+ * @remarks
1636
+ * When set, this shortcut property will modify the node's position so that
1637
+ * the left edge ends up in the given place.
1638
+ *
1639
+ * When retrieved, it will return the position of the left edge in the parent
1640
+ * space.
1641
+ */
1642
+ readonly left: SimpleVector2Signal<this>;
1643
+ /**
1644
+ * The position of the right edge of this node.
1645
+ *
1646
+ * @remarks
1647
+ * When set, this shortcut property will modify the node's position so that
1648
+ * the right edge ends up in the given place.
1649
+ *
1650
+ * When retrieved, it will return the position of the right edge in the parent
1651
+ * space.
1652
+ */
1653
+ readonly right: SimpleVector2Signal<this>;
1654
+ /**
1655
+ * The position of the top left corner of this node.
1656
+ *
1657
+ * @remarks
1658
+ * When set, this shortcut property will modify the node's position so that
1659
+ * the top left corner ends up in the given place.
1660
+ *
1661
+ * When retrieved, it will return the position of the top left corner in the
1662
+ * parent space.
1663
+ */
1664
+ readonly topLeft: SimpleVector2Signal<this>;
1665
+ /**
1666
+ * The position of the top right corner of this node.
1667
+ *
1668
+ * @remarks
1669
+ * When set, this shortcut property will modify the node's position so that
1670
+ * the top right corner ends up in the given place.
1671
+ *
1672
+ * When retrieved, it will return the position of the top right corner in the
1673
+ * parent space.
1674
+ */
1675
+ readonly topRight: SimpleVector2Signal<this>;
1676
+ /**
1677
+ * The position of the bottom left corner of this node.
1678
+ *
1679
+ * @remarks
1680
+ * When set, this shortcut property will modify the node's position so that
1681
+ * the bottom left corner ends up in the given place.
1682
+ *
1683
+ * When retrieved, it will return the position of the bottom left corner in
1684
+ * the parent space.
1685
+ */
1686
+ readonly bottomLeft: SimpleVector2Signal<this>;
1687
+ /**
1688
+ * The position of the bottom right corner of this node.
1689
+ *
1690
+ * @remarks
1691
+ * When set, this shortcut property will modify the node's position so that
1692
+ * the bottom right corner ends up in the given place.
1693
+ *
1694
+ * When retrieved, it will return the position of the bottom right corner in
1695
+ * the parent space.
1696
+ */
1697
+ readonly bottomRight: SimpleVector2Signal<this>;
1698
+ readonly clip: SimpleSignal<boolean, this>;
1699
+ element: HTMLElement;
1700
+ styles: CSSStyleDeclaration;
1701
+ protected readonly sizeLockCounter: SimpleSignal<number, this>;
1702
+ constructor(props: LayoutProps);
1703
+ lockSize(): void;
1704
+ releaseSize(): void;
1705
+ protected parentTransform(): Layout | null;
1706
+ anchorPosition(): Vector2;
1707
+ /**
1708
+ * Get the resolved layout mode of this node.
1709
+ *
1710
+ * @remarks
1711
+ * When the mode is `null`, its value will be inherited from the parent.
1712
+ *
1713
+ * Use {@link layout} to get the raw mode set for this node (without
1714
+ * inheritance).
1715
+ */
1716
+ layoutEnabled(): boolean;
1717
+ isLayoutRoot(): boolean;
1718
+ localToParent(): DOMMatrix;
1719
+ /**
1720
+ * A simplified version of {@link localToParent} matrix used for transforming
1721
+ * direction vectors.
1722
+ *
1723
+ * @internal
1724
+ */
1725
+ protected scalingRotationMatrix(): DOMMatrix;
1726
+ protected getComputedLayout(): BBox;
1727
+ computedPosition(): Vector2;
1728
+ protected computedSize(): Vector2;
1729
+ /**
1730
+ * Find the closest layout root and apply any new layout changes.
1731
+ */
1732
+ protected requestLayoutUpdate(): void;
1733
+ protected appendedToView(): boolean;
1734
+ /**
1735
+ * Apply any new layout changes to this node and its children.
1736
+ */
1737
+ protected updateLayout(): void;
1738
+ protected layoutChildren(): Layout[];
1739
+ /**
1740
+ * Apply any new font changes to this node and all of its ancestors.
1741
+ */
1742
+ protected requestFontUpdate(): void;
1743
+ protected getCacheBBox(): BBox;
1744
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
1745
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
1746
+ getOriginDelta(origin: Origin): Vector2;
1747
+ /**
1748
+ * Update the offset of this node and adjust the position to keep it in the
1749
+ * same place.
1750
+ *
1751
+ * @param offset - The new offset.
1752
+ */
1753
+ moveOffset(offset: Vector2): void;
1754
+ protected parsePixels(value: number | null): string;
1755
+ protected parseLength(value: number | string | null): string;
1756
+ protected applyFlex(): void;
1757
+ protected applyFont(): void;
1758
+ dispose(): void;
1759
+ hit(position: Vector2): Node | null;
1760
+ }
1761
+
1762
+ interface ShapeProps extends LayoutProps {
1763
+ fill?: SignalValue<PossibleCanvasStyle>;
1764
+ stroke?: SignalValue<PossibleCanvasStyle>;
1765
+ strokeFirst?: SignalValue<boolean>;
1766
+ lineWidth?: SignalValue<number>;
1767
+ lineJoin?: SignalValue<CanvasLineJoin>;
1768
+ lineCap?: SignalValue<CanvasLineCap>;
1769
+ lineDash?: SignalValue<number[]>;
1770
+ lineDashOffset?: SignalValue<number>;
1771
+ antialiased?: SignalValue<boolean>;
1772
+ }
1773
+ declare abstract class Shape extends Layout {
1774
+ readonly fill: CanvasStyleSignal<this>;
1775
+ readonly stroke: CanvasStyleSignal<this>;
1776
+ readonly strokeFirst: SimpleSignal<boolean, this>;
1777
+ readonly lineWidth: SimpleSignal<number, this>;
1778
+ readonly lineJoin: SimpleSignal<CanvasLineJoin, this>;
1779
+ readonly lineCap: SimpleSignal<CanvasLineCap, this>;
1780
+ readonly lineDash: SimpleSignal<number[], this>;
1781
+ readonly lineDashOffset: SimpleSignal<number, this>;
1782
+ readonly antialiased: SimpleSignal<boolean, this>;
1783
+ protected readonly rippleStrength: SimpleSignal<number, this>;
1784
+ protected rippleSize(): number;
1785
+ constructor(props: ShapeProps);
1786
+ protected applyText(context: CanvasRenderingContext2D): void;
1787
+ protected applyStyle(context: CanvasRenderingContext2D): void;
1788
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
1789
+ protected drawShape(context: CanvasRenderingContext2D): void;
1790
+ protected getCacheBBox(): BBox;
1791
+ protected getPath(): Path2D;
1792
+ protected getRipplePath(): Path2D;
1793
+ protected drawRipple(context: CanvasRenderingContext2D): void;
1794
+ ripple(duration?: number): Generator<void | _twick_core.ThreadGenerator | Promise<any> | _twick_core.Promisable<any>, void, any>;
1795
+ }
1796
+
1797
+ interface CurveProps extends ShapeProps {
1798
+ /**
1799
+ * {@inheritDoc Curve.closed}
1800
+ */
1801
+ closed?: SignalValue<boolean>;
1802
+ /**
1803
+ * {@inheritDoc Curve.start}
1804
+ */
1805
+ start?: SignalValue<number>;
1806
+ /**
1807
+ * {@inheritDoc Curve.startOffset}
1808
+ */
1809
+ startOffset?: SignalValue<number>;
1810
+ /**
1811
+ * {@inheritDoc Curve.startArrow}
1812
+ */
1813
+ startArrow?: SignalValue<boolean>;
1814
+ /**
1815
+ * {@inheritDoc Curve.end}
1816
+ */
1817
+ end?: SignalValue<number>;
1818
+ /**
1819
+ * {@inheritDoc Curve.endOffset}
1820
+ */
1821
+ endOffset?: SignalValue<number>;
1822
+ /**
1823
+ * {@inheritDoc Curve.endArrow}
1824
+ */
1825
+ endArrow?: SignalValue<boolean>;
1826
+ /**
1827
+ * {@inheritDoc Curve.arrowSize}
1828
+ */
1829
+ arrowSize?: SignalValue<number>;
1830
+ }
1831
+ declare abstract class Curve extends Shape {
1832
+ /**
1833
+ * Whether the curve should be closed.
1834
+ *
1835
+ * @remarks
1836
+ * Closed curves have their start and end points connected.
1837
+ */
1838
+ readonly closed: SimpleSignal<boolean, this>;
1839
+ /**
1840
+ * A percentage from the start before which the curve should be clipped.
1841
+ *
1842
+ * @remarks
1843
+ * The portion of the curve that comes before the given percentage will be
1844
+ * made invisible.
1845
+ *
1846
+ * This property is usefully for animating the curve appearing on the screen.
1847
+ * The value of `0` means the very start of the curve (accounting for the
1848
+ * {@link startOffset}) while `1` means the very end (accounting for the
1849
+ * {@link endOffset}).
1850
+ */
1851
+ readonly start: SimpleSignal<number, this>;
1852
+ /**
1853
+ * The offset in pixels from the start of the curve.
1854
+ *
1855
+ * @remarks
1856
+ * This property lets you specify where along the defined curve the actual
1857
+ * visible portion starts. For example, setting it to `20` will make the first
1858
+ * 20 pixels of the curve invisible.
1859
+ *
1860
+ * This property is useful for trimming the curve using a fixed distance.
1861
+ * If you want to animate the curve appearing on the screen, use {@link start}
1862
+ * instead.
1863
+ */
1864
+ readonly startOffset: SimpleSignal<number, this>;
1865
+ /**
1866
+ * Whether to display an arrow at the start of the visible curve.
1867
+ *
1868
+ * @remarks
1869
+ * Use {@link arrowSize} to control the size of the arrow.
1870
+ */
1871
+ readonly startArrow: SimpleSignal<boolean, this>;
1872
+ /**
1873
+ * A percentage from the start after which the curve should be clipped.
1874
+ *
1875
+ * @remarks
1876
+ * The portion of the curve that comes after the given percentage will be
1877
+ * made invisible.
1878
+ *
1879
+ * This property is usefully for animating the curve appearing on the screen.
1880
+ * The value of `0` means the very start of the curve (accounting for the
1881
+ * {@link startOffset}) while `1` means the very end (accounting for the
1882
+ * {@link endOffset}).
1883
+ */
1884
+ readonly end: SimpleSignal<number, this>;
1885
+ /**
1886
+ * The offset in pixels from the end of the curve.
1887
+ *
1888
+ * @remarks
1889
+ * This property lets you specify where along the defined curve the actual
1890
+ * visible portion ends. For example, setting it to `20` will make the last
1891
+ * 20 pixels of the curve invisible.
1892
+ *
1893
+ * This property is useful for trimming the curve using a fixed distance.
1894
+ * If you want to animate the curve appearing on the screen, use {@link end}
1895
+ * instead.
1896
+ */
1897
+ readonly endOffset: SimpleSignal<number, this>;
1898
+ /**
1899
+ * Whether to display an arrow at the end of the visible curve.
1900
+ *
1901
+ * @remarks
1902
+ * Use {@link arrowSize} to control the size of the arrow.
1903
+ */
1904
+ readonly endArrow: SimpleSignal<boolean, this>;
1905
+ /**
1906
+ * Controls the size of the end and start arrows.
1907
+ *
1908
+ * @remarks
1909
+ * To make the arrows visible make sure to enable {@link startArrow} and/or
1910
+ * {@link endArrow}.
1911
+ */
1912
+ readonly arrowSize: SimpleSignal<number, this>;
1913
+ protected canHaveSubpath: boolean;
1914
+ protected desiredSize(): SerializedVector2<DesiredLength>;
1915
+ constructor(props: CurveProps);
1916
+ protected abstract childrenBBox(): BBox;
1917
+ abstract profile(): CurveProfile;
1918
+ /**
1919
+ * Convert a percentage along the curve to a distance.
1920
+ *
1921
+ * @remarks
1922
+ * The returned distance is given in relation to the full curve, not
1923
+ * accounting for {@link startOffset} and {@link endOffset}.
1924
+ *
1925
+ * @param value - The percentage along the curve.
1926
+ */
1927
+ percentageToDistance(value: number): number;
1928
+ /**
1929
+ * Convert a distance along the curve to a percentage.
1930
+ *
1931
+ * @remarks
1932
+ * The distance should be given in relation to the full curve, not
1933
+ * accounting for {@link startOffset} and {@link endOffset}.
1934
+ *
1935
+ * @param value - The distance along the curve.
1936
+ */
1937
+ distanceToPercentage(value: number): number;
1938
+ /**
1939
+ * The base arc length of this curve.
1940
+ *
1941
+ * @remarks
1942
+ * This is the entire length of this curve, not accounting for
1943
+ * {@link startOffset | the offsets}.
1944
+ */
1945
+ baseArcLength(): number;
1946
+ /**
1947
+ * The offset arc length of this curve.
1948
+ *
1949
+ * @remarks
1950
+ * This is the length of the curve that accounts for
1951
+ * {@link startOffset | the offsets}.
1952
+ */
1953
+ offsetArcLength(): number;
1954
+ /**
1955
+ * The visible arc length of this curve.
1956
+ *
1957
+ * @remarks
1958
+ * This arc length accounts for both the offset and the {@link start} and
1959
+ * {@link end} properties.
1960
+ */
1961
+ arcLength(): number;
1962
+ /**
1963
+ * The percentage of the curve that's currently visible.
1964
+ *
1965
+ * @remarks
1966
+ * The returned value is the ratio between the visible length (as defined by
1967
+ * {@link start} and {@link end}) and the offset length of the curve.
1968
+ */
1969
+ completion(): number;
1970
+ protected processSubpath(_path: Path2D, _startPoint: Vector2 | null, _endPoint: Vector2 | null): void;
1971
+ protected curveDrawingInfo(): CurveDrawingInfo;
1972
+ protected getPointAtDistance(value: number): CurvePoint;
1973
+ getPointAtPercentage(value: number): CurvePoint;
1974
+ protected getComputedLayout(): BBox;
1975
+ protected offsetComputedLayout(box: BBox): BBox;
1976
+ protected getPath(): Path2D;
1977
+ protected getCacheBBox(): BBox;
1978
+ protected lineWidthCoefficient(): number;
1979
+ /**
1980
+ * Check if the path requires a profile.
1981
+ *
1982
+ * @remarks
1983
+ * The profile is only required if certain features are used. Otherwise, the
1984
+ * profile generation can be skipped, and the curve can be drawn directly
1985
+ * using the 2D context.
1986
+ */
1987
+ protected requiresProfile(): boolean;
1988
+ protected drawShape(context: CanvasRenderingContext2D): void;
1989
+ private drawArrows;
1990
+ private drawArrow;
1991
+ }
1992
+
1993
+ interface RectProps extends CurveProps {
1994
+ /**
1995
+ * {@inheritDoc Rect.radius}
1996
+ */
1997
+ radius?: SignalValue<PossibleSpacing>;
1998
+ /**
1999
+ * {@inheritDoc Rect.smoothCorners}
2000
+ */
2001
+ smoothCorners?: SignalValue<boolean>;
2002
+ /**
2003
+ * {@inheritDoc Rect.cornerSharpness}
2004
+ */
2005
+ cornerSharpness?: SignalValue<number>;
2006
+ }
2007
+ declare class Rect extends Curve {
2008
+ /**
2009
+ * Rounds the corners of this rectangle.
2010
+ *
2011
+ * @remarks
2012
+ * The value represents the radius of the quarter circle that is used to round
2013
+ * the corners. If the value is a number, the same radius is used for all
2014
+ * corners. Passing an array of two to four numbers will set individual radii
2015
+ * for each corner. Individual radii correspond to different corners depending
2016
+ * on the number of values passed:
2017
+ *
2018
+ * ```ts
2019
+ * // top-left-and-bottom-right | top-right-and-bottom-left
2020
+ * [10, 30]
2021
+ * // top-left | top-right-and-bottom-left | bottom-right
2022
+ * [10, 20, 30]
2023
+ * // top-left | top-right | bottom-right | bottom-left
2024
+ * [10, 20, 30, 40]
2025
+ * ```
2026
+ *
2027
+ * @example
2028
+ * One uniform radius:
2029
+ * ```tsx
2030
+ * <Rect
2031
+ * size={320}
2032
+ * radius={40}
2033
+ * fill={'white'}
2034
+ * />
2035
+ * ```
2036
+ * @example
2037
+ * Individual radii for each corner:
2038
+ * ```tsx
2039
+ * <Rect
2040
+ * size={320}
2041
+ * radius={[10, 20, 30, 40]}
2042
+ * fill={'white'}
2043
+ * />
2044
+ * ```
2045
+ */
2046
+ readonly radius: SpacingSignal<this>;
2047
+ /**
2048
+ * Enables corner smoothing.
2049
+ *
2050
+ * @remarks
2051
+ * This property only affects the way rounded corners are drawn. To control
2052
+ * the corner radius use the {@link radius} property.
2053
+ *
2054
+ * When enabled, rounded corners are drawn continuously using Bézier curves
2055
+ * rather than quarter circles. The sharpness of the curve can be controlled
2056
+ * with {@link cornerSharpness}.
2057
+ *
2058
+ * You can read more about corner smoothing in
2059
+ * [this article by Nick Lawrence](https://uxplanet.org/ui-ux-design-corner-smoothing-720509d1ae48).
2060
+ *
2061
+ * @example
2062
+ * ```tsx
2063
+ * <Rect
2064
+ * width={300}
2065
+ * height={300}
2066
+ * smoothCorners={true}
2067
+ * />
2068
+ * ```
2069
+ */
2070
+ readonly smoothCorners: SimpleSignal<boolean, this>;
2071
+ /**
2072
+ * Controls the sharpness of {@link smoothCorners}.
2073
+ *
2074
+ * @remarks
2075
+ * This property only affects the way rounded corners are drawn. To control
2076
+ * the corner radius use the {@link radius} property.
2077
+ *
2078
+ * Requires {@link smoothCorners} to be enabled to have any effect.
2079
+ * By default, corner sharpness is set to `0.6` which represents a smooth,
2080
+ * circle-like rounding. At `0` the edges are squared off.
2081
+ *
2082
+ * @example
2083
+ * ```tsx
2084
+ * <Rect
2085
+ * size={300}
2086
+ * smoothCorners={true}
2087
+ * cornerSharpness={0.7}
2088
+ * />
2089
+ * ```
2090
+ */
2091
+ readonly cornerSharpness: SimpleSignal<number, this>;
2092
+ constructor(props: RectProps);
2093
+ profile(): CurveProfile;
2094
+ protected desiredSize(): SerializedVector2<DesiredLength>;
2095
+ protected offsetComputedLayout(box: BBox): BBox;
2096
+ protected childrenBBox(): BBox;
2097
+ protected getPath(): Path2D;
2098
+ protected getCacheBBox(): BBox;
2099
+ protected getRipplePath(): Path2D;
2100
+ }
2101
+
2102
+ declare namespace JSX {
2103
+ type Element = Node;
2104
+ type ElementClass = Node;
2105
+ interface ElementChildrenAttribute {
2106
+ children: any;
2107
+ }
2108
+ }
2109
+ declare const Fragment: FunctionComponent;
2110
+ declare function jsx(type: NodeConstructor | FunctionComponent | typeof Fragment, config: JSXProps, key?: any): ComponentChildren;
2111
+
2112
+ export { type FilterName as $, getPropertyMeta as A, getPropertyMetaOrCreate as B, type CurvePoint as C, type DesiredLength as D, getPropertiesOf as E, type FunctionComponent as F, Gradient as G, initializeSignals as H, signal as I, type JSXProps as J, initial as K, type LayoutProps as L, interpolation as M, type NodeProps as N, parser as O, type PossibleCanvasStyle as P, wrapper as Q, Rect as R, Segment as S, cloneable as T, inspectable as U, View2D as V, type Vector2LengthSignal as W, vector2Signal as X, jsx as Y, JSX as Z, Fragment as _, type RectProps as a, FILTERS as a0, type FilterProps as a1, Filter as a2, invert as a3, sepia as a4, grayscale as a5, brightness as a6, contrast as a7, saturate as a8, hue as a9, blur as aa, type GradientType as ab, type GradientStop as ac, type GradientProps as ad, type CanvasRepetition as ae, type PatternProps as af, type FlexDirection as ag, type FlexWrap as ah, type FlexBasis as ai, type FlexContent as aj, type FlexItems as ak, type TextWrap as al, type LayoutMode as am, type Length as an, type LengthLimit as ao, type CurveProfile as b, Curve as c, type CurveProps as d, Shape as e, type ShapeProps as f, Node as g, type ComponentChildren as h, Pattern as i, type CanvasStyle as j, Layout as k, type NodeState as l, type ComponentChild as m, type NodeChildren as n, type PropsOf as o, type NodeConstructor as p, type View2DProps as q, type CurveDrawingInfo as r, type CanvasStyleSignal as s, canvasStyleSignal as t, type FiltersSignal as u, FiltersSignalContext as v, filtersSignal as w, NODE_NAME as x, nodeName as y, type PropertyMetadata as z };