@babylonjs/gui 5.43.0 → 5.43.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/2D/controls/button.d.ts +2 -0
  2. package/2D/controls/button.js +8 -0
  3. package/2D/controls/button.js.map +1 -1
  4. package/2D/controls/container.d.ts +8 -1
  5. package/2D/controls/container.js +33 -2
  6. package/2D/controls/container.js.map +1 -1
  7. package/2D/controls/control.d.ts +7 -1
  8. package/2D/controls/control.js +31 -2
  9. package/2D/controls/control.js.map +1 -1
  10. package/2D/controls/ellipse.js +2 -2
  11. package/2D/controls/ellipse.js.map +1 -1
  12. package/2D/controls/gradient/BaseGradient.d.ts +57 -0
  13. package/2D/controls/gradient/BaseGradient.js +72 -0
  14. package/2D/controls/gradient/BaseGradient.js.map +1 -0
  15. package/2D/controls/gradient/LinearGradient.d.ts +45 -0
  16. package/2D/controls/gradient/LinearGradient.js +73 -0
  17. package/2D/controls/gradient/LinearGradient.js.map +1 -0
  18. package/2D/controls/gradient/RadialGradient.d.ts +53 -0
  19. package/2D/controls/gradient/RadialGradient.js +89 -0
  20. package/2D/controls/gradient/RadialGradient.js.map +1 -0
  21. package/2D/controls/image.d.ts +5 -0
  22. package/2D/controls/image.js +21 -2
  23. package/2D/controls/image.js.map +1 -1
  24. package/2D/controls/index.d.ts +3 -0
  25. package/2D/controls/index.js +3 -0
  26. package/2D/controls/index.js.map +1 -1
  27. package/2D/controls/line.js +1 -1
  28. package/2D/controls/line.js.map +1 -1
  29. package/2D/controls/rectangle.d.ts +2 -1
  30. package/2D/controls/rectangle.js +7 -4
  31. package/2D/controls/rectangle.js.map +1 -1
  32. package/2D/controls/sliders/scrollBar.d.ts +10 -0
  33. package/2D/controls/sliders/scrollBar.js +35 -2
  34. package/2D/controls/sliders/scrollBar.js.map +1 -1
  35. package/2D/controls/sliders/slider.d.ts +11 -0
  36. package/2D/controls/sliders/slider.js +35 -3
  37. package/2D/controls/sliders/slider.js.map +1 -1
  38. package/2D/controls/textBlock.d.ts +8 -0
  39. package/2D/controls/textBlock.js +22 -3
  40. package/2D/controls/textBlock.js.map +1 -1
  41. package/package.json +2 -2
@@ -37,8 +37,8 @@ export class Ellipse extends Container {
37
37
  context.shadowOffsetY = this.shadowOffsetY;
38
38
  }
39
39
  Control.drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
40
- if (this._background) {
41
- context.fillStyle = this._background;
40
+ if (this._backgroundGradient || this._background) {
41
+ context.fillStyle = this._getBackgroundColor(context);
42
42
  context.fill();
43
43
  }
44
44
  if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
@@ -1 +1 @@
1
- {"version":3,"file":"ellipse.js","sourceRoot":"","sources":["../../../../../lts/gui/generated/2D/controls/ellipse.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAGjD,iDAAiD;AACjD,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAkBlC;;;OAGG;IACH,YAAmB,IAAa;QAC5B,KAAK,CAAC,IAAI,CAAC,CAAC;QADG,SAAI,GAAJ,IAAI,CAAS;QArBxB,eAAU,GAAG,CAAC,CAAC;IAuBvB,CAAC;IArBD,oCAAoC;IAEpC,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE;YAC3B,OAAO;SACV;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,CAA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AAC,EAC1D,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,mBAAmB,GAAG,CAAC,EAC7D,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,mBAAmB,GAAG,CAAC,EAC9D,OAAO,CACV,CAAC;QACF,OAAO,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;CACJ;AAlGG;IADC,SAAS,EAAE;wCAGX;AAiGL,aAAa,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC","sourcesContent":["import { Container } from \"./container\";\r\nimport { Control } from \"./control\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/** Class used to create 2D ellipse containers */\r\nexport class Ellipse extends Container {\r\n private _thickness = 1;\r\n\r\n /** Gets or sets border thickness */\r\n @serialize()\r\n public get thickness(): number {\r\n return this._thickness;\r\n }\r\n\r\n public set thickness(value: number) {\r\n if (this._thickness === value) {\r\n return;\r\n }\r\n\r\n this._thickness = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Ellipse\r\n * @param name defines the control name\r\n */\r\n constructor(public name?: string) {\r\n super(name);\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"Ellipse\";\r\n }\r\n\r\n protected _localDraw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2 - this._thickness / 2,\r\n this._currentMeasure.height / 2 - this._thickness / 2,\r\n context\r\n );\r\n\r\n if (this._background) {\r\n context.fillStyle = this._background;\r\n\r\n context.fill();\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n\r\n if (this._thickness) {\r\n if (this.color) {\r\n context.strokeStyle = this.color;\r\n }\r\n context.lineWidth = this._thickness;\r\n\r\n context.stroke();\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n protected _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n super._additionalProcessing(parentMeasure, context);\r\n\r\n this._measureForChildren.width -= 2 * this._thickness;\r\n this._measureForChildren.height -= 2 * this._thickness;\r\n this._measureForChildren.left += this._thickness;\r\n this._measureForChildren.top += this._thickness;\r\n }\r\n\r\n protected _clipForChildren(context: ICanvasRenderingContext) {\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2,\r\n this._currentMeasure.height / 2,\r\n context\r\n );\r\n\r\n context.clip();\r\n }\r\n\r\n public _renderHighlightSpecific(context: ICanvasRenderingContext): void {\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2 - this._highlightLineWidth / 2,\r\n this._currentMeasure.height / 2 - this._highlightLineWidth / 2,\r\n context\r\n );\r\n context.stroke();\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.Ellipse\", Ellipse);\r\n"]}
1
+ {"version":3,"file":"ellipse.js","sourceRoot":"","sources":["../../../../../lts/gui/generated/2D/controls/ellipse.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,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C,OAAgC;QACvD,OAAO,CAAC,WAAW,CACf,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,EAC1D,IAAI,CAAC,eAAe,CAAC,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAC1D,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,EAC9B,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAC/B,OAAO,CACV,CAAC;QAEF,OAAO,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;IAEM,wBAAwB,CAAC,OAAgC;QAC5D,OAAO,CAAC,WAAW,CACf,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,EAC1D,IAAI,CAAC,eAAe,CAAC,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAC1D,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,mBAAmB,GAAG,CAAC,EAC7D,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,mBAAmB,GAAG,CAAC,EAC9D,OAAO,CACV,CAAC;QACF,OAAO,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;CACJ;AAlGG;IADC,SAAS,EAAE;wCAGX;AAiGL,aAAa,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC","sourcesContent":["import { Container } from \"./container\";\r\nimport { Control } from \"./control\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/** Class used to create 2D ellipse containers */\r\nexport class Ellipse extends Container {\r\n private _thickness = 1;\r\n\r\n /** Gets or sets border thickness */\r\n @serialize()\r\n public get thickness(): number {\r\n return this._thickness;\r\n }\r\n\r\n public set thickness(value: number) {\r\n if (this._thickness === value) {\r\n return;\r\n }\r\n\r\n this._thickness = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Ellipse\r\n * @param name defines the control name\r\n */\r\n constructor(public name?: string) {\r\n super(name);\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"Ellipse\";\r\n }\r\n\r\n protected _localDraw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2 - this._thickness / 2,\r\n this._currentMeasure.height / 2 - this._thickness / 2,\r\n context\r\n );\r\n\r\n if (this._backgroundGradient || this._background) {\r\n context.fillStyle = this._getBackgroundColor(context);\r\n\r\n context.fill();\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n\r\n if (this._thickness) {\r\n if (this.color) {\r\n context.strokeStyle = this.color;\r\n }\r\n context.lineWidth = this._thickness;\r\n\r\n context.stroke();\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n protected _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n super._additionalProcessing(parentMeasure, context);\r\n\r\n this._measureForChildren.width -= 2 * this._thickness;\r\n this._measureForChildren.height -= 2 * this._thickness;\r\n this._measureForChildren.left += this._thickness;\r\n this._measureForChildren.top += this._thickness;\r\n }\r\n\r\n protected _clipForChildren(context: ICanvasRenderingContext) {\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2,\r\n this._currentMeasure.height / 2,\r\n context\r\n );\r\n\r\n context.clip();\r\n }\r\n\r\n public _renderHighlightSpecific(context: ICanvasRenderingContext): void {\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2 - this._highlightLineWidth / 2,\r\n this._currentMeasure.height / 2 - this._highlightLineWidth / 2,\r\n context\r\n );\r\n context.stroke();\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.Ellipse\", Ellipse);\r\n"]}
@@ -0,0 +1,57 @@
1
+ import type { ICanvasGradient, ICanvasRenderingContext } from "@babylonjs/core/Engines/ICanvas.js";
2
+ /**
3
+ * Type that represents a single stop on the gradient.
4
+ */
5
+ export declare type GradientColorStop = {
6
+ /**
7
+ * Offset from the start where the color will be applied.
8
+ */
9
+ offset: number;
10
+ /**
11
+ * Color to be applied.
12
+ */
13
+ color: string;
14
+ };
15
+ /**
16
+ * Class that serves as a base for all the gradients created from context.
17
+ */
18
+ export declare abstract class BaseGradient {
19
+ private _colorStops;
20
+ private _canvasGradient;
21
+ private _context;
22
+ private _gradientDirty;
23
+ /**
24
+ * Overwritten by child classes to create the canvas gradient.
25
+ * @param context
26
+ */
27
+ protected abstract _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
28
+ private _addColorStopsToCanvasGradient;
29
+ /**
30
+ * If there are any changes or the context changed, regenerate the canvas gradient object. Else,
31
+ * reuse the existing gradient.
32
+ **/
33
+ getCanvasGradient(context: ICanvasRenderingContext): CanvasGradient;
34
+ /**
35
+ * Adds a new color stop to the gradient.
36
+ * @param offset the offset of the stop on the gradient. Should be between 0 and 1
37
+ * @param color the color of the stop
38
+ */
39
+ addColorStop(offset: number, color: string): void;
40
+ /**
41
+ * Removes an existing color stop with the specified offset from the gradient
42
+ * @param offset the offset of the stop to be removed
43
+ */
44
+ removeColorStop(offset: number): void;
45
+ /**
46
+ * Removes all color stops from the gradient
47
+ */
48
+ clearColorStops(): void;
49
+ /** Color stops of the gradient */
50
+ get colorStops(): GradientColorStop[];
51
+ /** Type of the gradient */
52
+ getClassName(): string;
53
+ /** Serialize into a json object */
54
+ serialize(serializationObject: any): void;
55
+ /** Parse from json object */
56
+ parse(serializationObject: any): void;
57
+ }
@@ -0,0 +1,72 @@
1
+ /*
2
+ * Base Gradient class. Should not be used directly.
3
+ */
4
+ /**
5
+ * Class that serves as a base for all the gradients created from context.
6
+ */
7
+ export class BaseGradient {
8
+ constructor() {
9
+ this._colorStops = [];
10
+ this._gradientDirty = true;
11
+ }
12
+ _addColorStopsToCanvasGradient() {
13
+ for (const stop of this._colorStops) {
14
+ this._canvasGradient.addColorStop(stop.offset, stop.color);
15
+ }
16
+ }
17
+ /**
18
+ * If there are any changes or the context changed, regenerate the canvas gradient object. Else,
19
+ * reuse the existing gradient.
20
+ **/
21
+ getCanvasGradient(context) {
22
+ if (this._gradientDirty || this._context !== context) {
23
+ this._context = context;
24
+ this._canvasGradient = this._createCanvasGradient(context);
25
+ this._addColorStopsToCanvasGradient();
26
+ this._gradientDirty = false;
27
+ }
28
+ return this._canvasGradient;
29
+ }
30
+ /**
31
+ * Adds a new color stop to the gradient.
32
+ * @param offset the offset of the stop on the gradient. Should be between 0 and 1
33
+ * @param color the color of the stop
34
+ */
35
+ addColorStop(offset, color) {
36
+ this._colorStops.push({ offset, color });
37
+ this._gradientDirty = true;
38
+ }
39
+ /**
40
+ * Removes an existing color stop with the specified offset from the gradient
41
+ * @param offset the offset of the stop to be removed
42
+ */
43
+ removeColorStop(offset) {
44
+ this._colorStops = this._colorStops.filter((colorStop) => colorStop.offset !== offset);
45
+ this._gradientDirty = true;
46
+ }
47
+ /**
48
+ * Removes all color stops from the gradient
49
+ */
50
+ clearColorStops() {
51
+ this._colorStops = [];
52
+ this._gradientDirty = true;
53
+ }
54
+ /** Color stops of the gradient */
55
+ get colorStops() {
56
+ return this._colorStops;
57
+ }
58
+ /** Type of the gradient */
59
+ getClassName() {
60
+ return "BaseGradient";
61
+ }
62
+ /** Serialize into a json object */
63
+ serialize(serializationObject) {
64
+ serializationObject.colorStops = this._colorStops;
65
+ serializationObject.className = this.getClassName();
66
+ }
67
+ /** Parse from json object */
68
+ parse(serializationObject) {
69
+ this._colorStops = serializationObject.colorStops;
70
+ }
71
+ }
72
+ //# sourceMappingURL=BaseGradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseGradient.js","sourceRoot":"","sources":["../../../../../../lts/gui/generated/2D/controls/gradient/BaseGradient.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH;;GAEG;AACH,MAAM,OAAgB,YAAY;IAAlC;QACY,gBAAW,GAAwB,EAAE,CAAC;QAItC,mBAAc,GAAY,IAAI,CAAC;IA2E3C,CAAC;IAnEW,8BAA8B;QAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE;YACjC,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;SAC9D;IACL,CAAC;IAED;;;QAGI;IACG,iBAAiB,CAAC,OAAgC;QACrD,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE;YAClD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;YAC3D,IAAI,CAAC,8BAA8B,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;SAC/B;QACD,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,MAAc,EAAE,KAAa;QAC7C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,MAAc;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;QACvF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,eAAe;QAClB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAED,kCAAkC;IAClC,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,2BAA2B;IACpB,YAAY;QACf,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED,mCAAmC;IAC5B,SAAS,CAAC,mBAAwB;QACrC,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;QAClD,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACxD,CAAC;IAED,6BAA6B;IACtB,KAAK,CAAC,mBAAwB;QACjC,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,UAAU,CAAC;IACtD,CAAC;CACJ","sourcesContent":["/*\r\n * Base Gradient class. Should not be used directly.\r\n */\r\n\r\nimport type { ICanvasGradient, ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/**\r\n * Type that represents a single stop on the gradient.\r\n */\r\nexport type GradientColorStop = {\r\n /**\r\n * Offset from the start where the color will be applied.\r\n */\r\n offset: number;\r\n /**\r\n * Color to be applied.\r\n */\r\n color: string;\r\n};\r\n\r\n/**\r\n * Class that serves as a base for all the gradients created from context.\r\n */\r\nexport abstract class BaseGradient {\r\n private _colorStops: GradientColorStop[] = [];\r\n\r\n private _canvasGradient: CanvasGradient;\r\n private _context: ICanvasRenderingContext;\r\n private _gradientDirty: boolean = true;\r\n\r\n /**\r\n * Overwritten by child classes to create the canvas gradient.\r\n * @param context\r\n */\r\n protected abstract _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;\r\n\r\n private _addColorStopsToCanvasGradient() {\r\n for (const stop of this._colorStops) {\r\n this._canvasGradient.addColorStop(stop.offset, stop.color);\r\n }\r\n }\r\n\r\n /**\r\n * If there are any changes or the context changed, regenerate the canvas gradient object. Else,\r\n * reuse the existing gradient.\r\n **/\r\n public getCanvasGradient(context: ICanvasRenderingContext) {\r\n if (this._gradientDirty || this._context !== context) {\r\n this._context = context;\r\n this._canvasGradient = this._createCanvasGradient(context);\r\n this._addColorStopsToCanvasGradient();\r\n this._gradientDirty = false;\r\n }\r\n return this._canvasGradient;\r\n }\r\n\r\n /**\r\n * Adds a new color stop to the gradient.\r\n * @param offset the offset of the stop on the gradient. Should be between 0 and 1\r\n * @param color the color of the stop\r\n */\r\n public addColorStop(offset: number, color: string) {\r\n this._colorStops.push({ offset, color });\r\n this._gradientDirty = true;\r\n }\r\n\r\n /**\r\n * Removes an existing color stop with the specified offset from the gradient\r\n * @param offset the offset of the stop to be removed\r\n */\r\n public removeColorStop(offset: number) {\r\n this._colorStops = this._colorStops.filter((colorStop) => colorStop.offset !== offset);\r\n this._gradientDirty = true;\r\n }\r\n\r\n /**\r\n * Removes all color stops from the gradient\r\n */\r\n public clearColorStops() {\r\n this._colorStops = [];\r\n this._gradientDirty = true;\r\n }\r\n\r\n /** Color stops of the gradient */\r\n public get colorStops() {\r\n return this._colorStops;\r\n }\r\n\r\n /** Type of the gradient */\r\n public getClassName() {\r\n return \"BaseGradient\";\r\n }\r\n\r\n /** Serialize into a json object */\r\n public serialize(serializationObject: any) {\r\n serializationObject.colorStops = this._colorStops;\r\n serializationObject.className = this.getClassName();\r\n }\r\n\r\n /** Parse from json object */\r\n public parse(serializationObject: any) {\r\n this._colorStops = serializationObject.colorStops;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,45 @@
1
+ import type { ICanvasGradient, ICanvasRenderingContext } from "@babylonjs/core/Engines/ICanvas.js";
2
+ import { BaseGradient } from "./BaseGradient";
3
+ /**
4
+ * Gradient along a line that connects two coordinates.
5
+ * These coordinates are relative to the canvas' space, not to any control's space.
6
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
7
+ */
8
+ export declare class LinearGradient extends BaseGradient {
9
+ private _x0;
10
+ private _y0;
11
+ private _x1;
12
+ private _y1;
13
+ /**
14
+ * Creates a new linear gradient
15
+ * @param x0
16
+ * @param y0
17
+ * @param x1
18
+ * @param y1
19
+ */
20
+ constructor(x0?: number, y0?: number, x1?: number, y1?: number);
21
+ protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
22
+ /** X axis coordinate of the starting point in the line */
23
+ get x0(): number;
24
+ /** X axis coordinate of the ending point in the line */
25
+ get x1(): number;
26
+ /** Y axis coordinate of the starting point in the line */
27
+ get y0(): number;
28
+ /** Y axis coordinate of the ending point in the line */
29
+ get y1(): number;
30
+ /**
31
+ * Class name of the gradient
32
+ * @returns the class name of the gradient
33
+ */
34
+ getClassName(): string;
35
+ /**
36
+ * Serializes this gradient
37
+ * @param serializationObject the object to serialize to
38
+ */
39
+ serialize(serializationObject: any): void;
40
+ /**
41
+ * Parses a gradient from a serialization object
42
+ * @param serializationObject the object to parse from
43
+ */
44
+ parse(serializationObject: any): void;
45
+ }
@@ -0,0 +1,73 @@
1
+ import { BaseGradient } from "./BaseGradient.js";
2
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
3
+ /**
4
+ * Gradient along a line that connects two coordinates.
5
+ * These coordinates are relative to the canvas' space, not to any control's space.
6
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
7
+ */
8
+ export class LinearGradient extends BaseGradient {
9
+ /**
10
+ * Creates a new linear gradient
11
+ * @param x0
12
+ * @param y0
13
+ * @param x1
14
+ * @param y1
15
+ */
16
+ constructor(x0, y0, x1, y1) {
17
+ super();
18
+ this._x0 = x0 !== null && x0 !== void 0 ? x0 : 0;
19
+ this._y0 = y0 !== null && y0 !== void 0 ? y0 : 0;
20
+ this._x1 = x1 !== null && x1 !== void 0 ? x1 : 0;
21
+ this._y1 = y1 !== null && y1 !== void 0 ? y1 : 0;
22
+ }
23
+ _createCanvasGradient(context) {
24
+ return context.createLinearGradient(this._x0, this._y0, this._x1, this._y1);
25
+ }
26
+ /** X axis coordinate of the starting point in the line */
27
+ get x0() {
28
+ return this._x0;
29
+ }
30
+ /** X axis coordinate of the ending point in the line */
31
+ get x1() {
32
+ return this._x1;
33
+ }
34
+ /** Y axis coordinate of the starting point in the line */
35
+ get y0() {
36
+ return this._y0;
37
+ }
38
+ /** Y axis coordinate of the ending point in the line */
39
+ get y1() {
40
+ return this._y1;
41
+ }
42
+ /**
43
+ * Class name of the gradient
44
+ * @returns the class name of the gradient
45
+ */
46
+ getClassName() {
47
+ return "LinearGradient";
48
+ }
49
+ /**
50
+ * Serializes this gradient
51
+ * @param serializationObject the object to serialize to
52
+ */
53
+ serialize(serializationObject) {
54
+ super.serialize(serializationObject);
55
+ serializationObject.x0 = this._x0;
56
+ serializationObject.y0 = this._y0;
57
+ serializationObject.x1 = this._x1;
58
+ serializationObject.y1 = this._y1;
59
+ }
60
+ /**
61
+ * Parses a gradient from a serialization object
62
+ * @param serializationObject the object to parse from
63
+ */
64
+ parse(serializationObject) {
65
+ super.parse(serializationObject);
66
+ this._x0 = serializationObject.x0;
67
+ this._y0 = serializationObject.y0;
68
+ this._x1 = serializationObject.x1;
69
+ this._y1 = serializationObject.y1;
70
+ }
71
+ }
72
+ RegisterClass("BABYLON.GUI.LinearGradient", LinearGradient);
73
+ //# sourceMappingURL=LinearGradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinearGradient.js","sourceRoot":"","sources":["../../../../../../lts/gui/generated/2D/controls/gradient/LinearG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QACrC,mBAAmB,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QAClC,mBAAmB,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QAClC,mBAAmB,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QAClC,mBAAmB,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;IACtC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,mBAAwB;QACjC,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,EAAE,CAAC;IACtC,CAAC;CACJ;AACD,aAAa,CAAC,4BAA4B,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { ICanvasGradient, ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\nimport { BaseGradient } from \"./BaseGradient\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\n/**\r\n * Gradient along a line that connects two coordinates.\r\n * These coordinates are relative to the canvas' space, not to any control's space.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient\r\n */\r\nexport class LinearGradient extends BaseGradient {\r\n private _x0: number;\r\n private _y0: number;\r\n private _x1: number;\r\n private _y1: number;\r\n\r\n /**\r\n * Creates a new linear gradient\r\n * @param x0\r\n * @param y0\r\n * @param x1\r\n * @param y1\r\n */\r\n constructor(x0?: number, y0?: number, x1?: number, y1?: number) {\r\n super();\r\n this._x0 = x0 ?? 0;\r\n this._y0 = y0 ?? 0;\r\n this._x1 = x1 ?? 0;\r\n this._y1 = y1 ?? 0;\r\n }\r\n\r\n protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient {\r\n return context.createLinearGradient(this._x0, this._y0, this._x1, this._y1);\r\n }\r\n\r\n /** X axis coordinate of the starting point in the line */\r\n public get x0() {\r\n return this._x0;\r\n }\r\n\r\n /** X axis coordinate of the ending point in the line */\r\n public get x1() {\r\n return this._x1;\r\n }\r\n\r\n /** Y axis coordinate of the starting point in the line */\r\n public get y0() {\r\n return this._y0;\r\n }\r\n\r\n /** Y axis coordinate of the ending point in the line */\r\n public get y1() {\r\n return this._y1;\r\n }\r\n\r\n /**\r\n * Class name of the gradient\r\n * @returns the class name of the gradient\r\n */\r\n public getClassName(): string {\r\n return \"LinearGradient\";\r\n }\r\n\r\n /**\r\n * Serializes this gradient\r\n * @param serializationObject the object to serialize to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.x0 = this._x0;\r\n serializationObject.y0 = this._y0;\r\n serializationObject.x1 = this._x1;\r\n serializationObject.y1 = this._y1;\r\n }\r\n\r\n /**\r\n * Parses a gradient from a serialization object\r\n * @param serializationObject the object to parse from\r\n */\r\n public parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this._x0 = serializationObject.x0;\r\n this._y0 = serializationObject.y0;\r\n this._x1 = serializationObject.x1;\r\n this._y1 = serializationObject.y1;\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.LinearGradient\", LinearGradient);\r\n"]}
@@ -0,0 +1,53 @@
1
+ import type { ICanvasGradient, ICanvasRenderingContext } from "@babylonjs/core/Engines/ICanvas.js";
2
+ import { BaseGradient } from "./BaseGradient";
3
+ /**
4
+ * Gradient formed from two circles with their own centers and radius.
5
+ * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
6
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
7
+ */
8
+ export declare class RadialGradient extends BaseGradient {
9
+ private _x0;
10
+ private _y0;
11
+ private _r0;
12
+ private _x1;
13
+ private _y1;
14
+ private _r1;
15
+ /**
16
+ * Creates a new radial gradient
17
+ * @param x0 x coordinate of the first circle's center
18
+ * @param y0 y coordinate of the first circle's center
19
+ * @param r0 radius of the first circle
20
+ * @param x1 x coordinate of the second circle's center
21
+ * @param y1 y coordinate of the second circle's center
22
+ * @param r1 radius of the second circle
23
+ */
24
+ constructor(x0?: number, y0?: number, r0?: number, x1?: number, y1?: number, r1?: number);
25
+ protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
26
+ /** x coordinate of the first circle's center */
27
+ get x0(): number;
28
+ /** x coordinate of the second circle's center */
29
+ get x1(): number;
30
+ /** y coordinate of the first circle's center */
31
+ get y0(): number;
32
+ /** y coordinate of the second circle's center */
33
+ get y1(): number;
34
+ /** radius of the first circle */
35
+ get r0(): number;
36
+ /** radius of the second circle */
37
+ get r1(): number;
38
+ /**
39
+ * Class name of the gradient
40
+ * @returns the class name of the gradient
41
+ */
42
+ getClassName(): string;
43
+ /**
44
+ * Serializes this gradient
45
+ * @param serializationObject the object to serialize to
46
+ */
47
+ serialize(serializationObject: any): void;
48
+ /**
49
+ * Parses a gradient from a serialization object
50
+ * @param serializationObject the object to parse from
51
+ */
52
+ parse(serializationObject: any): void;
53
+ }
@@ -0,0 +1,89 @@
1
+ import { BaseGradient } from "./BaseGradient.js";
2
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
3
+ /**
4
+ * Gradient formed from two circles with their own centers and radius.
5
+ * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
6
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
7
+ */
8
+ export class RadialGradient extends BaseGradient {
9
+ /**
10
+ * Creates a new radial gradient
11
+ * @param x0 x coordinate of the first circle's center
12
+ * @param y0 y coordinate of the first circle's center
13
+ * @param r0 radius of the first circle
14
+ * @param x1 x coordinate of the second circle's center
15
+ * @param y1 y coordinate of the second circle's center
16
+ * @param r1 radius of the second circle
17
+ */
18
+ constructor(x0, y0, r0, x1, y1, r1) {
19
+ super();
20
+ this._x0 = x0 !== null && x0 !== void 0 ? x0 : 0;
21
+ this._y0 = y0 !== null && y0 !== void 0 ? y0 : 0;
22
+ this._r0 = r0 !== null && r0 !== void 0 ? r0 : 0;
23
+ this._x1 = x1 !== null && x1 !== void 0 ? x1 : 0;
24
+ this._y1 = y1 !== null && y1 !== void 0 ? y1 : 0;
25
+ this._r1 = r1 !== null && r1 !== void 0 ? r1 : 0;
26
+ }
27
+ _createCanvasGradient(context) {
28
+ return context.createRadialGradient(this._x0, this._y0, this._r0, this._x1, this._y1, this._r1);
29
+ }
30
+ /** x coordinate of the first circle's center */
31
+ get x0() {
32
+ return this._x0;
33
+ }
34
+ /** x coordinate of the second circle's center */
35
+ get x1() {
36
+ return this._x1;
37
+ }
38
+ /** y coordinate of the first circle's center */
39
+ get y0() {
40
+ return this._y0;
41
+ }
42
+ /** y coordinate of the second circle's center */
43
+ get y1() {
44
+ return this._y1;
45
+ }
46
+ /** radius of the first circle */
47
+ get r0() {
48
+ return this._r0;
49
+ }
50
+ /** radius of the second circle */
51
+ get r1() {
52
+ return this._r1;
53
+ }
54
+ /**
55
+ * Class name of the gradient
56
+ * @returns the class name of the gradient
57
+ */
58
+ getClassName() {
59
+ return "RadialGradient";
60
+ }
61
+ /**
62
+ * Serializes this gradient
63
+ * @param serializationObject the object to serialize to
64
+ */
65
+ serialize(serializationObject) {
66
+ super.serialize(serializationObject);
67
+ serializationObject.x0 = this._x0;
68
+ serializationObject.y0 = this._y0;
69
+ serializationObject.r0 = this._r0;
70
+ serializationObject.x1 = this._x1;
71
+ serializationObject.y1 = this._y1;
72
+ serializationObject.r1 = this._r1;
73
+ }
74
+ /**
75
+ * Parses a gradient from a serialization object
76
+ * @param serializationObject the object to parse from
77
+ */
78
+ parse(serializationObject) {
79
+ super.parse(serializationObject);
80
+ this._x0 = serializationObject.x0;
81
+ this._y0 = serializationObject.y0;
82
+ this._r0 = serializationObject.r0;
83
+ this._x1 = serializationObject.x1;
84
+ this._y1 = serializationObject.y1;
85
+ this._r1 = serializationObject.r1;
86
+ }
87
+ }
88
+ RegisterClass("BABYLON.GUI.RadialGradient", RadialGradient);
89
+ //# sourceMappingURL=RadialGradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadialGradient.js","sourceRoot":"","sources":["../../../../../../lts/gui/generated/2D/controls/gradient/RadialGradient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAY;IAQ5C;;;;;;;;OAQG;IACH,YAAY,EAAW,EAAE,EAAW,EAAE,EAAW,EAAE,EAAW,EAAE,EAAW,EAAE,EAAW;QACpF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,CAAC,CAAC;IACvB,CAAC;IAES,qBAAqB,CAAC,OAAgC;QAC5D,OAAO,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACpG,CAAC;IAED,gDAAgD;IAChD,IAAW,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AG,mBAAmB,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,EAAE,CAAC;IACtC,CAAC;CACJ;AACD,aAAa,CAAC,4BAA4B,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { ICanvasGradient, ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\nimport { BaseGradient } from \"./BaseGradient\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\n/**\r\n * Gradient formed from two circles with their own centers and radius.\r\n * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient\r\n */\r\nexport class RadialGradient extends BaseGradient {\r\n private _x0: number;\r\n private _y0: number;\r\n private _r0: number;\r\n private _x1: number;\r\n private _y1: number;\r\n private _r1: number;\r\n\r\n /**\r\n * Creates a new radial gradient\r\n * @param x0 x coordinate of the first circle's center\r\n * @param y0 y coordinate of the first circle's center\r\n * @param r0 radius of the first circle\r\n * @param x1 x coordinate of the second circle's center\r\n * @param y1 y coordinate of the second circle's center\r\n * @param r1 radius of the second circle\r\n */\r\n constructor(x0?: number, y0?: number, r0?: number, x1?: number, y1?: number, r1?: number) {\r\n super();\r\n this._x0 = x0 ?? 0;\r\n this._y0 = y0 ?? 0;\r\n this._r0 = r0 ?? 0;\r\n this._x1 = x1 ?? 0;\r\n this._y1 = y1 ?? 0;\r\n this._r1 = r1 ?? 0;\r\n }\r\n\r\n protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient {\r\n return context.createRadialGradient(this._x0, this._y0, this._r0, this._x1, this._y1, this._r1);\r\n }\r\n\r\n /** x coordinate of the first circle's center */\r\n public get x0() {\r\n return this._x0;\r\n }\r\n\r\n /** x coordinate of the second circle's center */\r\n public get x1() {\r\n return this._x1;\r\n }\r\n\r\n /** y coordinate of the first circle's center */\r\n public get y0() {\r\n return this._y0;\r\n }\r\n\r\n /** y coordinate of the second circle's center */\r\n public get y1() {\r\n return this._y1;\r\n }\r\n\r\n /** radius of the first circle */\r\n public get r0() {\r\n return this._r0;\r\n }\r\n\r\n /** radius of the second circle */\r\n public get r1() {\r\n return this._r1;\r\n }\r\n\r\n /**\r\n * Class name of the gradient\r\n * @returns the class name of the gradient\r\n */\r\n public getClassName() {\r\n return \"RadialGradient\";\r\n }\r\n\r\n /**\r\n * Serializes this gradient\r\n * @param serializationObject the object to serialize to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.x0 = this._x0;\r\n serializationObject.y0 = this._y0;\r\n serializationObject.r0 = this._r0;\r\n serializationObject.x1 = this._x1;\r\n serializationObject.y1 = this._y1;\r\n serializationObject.r1 = this._r1;\r\n }\r\n\r\n /**\r\n * Parses a gradient from a serialization object\r\n * @param serializationObject the object to parse from\r\n */\r\n public parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this._x0 = serializationObject.x0;\r\n this._y0 = serializationObject.y0;\r\n this._r0 = serializationObject.r0;\r\n this._x1 = serializationObject.x1;\r\n this._y1 = serializationObject.y1;\r\n this._r1 = serializationObject.r1;\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.RadialGradient\", RadialGradient);\r\n"]}
@@ -36,9 +36,14 @@ export declare class Image extends Control {
36
36
  private _populateNinePatchSlicesFromImage;
37
37
  private _detectPointerOnOpaqueOnly;
38
38
  private _imageDataCache;
39
+ /**
40
+ * Cache of images to avoid loading the same image multiple times
41
+ */
39
42
  static SourceImgCache: Map<string, {
40
43
  img: IImage;
41
44
  timesUsed: number;
45
+ loaded: boolean;
46
+ waitingForLoadCallback: Array<() => void>;
42
47
  }>;
43
48
  /**
44
49
  * Observable notified when the content is loaded
@@ -421,14 +421,30 @@ export class Image extends Control {
421
421
  const cachedData = Image.SourceImgCache.get(value);
422
422
  this._domImage = cachedData.img;
423
423
  cachedData.timesUsed += 1;
424
- this._onImageLoaded();
424
+ if (cachedData.loaded) {
425
+ this._onImageLoaded();
426
+ }
427
+ else {
428
+ cachedData.waitingForLoadCallback.push(this._onImageLoaded.bind(this));
429
+ }
425
430
  return;
426
431
  }
427
432
  this._domImage = engine.createCanvasImage();
428
433
  if (value) {
429
- Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1 });
434
+ Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1, loaded: false, waitingForLoadCallback: [this._onImageLoaded.bind(this)] });
430
435
  }
431
436
  this._domImage.onload = () => {
437
+ if (value) {
438
+ const cachedData = Image.SourceImgCache.get(value);
439
+ if (cachedData) {
440
+ cachedData.loaded = true;
441
+ for (const waitingCallback of cachedData.waitingForLoadCallback) {
442
+ waitingCallback();
443
+ }
444
+ cachedData.waitingForLoadCallback.length = 0;
445
+ return;
446
+ }
447
+ }
432
448
  this._onImageLoaded();
433
449
  };
434
450
  if (value) {
@@ -761,6 +777,9 @@ export class Image extends Control {
761
777
  this._removeCacheUsage(this._source);
762
778
  }
763
779
  }
780
+ /**
781
+ * Cache of images to avoid loading the same image multiple times
782
+ */
764
783
  Image.SourceImgCache = new Map();
765
784
  // Static
766
785
  /** STRETCH_NONE */