@pacem/pacem-2d 1.0.0-bessel → 1.0.0-dirac

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.
@@ -8,8 +8,16 @@ import { Rect } from '@pacem/pacem-foundation';
8
8
  import { Size } from '@pacem/pacem-foundation';
9
9
  import { UI } from '@pacem/pacem-core';
10
10
 
11
+ /** Shared static helpers used by the 2D rendering adapters (SVG/Canvas) to dispatch UI events and validate viewboxes. */
11
12
  declare class AdapterUtils {
13
+ /**
14
+ * Dispatches a `StageEvent` (prefixed with `'stage'`) on the given stage, when it is an `EventTarget`.
15
+ * @param stage The target stage.
16
+ * @param type Short event type name.
17
+ * @param evt The original event.
18
+ */
12
19
  static stageDispatch(stage: Stage, type: 'down' | 'up' | 'click' | 'over' | 'out' | 'move', evt: MouseEvent | TouchEvent): void;
20
+ /** Type guard telling whether `viewbox` is a well-formed, finite `Rect` usable as a stage viewbox. */
13
21
  static isValidViewbox(viewbox: any): viewbox is Rect;
14
22
  /**
15
23
  * Dispatches a UI event related to a `Drawable` and returns a boolean that tells if the event was prevented (true) or not (false).
@@ -33,30 +41,36 @@ export declare namespace Components {
33
41
  }
34
42
  }
35
43
 
44
+ /** Radius (x/y) and treatment (rounded or cut) applied to a single corner of a `PacemRectElement`. */
36
45
  declare type CornerRadius = {
37
46
  rx: CornerRadiusComponent;
38
47
  ry: CornerRadiusComponent;
39
48
  type: CornerType;
40
49
  };
41
50
 
51
+ /** One axis (rx or ry) of a `CornerRadius`: a numeric value, either in units (`'u'`) or as a percentage (`'pct'`). */
42
52
  declare type CornerRadiusComponent = {
43
53
  value: number;
44
54
  unit?: 'pct' | 'u';
45
55
  };
46
56
 
57
+ /** How a `PacemRectElement` corner is rendered: smoothly `Rounded` or straight-line `Cut` (chamfered). */
47
58
  declare enum CornerType {
48
59
  Rounded = "rounded",
49
60
  Cut = "cut"
50
61
  }
51
62
 
63
+ /** Event dispatched throughout a `Drawable`'s drag lifecycle, carrying `DragEventArgs`. */
52
64
  declare class DragEvent_2 extends UI2DEvent<DragEventArgs> {
53
65
  }
54
66
 
67
+ /** Event args carried by a `DragEvent`: the dragged `item` and its current `offset`. */
55
68
  declare interface DragEventArgs {
56
69
  readonly offset: Point;
57
70
  readonly item: Drawable;
58
71
  }
59
72
 
73
+ /** Base contract for anything that can be drawn on a `Stage`. */
60
74
  declare interface Drawable {
61
75
  stage?: Stage;
62
76
  /** Gets or sets whether the drawable is hit-testable. */
@@ -67,17 +81,27 @@ declare interface Drawable {
67
81
  tag?: any;
68
82
  }
69
83
 
84
+ /**
85
+ * Root of the `<pacem-2d-*>` drawable elements hierarchy: wires a custom element up to its containing
86
+ * `Pacem2DElement` stage and, in case of nesting, its parent drawable. By default children are not allowed
87
+ * (only `PacemGroupElement` overrides `validate` to accept them).
88
+ */
70
89
  declare abstract class DrawableElement extends Components_2.PacemCrossItemsContainerElement<DrawableElement> implements Drawable {
71
90
  validate(_: DrawableElement): boolean;
72
91
  protected findContainer(): DrawableElement | Pacem2DElement;
92
+ /** @readonly Gets the `Pacem2DElement` stage this drawable belongs to. */
73
93
  get stage(): Pacem2DElement;
94
+ /** @readonly Gets the closest ancestor `DrawableElement` (e.g. a containing group), if any. */
74
95
  get parent(): DrawableElement;
96
+ /** Gets or sets a free-form tag, reflected back onto the `tag` attribute. */
75
97
  tag: any;
98
+ /** Gets or sets whether the drawable is hit-testable (when `true`, it is ignored by pointer hit-testing). */
76
99
  inert: boolean;
77
100
  disconnectedCallback(): void;
78
101
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
79
102
  }
80
103
 
104
+ /** Event dispatched for pointer interactions (over/out/down/up/click) targeting a `Drawable`. */
81
105
  declare class DrawableEvent extends UI2DEvent<Drawable> {
82
106
  constructor(type: string, args: Drawable, originalEvent: MouseEvent | TouchEvent | KeyboardEvent, m: Matrix2D);
83
107
  }
@@ -147,22 +171,31 @@ export declare namespace Drawing_2 {
147
171
  }
148
172
  }
149
173
 
174
+ /**
175
+ * Returns the effective `StageOptions` for the given stage, filling in any option left unset with the
176
+ * library defaults.
177
+ * @param stage The stage to resolve options for.
178
+ */
150
179
  declare function getStageOptions(stage: Stage): StageOptions;
151
180
 
181
+ /** Base gradient contract, a sequence of `GradientStop`s. See also `LinearGradient` and `RadialGradient`. */
152
182
  declare interface Gradient {
153
183
  stops: GradientStop[];
154
184
  }
155
185
 
186
+ /** A single color stop within a `Gradient`. */
156
187
  declare interface GradientStop {
157
188
  offset: number;
158
189
  color: string;
159
190
  opacity?: number;
160
191
  }
161
192
 
193
+ /** A `UiObject` acting as a container of other `Drawable`s. */
162
194
  declare interface Group extends UiObject {
163
195
  childDrawables: Drawable[];
164
196
  }
165
197
 
198
+ /** A `UiObject` rendering a raster image. */
166
199
  declare interface Image_2 extends UiObject {
167
200
  src: string;
168
201
  x?: number;
@@ -171,29 +204,40 @@ declare interface Image_2 extends UiObject {
171
204
  height?: number;
172
205
  }
173
206
 
207
+ /** Type guard telling whether `object` implements `Drawable`. */
174
208
  declare function isDrawable(object: any): object is Drawable;
175
209
 
210
+ /** Type guard telling whether `object` implements `Group` and has at least one child drawable. */
176
211
  declare function isGroup(object: any): object is Group;
177
212
 
213
+ /** Type guard telling whether `object` implements `Image`. */
178
214
  declare function isImage(object: any): object is Image_2;
179
215
 
216
+ /** Type guard telling whether `object` is a `LinearGradient`. */
180
217
  declare function isLinearGradient(object: Gradient): object is LinearGradient;
181
218
 
219
+ /** Type guard telling whether `object` implements `PresentationObject`. */
182
220
  declare function isPresentationObject(object: any): object is PresentationObject;
183
221
 
222
+ /** Type guard telling whether `object` is a `RadialGradient`. */
184
223
  declare function isRadialGradient(object: Gradient): object is RadialGradient;
185
224
 
225
+ /** Type guard telling whether `object` implements `Shape`. */
186
226
  declare function isShape(object: any): object is Shape;
187
227
 
228
+ /** Type guard telling whether `object` implements `Text`. */
188
229
  declare function isText(object: any): object is Text_2;
189
230
 
231
+ /** Type guard telling whether `object` implements `UiObject`. */
190
232
  declare function isUiObject(object: any): object is UiObject;
191
233
 
234
+ /** A gradient that varies linearly from `start` to `end`. */
192
235
  declare interface LinearGradient extends Gradient {
193
236
  start: Point;
194
237
  end: Point;
195
238
  }
196
239
 
240
+ /** Arrowhead/decoration drawn at a shape's start, end, or intermediate vertices (akin to SVG `<marker>`). */
197
241
  declare type Marker = {
198
242
  pathData: string;
199
243
  stroke?: string;
@@ -204,7 +248,13 @@ declare type Marker = {
204
248
  height?: number;
205
249
  };
206
250
 
251
+ /**
252
+ * Base class for the rendering adapters (SVG, Canvas) assignable to a `Pacem2DElement` stage. Concrete
253
+ * adapters are responsible for initializing/disposing the underlying DOM surface, sizing it, drawing the
254
+ * scene graph, hit-testing and producing snapshot images.
255
+ */
207
256
  declare abstract class Pacem2DAdapterElement extends PacemEventTarget {
257
+ /** Fallback stroke/fill/lineWidth values used when a shape doesn't provide its own. */
208
258
  protected DefaultShapeValues: {
209
259
  stroke: string;
210
260
  lineWidth: number;
@@ -247,21 +297,43 @@ declare abstract class Pacem2DAdapterElement extends PacemEventTarget {
247
297
  * Processes the stage content and returns an image accordingly.
248
298
  * */
249
299
  abstract snapshot(stage: Pacem2DElement, bgColor?: string, type?: string, quality?: number): PromiseLike<Blob>;
300
+ /**
301
+ * Rasterizes the given DOM element into an image `Blob`, defaulting to JPEG when `bgColor` is provided
302
+ * (to flatten transparency against it) and to PNG otherwise.
303
+ * @param element Element to snapshot.
304
+ * @param bgColor Background color to flatten transparency against; if set, defaults `type` to `'image/jpeg'`.
305
+ * @param type Explicit image MIME type, overrides the `bgColor`-based default.
306
+ * @param quality Compression quality, applicable to lossy formats (defaults to `.9` for JPEG).
307
+ */
250
308
  protected snapshotElement(element: HTMLElement | SVGElement, bgColor?: string, type?: string, quality?: number): PromiseLike<Blob>;
251
309
  }
252
310
 
311
+ /**
312
+ * The `<pacem-2d>` element: root stage/scene container for the drawable elements (shapes, text, images,
313
+ * groups...). Delegates actual rendering to the assigned `adapter` (SVG or Canvas) and handles the
314
+ * viewbox/aspect-ratio mapping plus built-in pan and zoom interactions.
315
+ */
253
316
  declare class Pacem2DElement extends Components_2.PacemItemsContainerElement<DrawableElement> implements Stage_2 {
254
317
  #private;
318
+ /** @readonly Gets the DOM element hosting the stage content. */
255
319
  get stage(): HTMLElement;
320
+ /** Processes the stage content and returns a snapshot image (delegates to the current `adapter`). */
256
321
  snapshot(bgColor?: string, type?: string, quality?: number): Promise<any> | PromiseLike<Blob>;
322
+ /** @readonly Gets the matrix that projects stage coords into screen coords. */
257
323
  get transformMatrix(): Matrix2D;
258
324
  private _transformMatrixScale;
259
325
  validate(item: DrawableElement): boolean;
326
+ /** Gets or sets the rendering adapter (e.g. `pacem-2d-svg-adapter`) in charge of drawing the stage content. */
260
327
  adapter: Pacem2DAdapterElement;
328
+ /** Gets or sets the visible portion of the stage, in stage coordinates. */
261
329
  viewbox: Rect;
330
+ /** Gets or sets how the viewbox is mapped onto the stage's viewport (mirrors SVG's `preserveAspectRatio`). */
262
331
  aspectRatio: ViewBoxAspectRatio;
332
+ /** Gets or sets the drawable items to render, alternative to declaring them as child elements. */
263
333
  datasource: Drawable[];
334
+ /** Gets or sets the pan/zoom/click interaction options. */
264
335
  options: StageOptions;
336
+ /** Gets or sets the zoom factor (relative to the original viewbox). */
265
337
  zoom: number;
266
338
  private _stage;
267
339
  private _resize;
@@ -287,7 +359,12 @@ declare class Pacem2DElement extends Components_2.PacemItemsContainerElement<Dra
287
359
  disconnectedCallback(): void;
288
360
  }
289
361
 
290
- /** Implementation postponed. Focus on SVG adapter. */
362
+ /**
363
+ * `<pacem-2d-canvas-adapter>`: renders a `Pacem2DElement` stage onto an `HTMLCanvasElement`, redrawing the
364
+ * whole scene graph on every frame and performing manual (path-based) pointer hit-testing.
365
+ *
366
+ * @deprecated Implementation postponed. Focus on SVG adapter.
367
+ */
291
368
  declare class PacemCanvasAdapterElement extends Pacem2DAdapterElement {
292
369
  #private;
293
370
  snapshot(stage: Pacem2DElement, backgroundColor?: string, type?: string, quality?: number): PromiseLike<Blob>;
@@ -322,100 +399,184 @@ declare class PacemCanvasAdapterElement extends Pacem2DAdapterElement {
322
399
  private _handles;
323
400
  }
324
401
 
402
+ /** `<pacem-2d-circle>`: renders a full circle, or a pie-slice sector when `start`/`end` are set. */
325
403
  declare class PacemCircleElement extends ShapeElement {
404
+ /** Gets or sets the center point. */
326
405
  center: Point;
406
+ /** Gets or sets the radius. */
327
407
  radius: number;
408
+ /** Gets or sets the sector start angle, in degrees (full circle when `start`/`end` describe a full turn). */
328
409
  start: number;
410
+ /** Gets or sets the sector end angle, in degrees. */
329
411
  end: number;
330
412
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
413
+ /** Computes the SVG path data of the circle (or sector) out of its own `center`/`radius`/`start`/`end`. */
331
414
  protected getPathData(): string;
332
415
  protected getShapeGeometry(): ShapeGeometry;
416
+ /**
417
+ * Computes the SVG path data of a circle, or of a pie-slice sector when `start`/`end` don't describe a full turn.
418
+ * @param c Center point.
419
+ * @param r Radius.
420
+ * @param start Sector start angle, in degrees.
421
+ * @param end Sector end angle, in degrees.
422
+ */
333
423
  static getPathData(c?: Point, r?: number, start?: number, end?: number): string;
334
424
  }
335
425
 
426
+ /** `<pacem-2d-ellipse>`: renders a full ellipse, or a pie-slice sector when `start`/`end` are set. */
336
427
  declare class PacemEllipseElement extends ShapeElement {
428
+ /** Gets or sets the center point. */
337
429
  center: Point;
430
+ /** Gets or sets the horizontal radius. */
338
431
  rx: number;
432
+ /** Gets or sets the vertical radius. */
339
433
  ry: number;
434
+ /** Gets or sets the sector start angle, in degrees (full ellipse when `start`/`end` describe a full turn). */
340
435
  start: number;
436
+ /** Gets or sets the sector end angle, in degrees. */
341
437
  end: number;
342
438
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
439
+ /** Computes the SVG path data of the ellipse (or sector) out of its own `center`/`rx`/`ry`/`start`/`end`. */
343
440
  protected getPathData(): string;
344
441
  protected getShapeGeometry(): ShapeGeometry;
442
+ /**
443
+ * Computes the SVG path data of an ellipse, or of a pie-slice sector when `start`/`end` don't describe a full turn.
444
+ * @param c Center point.
445
+ * @param rx Horizontal radius.
446
+ * @param ry Vertical radius.
447
+ * @param start Sector start angle, in degrees.
448
+ * @param end Sector end angle, in degrees.
449
+ */
345
450
  static getPathData(c?: Point, rx?: number, ry?: number, start?: number, end?: number): string;
346
451
  }
347
452
 
453
+ /** `<pacem-2d-group>`: a container that groups child drawables, applying its own transform/presentation state to all of them. */
348
454
  declare class PacemGroupElement extends PresentationElement implements Group {
349
455
  #private;
350
456
  validate(item: DrawableElement): boolean;
457
+ /** Gets or sets the child drawables, alternative to declaring them as nested elements. */
351
458
  datasource: Drawable[];
459
+ /** @readonly Gets the child drawables currently in the group. */
352
460
  get childDrawables(): Drawable[];
353
461
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
354
462
  }
355
463
 
464
+ /** `<pacem-2d-image>`: renders a raster image at a given position and size within the stage. */
356
465
  declare class PacemImageElement extends UiElement implements Image_2 {
466
+ /** Gets or sets the image source URL. */
357
467
  src: string;
468
+ /** Gets or sets the horizontal position. */
358
469
  x: number;
470
+ /** Gets or sets the vertical position. */
359
471
  y: number;
472
+ /** Gets or sets the rendered width (defaults to the natural width, scaled if only `height` is set). */
360
473
  width: number;
474
+ /** Gets or sets the rendered height (defaults to the natural height, scaled if only `width` is set). */
361
475
  height: number;
362
476
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
363
477
  }
364
478
 
479
+ /** `<pacem-2d-line>`: renders a straight segment between two points. */
365
480
  declare class PacemLineElement extends ShapeElement {
481
+ /** Gets or sets the starting point. */
366
482
  from: Point;
483
+ /** Gets or sets the ending point. */
367
484
  to: Point;
368
485
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
369
486
  protected getShapeGeometry(): ShapeGeometry;
487
+ /** Computes the SVG path data of the line out of its own `from`/`to` points. */
370
488
  protected getPathData(): string;
489
+ /** Computes the SVG path data of a straight segment between `from` and `to`. */
371
490
  static getPathData(from?: Point, to?: Point): string;
372
491
  }
373
492
 
493
+ /** `<pacem-2d-path>`: renders an arbitrary SVG path, provided verbatim through the `d` property. */
374
494
  declare class PacemPathElement extends ShapeElement {
495
+ /** Gets or sets the raw SVG path data (`d` attribute syntax). */
375
496
  d: string;
376
497
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
498
+ /** Returns the raw path data, i.e. `d`. */
377
499
  protected getPathData: () => string;
378
500
  protected getShapeGeometry(): ShapeGeometry;
379
501
  }
380
502
 
503
+ /** `<pacem-2d-polygon>`: renders a regular polygon (or, with `starIndent` set, a star) centered on `center`. */
381
504
  declare class PacemPolygonElement extends ShapeElement {
505
+ /** Gets or sets the number of sides (or points, for a star) of the polygon. */
382
506
  sides: number;
383
507
  /** The circumradius of the polygon. */
384
508
  radius: number;
509
+ /** Gets or sets the center point of the polygon. */
385
510
  center: Point;
511
+ /** Gets or sets the star indentation factor (0 = regular polygon, up to 1 = fully indented star). */
386
512
  starIndent: number;
387
513
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
514
+ /** Computes the SVG path data of the polygon out of its own `center`, `radius`, `sides` and `starIndent`. */
388
515
  protected getPathData(): string;
389
516
  protected getShapeGeometry(): ShapeGeometry;
517
+ /**
518
+ * Computes the geometry (path data, vertices, bounding rect) of a regular polygon or star.
519
+ * @param center Center point.
520
+ * @param radius Circumradius.
521
+ * @param sides Number of sides (or points, for a star).
522
+ * @param starIndent Star indentation factor (0 = regular polygon).
523
+ */
390
524
  static getShapeGeometry(center: Point, radius: number, sides: number, starIndent?: number): ShapeGeometry;
525
+ /** Computes the SVG path data of a regular polygon or star. See `getShapeGeometry` for the parameters. */
391
526
  static getPathData(center: Point, radius: number, sides: number, starIndent?: number): string;
392
527
  }
393
528
 
529
+ /** `<pacem-2d-polyline>`: renders a series of connected segments through `points`, optionally `closed` into a polygon. */
394
530
  declare class PacemPolylineElement extends ShapeElement {
531
+ /** Gets or sets the vertices of the polyline, in order. */
395
532
  points: Point[];
533
+ /** Gets or sets whether the polyline is closed back onto its first point. */
396
534
  closed: boolean;
397
535
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
536
+ /**
537
+ * Computes the geometry (path data, vertices, bounding rect) of a polyline.
538
+ * @param points Vertices, in order.
539
+ * @param closed Whether the polyline is closed back onto its first point.
540
+ */
398
541
  static getShapeGeometry(points: Point[], closed: boolean): ShapeGeometry;
399
542
  protected getShapeGeometry(): ShapeGeometry;
543
+ /** Computes the SVG path data of the polyline out of its own `points`/`closed`. */
400
544
  protected getPathData(): string;
545
+ /** Computes the SVG path data of a polyline. See `getShapeGeometry` for the parameters. */
401
546
  static getPathData(points: Point[], closed: boolean): string;
402
547
  }
403
548
 
549
+ /** `<pacem-2d-rect>`: renders a rectangle, optionally with independently rounded or cut corners. */
404
550
  declare class PacemRectElement extends ShapeElement {
551
+ /** Gets or sets the horizontal position of the top-left corner. */
405
552
  x: number;
553
+ /** Gets or sets the vertical position of the top-left corner. */
406
554
  y: number;
555
+ /** Gets or sets the width. */
407
556
  w: number;
557
+ /** Gets or sets the height. */
408
558
  h: number;
559
+ /** Gets or sets the per-corner radii (single value applies to all four corners, or one `CornerRadius` per corner: top-left, top-right, bottom-right, bottom-left). */
409
560
  r: [CornerRadius, CornerRadius, CornerRadius, CornerRadius];
561
+ /** Gets or sets the default corner treatment (rounded or cut) used when `r` provides plain numbers instead of `CornerRadius` objects. */
410
562
  cornerType: CornerType;
411
563
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
564
+ /** Computes the SVG path data of the rectangle out of its own `x`/`y`/`w`/`h`/`r`/`cornerType`. */
412
565
  protected getPathData(): string;
413
566
  protected getShapeGeometry(): ShapeGeometry;
567
+ /** Computes the SVG path data of a plain rectangle (no rounding). */
414
568
  static getPathData(x: number, y: number, w: number, h: number): string;
569
+ /** Computes the SVG path data of a rectangle whose four corners share the same `CornerRadius`. */
415
570
  static getPathData(x: number, y: number, w: number, h: number, r: CornerRadius): string;
571
+ /** Computes the SVG path data of a rectangle with independent per-corner radii (top-left, top-right, bottom-right, bottom-left). */
416
572
  static getPathData(x: number, y: number, w: number, h: number, r: [CornerRadius, CornerRadius, CornerRadius, CornerRadius]): string;
417
573
  }
418
574
 
575
+ /**
576
+ * `<pacem-2d-svg-adapter>`: renders a `Pacem2DElement` stage as an inline SVG document, keeping one SVG
577
+ * element per drawable in sync (path/text/image/group), along with markers and gradients, and drives
578
+ * pointer hit-testing and drag & drop through the SVG DOM.
579
+ */
419
580
  declare class PacemSvgAdapterElement extends Pacem2DAdapterElement {
420
581
  #private;
421
582
  snapshot(stage: Stage, background?: string, type?: string, quality?: number): PromiseLike<Blob>;
@@ -447,31 +608,52 @@ declare class PacemSvgAdapterElement extends Pacem2DAdapterElement {
447
608
  private _items;
448
609
  }
449
610
 
611
+ /** `<pacem-2d-text>`: renders a text label anchored at a given point. */
450
612
  declare class PacemTextElement extends UiElement implements Text_2 {
613
+ /** Gets or sets the text content to render. */
451
614
  text: string;
615
+ /** Gets or sets the text color. */
452
616
  color: string;
617
+ /** Gets or sets the font family. */
453
618
  fontFamily: string;
619
+ /** Gets or sets the font size, in pixels. */
454
620
  fontSize: number;
621
+ /** Gets or sets the font weight. */
455
622
  fontWeight: string;
623
+ /** Gets or sets the font style (e.g. `italic`). */
456
624
  fontStyle: string;
625
+ /** Gets or sets the point the text is anchored to. */
457
626
  anchor: Point;
627
+ /** Gets or sets the horizontal text alignment relative to `anchor`. */
458
628
  textAnchor: 'start' | 'middle' | 'end';
459
629
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
460
630
  }
461
631
 
632
+ /**
633
+ * Base class for drawables that carry stroke/fill presentation state (color, line width, dash pattern,
634
+ * line join/cap), on top of the transform/opacity inherited from `UiElement`.
635
+ */
462
636
  declare abstract class PresentationElement extends UiElement implements PresentationObject {
637
+ /** Gets or sets the stroke color. */
463
638
  stroke: string;
639
+ /** Gets or sets the fill, either a color string or a `Gradient`. */
464
640
  fill: string | Gradient;
641
+ /** Gets or sets the stroke dash pattern, as an array of segment lengths. */
465
642
  dashArray?: number[];
643
+ /** Gets or sets the stroke line width. */
466
644
  lineWidth: number;
645
+ /** Gets or sets the stroke line join style. */
467
646
  lineJoin?: CanvasLineJoin;
647
+ /** Gets or sets the stroke line cap style. */
468
648
  lineCap?: CanvasLineCap;
469
649
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
470
650
  }
471
651
 
652
+ /** A `UiObject` that also carries presentation state (stroke, fill, etc.). */
472
653
  declare interface PresentationObject extends UiObject, PresentationState {
473
654
  }
474
655
 
656
+ /** Snapshot of the presentation-related state (stroke, fill, transform, opacity) applicable to a drawable. */
475
657
  declare interface PresentationState {
476
658
  stroke?: string;
477
659
  lineWidth?: number;
@@ -483,15 +665,25 @@ declare interface PresentationState {
483
665
  opacity?: number;
484
666
  }
485
667
 
668
+ /** Static helpers to combine `PresentationState` instances (e.g. a shape's own state with its inherited parent state). */
486
669
  declare class PresentationState {
670
+ /**
671
+ * Combines two presentation states (typically an item's own state and the one inherited from its
672
+ * ancestors), giving precedence to `lhs` whenever both define a value.
673
+ * @param lhs Own/most specific presentation state.
674
+ * @param rhs Inherited/fallback presentation state.
675
+ * @param precomputedMatrix If provided, used as-is instead of multiplying `lhs`'s and `rhs`'s transform matrices.
676
+ */
487
677
  static combine(lhs: PresentationState, rhs: PresentationState, precomputedMatrix?: Matrix2D): PresentationState;
488
678
  }
489
679
 
680
+ /** A gradient that radiates from `center` outwards up to `radius`. */
490
681
  declare interface RadialGradient extends Gradient {
491
682
  center: Point;
492
683
  radius: number;
493
684
  }
494
685
 
686
+ /** A `PresentationObject` whose visual is defined by an SVG path, optionally decorated with markers. */
495
687
  declare interface Shape extends PresentationObject {
496
688
  pathData: string;
497
689
  markerStart?: Marker;
@@ -501,44 +693,68 @@ declare interface Shape extends PresentationObject {
501
693
  readonly boundingRect?: Rect;
502
694
  }
503
695
 
696
+ /** Static helper to build an empty `ShapeGeometry`. */
504
697
  declare class Shape {
698
+ /** Returns an empty `ShapeGeometry` (no path, no vertices, zero-sized bounding rect). */
505
699
  static empty(): ShapeGeometry;
506
700
  }
507
701
 
702
+ /**
703
+ * Base class for drawables whose visual is an SVG path (`pathData`) computed out of their own geometry
704
+ * properties (e.g. center/radius, points, corners). Subclasses implement `getShapeGeometry` and this
705
+ * class takes care of recomputing `data`/`vertices`/`boundingRect` and requesting a redraw.
706
+ */
508
707
  declare abstract class ShapeElement extends PresentationElement implements Shape {
509
708
  #private;
709
+ /** @readonly Gets the computed SVG path data backing the shape (recomputed via `recomputeShape`). */
510
710
  protected data: string;
511
711
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
512
712
  viewActivatedCallback(): void;
713
+ /** Recomputes `data`, `vertices` and `boundingRect` from `getShapeGeometry()`. */
513
714
  protected recomputeShape(): void;
715
+ /** @readonly Gets the SVG path data backing the shape. */
514
716
  get pathData(): string;
717
+ /** @readonly Gets the bounding rectangle of the shape. */
515
718
  get boundingRect(): Rect;
719
+ /** @readonly Gets the vertices making up the shape. */
516
720
  get vertices(): Point[];
721
+ /** Computes the path data, vertices and bounding rect out of the shape's own geometry properties. */
517
722
  protected abstract getShapeGeometry(): ShapeGeometry;
518
723
  }
519
724
 
725
+ /** Computed geometry of a shape: its SVG path data, its vertices and its bounding rectangle. */
520
726
  declare type ShapeGeometry = {
521
727
  pathData: string;
522
728
  vertices: Point[];
523
729
  boundingRect: Rect;
524
730
  };
525
731
 
732
+ /** Abstraction of a 2D drawing surface capable of (re)drawing `Drawable` items and exposing its viewbox and screen transform. */
526
733
  declare interface Stage extends EventTarget {
734
+ /** Draws (or redraws) the whole stage, or just the provided item. */
527
735
  draw(item?: Drawable): any;
736
+ /** Gets or sets the visible portion of the stage, in stage coordinates. */
528
737
  viewbox: Rect;
738
+ /** Gets or sets how the viewbox is mapped onto the stage's viewport. */
529
739
  aspectRatio?: ViewBoxAspectRatio;
740
+ /** @readonly Gets the matrix that projects stage coords into screen coords. */
530
741
  readonly transformMatrix: Matrix2D;
742
+ /** @readonly Gets the DOM element hosting the stage content. */
531
743
  readonly stage: HTMLElement;
532
744
  }
533
745
 
746
+ /** A drawing `Stage` bound to a rendering `Pacem2DAdapterElement` (SVG or Canvas). */
534
747
  declare interface Stage_2 extends Stage {
748
+ /** @readonly Gets the adapter in charge of rendering this stage. */
535
749
  readonly adapter: Pacem2DAdapterElement;
536
750
  }
537
751
 
752
+ /** Event dispatched for pointer interactions (move/down/up/click) targeting a `Stage` at large (i.e. no specific hit `Drawable`). */
538
753
  declare class StageEvent extends UI2DEvent<Stage> {
539
754
  constructor(type: string, args: Stage, originalEvent: MouseEvent | TouchEvent | KeyboardEvent, m?: Matrix2D);
540
755
  }
541
756
 
757
+ /** User-interaction options (pan/zoom/click) of a `Stage`, including the key modifiers required to trigger them. */
542
758
  declare type StageOptions = {
543
759
  panControl: boolean;
544
760
  zoomControl: boolean;
@@ -547,6 +763,7 @@ declare type StageOptions = {
547
763
  clickModifiers: EventKeyModifier[];
548
764
  };
549
765
 
766
+ /** A `UiObject` rendering a piece of text. */
550
767
  declare interface Text_2 extends UiObject {
551
768
  text: string;
552
769
  fontFamily?: string;
@@ -558,21 +775,36 @@ declare interface Text_2 extends UiObject {
558
775
  textAnchor?: 'start' | 'middle' | 'end';
559
776
  }
560
777
 
778
+ /**
779
+ * Base class for the custom UI events dispatched by the 2D stage/adapters, carrying the screen transform
780
+ * matrix in effect at dispatch time so consumers can project screen coordinates into stage coordinates.
781
+ */
561
782
  declare abstract class UI2DEvent<T> extends CustomUIEvent<T> {
562
783
  #private;
563
784
  constructor(type: string, eventInit: CustomEventInit<T>, originalEvent: MouseEvent | TouchEvent | KeyboardEvent, transformMatrix: Matrix2D);
564
785
  /** Gets the screen transform matrix. */
565
786
  get transformMatrix(): Matrix2D;
787
+ /** Projects a point (defaults to the event's screen coordinates) through the event's transform matrix. */
566
788
  project(pt?: Point): Point;
567
789
  }
568
790
 
791
+ /**
792
+ * Base class for every drawable that participates in the 2D transform pipeline (rotation, scale,
793
+ * translation) and exposes an `opacity`. Computes and caches the corresponding `transformMatrix`.
794
+ */
569
795
  declare abstract class UiElement extends DrawableElement implements UiObject {
570
796
  #private;
797
+ /** Gets or sets the rotation angle, in degrees. */
571
798
  rotate: number;
799
+ /** Gets or sets the horizontal scale factor. */
572
800
  scaleX: number;
801
+ /** Gets or sets the vertical scale factor. */
573
802
  scaleY: number;
803
+ /** Gets or sets the horizontal translation offset. */
574
804
  translateX: number;
805
+ /** Gets or sets the vertical translation offset. */
575
806
  translateY: number;
807
+ /** Gets or sets the opacity, in the `[0, 1]` range. */
576
808
  opacity: number;
577
809
  viewActivatedCallback(): void;
578
810
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
@@ -588,13 +820,16 @@ declare abstract class UiElement extends DrawableElement implements UiObject {
588
820
  };
589
821
  }
590
822
 
823
+ /** A `Drawable` participating in the 2D transform pipeline (opacity and transform matrix). */
591
824
  declare interface UiObject extends Drawable {
592
825
  opacity?: number;
593
826
  readonly transformMatrix?: Matrix2D;
594
827
  }
595
828
 
829
+ /** Alignment keyword along one axis of the viewbox-to-viewport mapping (mirrors SVG's `preserveAspectRatio`). */
596
830
  declare type ViewBoxAlignment = 'min' | 'mid' | 'max';
597
831
 
832
+ /** Aspect-ratio behavior of the viewbox-to-viewport mapping: `'none'` stretches to fit, otherwise alignment plus an optional `slice` (cover) vs. `meet` (contain) choice. */
598
833
  declare type ViewBoxAspectRatio = 'none' | {
599
834
  x: ViewBoxAlignment;
600
835
  y: ViewBoxAlignment;