@rive-app/canvas 2.21.7 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas",
3
- "version": "2.21.7",
3
+ "version": "2.23.0",
4
4
  "description": "Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -19,7 +19,8 @@ export declare enum Fit {
19
19
  FitWidth = "fitWidth",
20
20
  FitHeight = "fitHeight",
21
21
  None = "none",
22
- ScaleDown = "scaleDown"
22
+ ScaleDown = "scaleDown",
23
+ Layout = "layout"
23
24
  }
24
25
  export declare enum Alignment {
25
26
  Center = "center",
@@ -35,6 +36,7 @@ export declare enum Alignment {
35
36
  export interface LayoutParameters {
36
37
  fit?: Fit;
37
38
  alignment?: Alignment;
39
+ layoutScaleFactor?: number;
38
40
  minX?: number;
39
41
  minY?: number;
40
42
  maxX?: number;
@@ -45,6 +47,7 @@ export declare class Layout {
45
47
  private cachedRuntimeAlignment;
46
48
  readonly fit: Fit;
47
49
  readonly alignment: Alignment;
50
+ readonly layoutScaleFactor: number;
48
51
  readonly minX: number;
49
52
  readonly minY: number;
50
53
  readonly maxX: number;
@@ -54,7 +57,7 @@ export declare class Layout {
54
57
  /**
55
58
  * Makes a copy of the layout, replacing any specified parameters
56
59
  */
57
- copyWith({ fit, alignment, minX, minY, maxX, maxY, }: LayoutParameters): Layout;
60
+ copyWith({ fit, alignment, layoutScaleFactor, minX, minY, maxX, maxY, }: LayoutParameters): Layout;
58
61
  runtimeFit(rive: rc.RiveCanvas): rc.Fit;
59
62
  runtimeAlignment(rive: rc.RiveCanvas): rc.Alignment;
60
63
  }
@@ -354,6 +357,9 @@ export declare class Rive {
354
357
  private automaticallyHandleEvents;
355
358
  private enableRiveAssetCDN;
356
359
  private _volume;
360
+ private _artboardWidth;
361
+ private _artboardHeight;
362
+ private _devicePixelRatioUsed;
357
363
  private _hasZeroSize;
358
364
  durations: number[];
359
365
  frameTimes: number[];
@@ -380,6 +386,7 @@ export declare class Rive {
380
386
  * we hook the instance to the audio manager
381
387
  */
382
388
  private initializeAudio;
389
+ private initArtboardSize;
383
390
  private initData;
384
391
  private initArtboard;
385
392
  drawFrame(): void;
@@ -475,7 +482,12 @@ export declare class Rive {
475
482
  * Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
476
483
  * Uses the size of the backing canvas to set new width/height attributes. Need to re-render
477
484
  * and resize the layout to match the new drawing surface afterwards.
478
- * Useful function for consumers to include in a window resize listener
485
+ * Useful function for consumers to include in a window resize listener.
486
+ *
487
+ * This method will set the {@link devicePixelRatioUsed} property.
488
+ *
489
+ * Optionally, you can provide a {@link customDevicePixelRatio} to provide a
490
+ * custom value.
479
491
  */
480
492
  resizeDrawingSurfaceToCanvas(customDevicePixelRatio?: number): void;
481
493
  get source(): string;
@@ -643,10 +655,46 @@ export declare class Rive {
643
655
  */
644
656
  get contents(): RiveFileContents;
645
657
  /**
646
- * getter and setter for the volume of the artboard
658
+ * Getter / Setter for the volume of the artboard
647
659
  */
648
660
  get volume(): number;
649
661
  set volume(value: number);
662
+ /**
663
+ * The width of the artboard.
664
+ *
665
+ * This will return undefined if the artboard is not loaded yet and a custom
666
+ * width has not been set.
667
+ *
668
+ * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
669
+ * with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
670
+ * automatically set.
671
+ */
672
+ get artboardWidth(): number | undefined;
673
+ set artboardWidth(value: number);
674
+ /**
675
+ * The height of the artboard.
676
+ *
677
+ * This will return undefined if the artboard is not loaded yet and a custom
678
+ * height has not been set.
679
+ *
680
+ * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
681
+ * with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
682
+ * automatically set.
683
+ */
684
+ get artboardHeight(): number | undefined;
685
+ set artboardHeight(value: number);
686
+ /**
687
+ * Reset the artboard size to its original values.
688
+ */
689
+ resetArtboardSize(): void;
690
+ /**
691
+ * The device pixel ratio used in rendering and canvas/artboard resizing.
692
+ *
693
+ * This value will be overidden by the device pixel ratio used in
694
+ * {@link resizeDrawingSurfaceToCanvas}. If you use that method, do not set this value.
695
+ */
696
+ get devicePixelRatioUsed(): number;
697
+ set devicePixelRatioUsed(value: number);
650
698
  }
651
699
  /**
652
700
  * Contents of a state machine input