babylonjs-gui 5.43.1 → 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.
@@ -555,6 +555,7 @@ import { TextBlock } from "babylonjs-gui/2D/controls/textBlock";
555
555
  import { Image } from "babylonjs-gui/2D/controls/image";
556
556
  import { PointerInfoBase } from "babylonjs/Events/pointerEvents";
557
557
  import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
558
+ import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
558
559
  /**
559
560
  * Class used to create 2D buttons
560
561
  */
@@ -612,6 +613,7 @@ export class Button extends Rectangle {
612
613
  * @internal
613
614
  */
614
615
  _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean;
616
+ protected _getRectangleFill(context: ICanvasRenderingContext): string | import("babylonjs/Engines/ICanvas").ICanvasGradient;
615
617
  /**
616
618
  * @internal
617
619
  */
@@ -824,9 +826,10 @@ import { Control } from "babylonjs-gui/2D/controls/control";
824
826
  import { Measure } from "babylonjs-gui/2D/measure";
825
827
  import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
826
828
  import { PointerInfoBase } from "babylonjs/Events/pointerEvents";
827
- import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
829
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
828
830
  import { DynamicTexture } from "babylonjs/Materials/Textures/dynamicTexture";
829
831
  import { Observable } from "babylonjs/Misc/observable";
832
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
830
833
  /**
831
834
  * Root class for 2D containers
832
835
  * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#containers
@@ -840,6 +843,8 @@ export class Container extends Control {
840
843
  /** @internal */
841
844
  protected _background: string;
842
845
  /** @internal */
846
+ protected _backgroundGradient: Nullable<BaseGradient>;
847
+ /** @internal */
843
848
  protected _adaptWidthToChildren: boolean;
844
849
  /** @internal */
845
850
  protected _adaptHeightToChildren: boolean;
@@ -867,6 +872,9 @@ export class Container extends Control {
867
872
  /** Gets or sets background color */
868
873
  get background(): string;
869
874
  set background(value: string);
875
+ /** Gets or sets background gradient color. Takes precedence over background */
876
+ get backgroundGradient(): Nullable<BaseGradient>;
877
+ set backgroundGradient(value: Nullable<BaseGradient>);
870
878
  /** Gets the list of children */
871
879
  get children(): Control[];
872
880
  get isReadOnly(): boolean;
@@ -936,6 +944,7 @@ export class Container extends Control {
936
944
  _offsetTop(offset: number): void;
937
945
  /** @internal */
938
946
  _markAllAsDirty(): void;
947
+ protected _getBackgroundColor(context: ICanvasRenderingContext): string | ICanvasGradient;
939
948
  /**
940
949
  * @internal
941
950
  */
@@ -995,10 +1004,11 @@ import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
995
1004
  import { Measure } from "babylonjs-gui/2D/measure";
996
1005
  import { Style } from "babylonjs-gui/2D/style";
997
1006
  import { Matrix2D, Vector2WithInfo } from "babylonjs-gui/2D/math2D";
998
- import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
1007
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
999
1008
  import { IAccessibilityTag } from "babylonjs/IAccessibilityTag";
1000
1009
  import { IAnimatable } from "babylonjs/Animations/animatable.interface";
1001
1010
  import { Animation } from "babylonjs/Animations/animation";
1011
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
1002
1012
  /**
1003
1013
  * Root class used for all 2D controls
1004
1014
  * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#controls
@@ -1094,6 +1104,7 @@ export class Control implements IAnimatable {
1094
1104
  protected _disabledColor: string;
1095
1105
  protected _disabledColorItem: string;
1096
1106
  protected _isReadOnly: boolean;
1107
+ private _gradient;
1097
1108
  /** @internal */
1098
1109
  protected _rebuildLayout: boolean;
1099
1110
  /** @internal */
@@ -1363,6 +1374,9 @@ export class Control implements IAnimatable {
1363
1374
  /** Gets or sets foreground color */
1364
1375
  get color(): string;
1365
1376
  set color(value: string);
1377
+ /** Gets or sets gradient. Setting a gradient will override the color */
1378
+ get gradient(): Nullable<BaseGradient>;
1379
+ set gradient(value: Nullable<BaseGradient>);
1366
1380
  /** Gets or sets z index which is used to reorder controls on the z axis */
1367
1381
  get zIndex(): number;
1368
1382
  set zIndex(value: number);
@@ -1659,6 +1673,7 @@ export class Control implements IAnimatable {
1659
1673
  * @internal
1660
1674
  */
1661
1675
  _renderHighlightSpecific(context: ICanvasRenderingContext): void;
1676
+ protected _getColor(context: ICanvasRenderingContext): string | ICanvasGradient;
1662
1677
  /**
1663
1678
  * @internal
1664
1679
  */
@@ -1989,6 +2004,170 @@ export interface IFocusableControl {
1989
2004
  blur(): void;
1990
2005
  }
1991
2006
 
2007
+ }
2008
+ declare module "babylonjs-gui/2D/controls/gradient/BaseGradient" {
2009
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2010
+ /**
2011
+ * Type that represents a single stop on the gradient.
2012
+ */
2013
+ export type GradientColorStop = {
2014
+ /**
2015
+ * Offset from the start where the color will be applied.
2016
+ */
2017
+ offset: number;
2018
+ /**
2019
+ * Color to be applied.
2020
+ */
2021
+ color: string;
2022
+ };
2023
+ /**
2024
+ * Class that serves as a base for all the gradients created from context.
2025
+ */
2026
+ export abstract class BaseGradient {
2027
+ private _colorStops;
2028
+ private _canvasGradient;
2029
+ private _context;
2030
+ private _gradientDirty;
2031
+ /**
2032
+ * Overwritten by child classes to create the canvas gradient.
2033
+ * @param context
2034
+ */
2035
+ protected abstract _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
2036
+ private _addColorStopsToCanvasGradient;
2037
+ /**
2038
+ * If there are any changes or the context changed, regenerate the canvas gradient object. Else,
2039
+ * reuse the existing gradient.
2040
+ **/
2041
+ getCanvasGradient(context: ICanvasRenderingContext): CanvasGradient;
2042
+ /**
2043
+ * Adds a new color stop to the gradient.
2044
+ * @param offset the offset of the stop on the gradient. Should be between 0 and 1
2045
+ * @param color the color of the stop
2046
+ */
2047
+ addColorStop(offset: number, color: string): void;
2048
+ /**
2049
+ * Removes an existing color stop with the specified offset from the gradient
2050
+ * @param offset the offset of the stop to be removed
2051
+ */
2052
+ removeColorStop(offset: number): void;
2053
+ /**
2054
+ * Removes all color stops from the gradient
2055
+ */
2056
+ clearColorStops(): void;
2057
+ /** Color stops of the gradient */
2058
+ get colorStops(): GradientColorStop[];
2059
+ /** Type of the gradient */
2060
+ getClassName(): string;
2061
+ /** Serialize into a json object */
2062
+ serialize(serializationObject: any): void;
2063
+ /** Parse from json object */
2064
+ parse(serializationObject: any): void;
2065
+ }
2066
+
2067
+ }
2068
+ declare module "babylonjs-gui/2D/controls/gradient/LinearGradient" {
2069
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2070
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
2071
+ /**
2072
+ * Gradient along a line that connects two coordinates.
2073
+ * These coordinates are relative to the canvas' space, not to any control's space.
2074
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
2075
+ */
2076
+ export class LinearGradient extends BaseGradient {
2077
+ private _x0;
2078
+ private _y0;
2079
+ private _x1;
2080
+ private _y1;
2081
+ /**
2082
+ * Creates a new linear gradient
2083
+ * @param x0
2084
+ * @param y0
2085
+ * @param x1
2086
+ * @param y1
2087
+ */
2088
+ constructor(x0?: number, y0?: number, x1?: number, y1?: number);
2089
+ protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
2090
+ /** X axis coordinate of the starting point in the line */
2091
+ get x0(): number;
2092
+ /** X axis coordinate of the ending point in the line */
2093
+ get x1(): number;
2094
+ /** Y axis coordinate of the starting point in the line */
2095
+ get y0(): number;
2096
+ /** Y axis coordinate of the ending point in the line */
2097
+ get y1(): number;
2098
+ /**
2099
+ * Class name of the gradient
2100
+ * @returns the class name of the gradient
2101
+ */
2102
+ getClassName(): string;
2103
+ /**
2104
+ * Serializes this gradient
2105
+ * @param serializationObject the object to serialize to
2106
+ */
2107
+ serialize(serializationObject: any): void;
2108
+ /**
2109
+ * Parses a gradient from a serialization object
2110
+ * @param serializationObject the object to parse from
2111
+ */
2112
+ parse(serializationObject: any): void;
2113
+ }
2114
+
2115
+ }
2116
+ declare module "babylonjs-gui/2D/controls/gradient/RadialGradient" {
2117
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2118
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
2119
+ /**
2120
+ * Gradient formed from two circles with their own centers and radius.
2121
+ * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
2122
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
2123
+ */
2124
+ export class RadialGradient extends BaseGradient {
2125
+ private _x0;
2126
+ private _y0;
2127
+ private _r0;
2128
+ private _x1;
2129
+ private _y1;
2130
+ private _r1;
2131
+ /**
2132
+ * Creates a new radial gradient
2133
+ * @param x0 x coordinate of the first circle's center
2134
+ * @param y0 y coordinate of the first circle's center
2135
+ * @param r0 radius of the first circle
2136
+ * @param x1 x coordinate of the second circle's center
2137
+ * @param y1 y coordinate of the second circle's center
2138
+ * @param r1 radius of the second circle
2139
+ */
2140
+ constructor(x0?: number, y0?: number, r0?: number, x1?: number, y1?: number, r1?: number);
2141
+ protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
2142
+ /** x coordinate of the first circle's center */
2143
+ get x0(): number;
2144
+ /** x coordinate of the second circle's center */
2145
+ get x1(): number;
2146
+ /** y coordinate of the first circle's center */
2147
+ get y0(): number;
2148
+ /** y coordinate of the second circle's center */
2149
+ get y1(): number;
2150
+ /** radius of the first circle */
2151
+ get r0(): number;
2152
+ /** radius of the second circle */
2153
+ get r1(): number;
2154
+ /**
2155
+ * Class name of the gradient
2156
+ * @returns the class name of the gradient
2157
+ */
2158
+ getClassName(): string;
2159
+ /**
2160
+ * Serializes this gradient
2161
+ * @param serializationObject the object to serialize to
2162
+ */
2163
+ serialize(serializationObject: any): void;
2164
+ /**
2165
+ * Parses a gradient from a serialization object
2166
+ * @param serializationObject the object to parse from
2167
+ */
2168
+ parse(serializationObject: any): void;
2169
+ }
2170
+
1992
2171
  }
1993
2172
  declare module "babylonjs-gui/2D/controls/grid" {
1994
2173
  import { Nullable } from "babylonjs/types";
@@ -2390,6 +2569,9 @@ export * from "babylonjs-gui/2D/controls/sliders/imageBasedSlider";
2390
2569
  export * from "babylonjs-gui/2D/controls/sliders/scrollBar";
2391
2570
  export * from "babylonjs-gui/2D/controls/sliders/imageScrollBar";
2392
2571
  export * from "babylonjs-gui/2D/controls/statics";
2572
+ export * from "babylonjs-gui/2D/controls/gradient/BaseGradient";
2573
+ export * from "babylonjs-gui/2D/controls/gradient/LinearGradient";
2574
+ export * from "babylonjs-gui/2D/controls/gradient/RadialGradient";
2393
2575
 
2394
2576
  }
2395
2577
  declare module "babylonjs-gui/2D/controls/inputPassword" {
@@ -2978,7 +3160,7 @@ export class RadioButton extends Control {
2978
3160
  declare module "babylonjs-gui/2D/controls/rectangle" {
2979
3161
  import { Container } from "babylonjs-gui/2D/controls/container";
2980
3162
  import { Measure } from "babylonjs-gui/2D/measure";
2981
- import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
3163
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2982
3164
  /** Class used to create rectangle container */
2983
3165
  export class Rectangle extends Container {
2984
3166
  name?: string | undefined;
@@ -3000,6 +3182,7 @@ export class Rectangle extends Container {
3000
3182
  protected _computeAdditionnalOffsetX(): 1 | 0;
3001
3183
  /** @internal */
3002
3184
  protected _computeAdditionnalOffsetY(): 1 | 0;
3185
+ protected _getRectangleFill(context: ICanvasRenderingContext): string | ICanvasGradient;
3003
3186
  protected _localDraw(context: ICanvasRenderingContext): void;
3004
3187
  protected _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void;
3005
3188
  private _drawRoundedRect;
@@ -3691,6 +3874,9 @@ import { BaseSlider } from "babylonjs-gui/2D/controls/sliders/baseSlider";
3691
3874
  import { Control } from "babylonjs-gui/2D/controls/control";
3692
3875
  import { PointerInfoBase } from "babylonjs/Events/pointerEvents";
3693
3876
  import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
3877
+ import { Nullable } from "babylonjs/types";
3878
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
3879
+ import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
3694
3880
  /**
3695
3881
  * Class used to create slider controls
3696
3882
  */
@@ -3700,12 +3886,16 @@ export class ScrollBar extends BaseSlider {
3700
3886
  private _borderColor;
3701
3887
  private _tempMeasure;
3702
3888
  private _invertScrollDirection;
3889
+ private _backgroundGradient;
3703
3890
  /** Gets or sets border color */
3704
3891
  get borderColor(): string;
3705
3892
  set borderColor(value: string);
3706
3893
  /** Gets or sets background color */
3707
3894
  get background(): string;
3708
3895
  set background(value: string);
3896
+ /** Gets or sets background gradient. Takes precedence over gradient. */
3897
+ get backgroundGradient(): Nullable<BaseGradient>;
3898
+ set backgroundGradient(value: Nullable<BaseGradient>);
3709
3899
  /** Inverts the scrolling direction (default: false) */
3710
3900
  get invertScrollDirection(): boolean;
3711
3901
  set invertScrollDirection(invert: boolean);
@@ -3716,6 +3906,7 @@ export class ScrollBar extends BaseSlider {
3716
3906
  constructor(name?: string | undefined);
3717
3907
  protected _getTypeName(): string;
3718
3908
  protected _getThumbThickness(): number;
3909
+ private _getBackgroundColor;
3719
3910
  _draw(context: ICanvasRenderingContext): void;
3720
3911
  private _first;
3721
3912
  private _originX;
@@ -3725,12 +3916,17 @@ export class ScrollBar extends BaseSlider {
3725
3916
  */
3726
3917
  protected _updateValueFromPointer(x: number, y: number): void;
3727
3918
  _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean;
3919
+ serialize(serializationObject: any): void;
3920
+ _parseFromContent(serializationObject: any, host: AdvancedDynamicTexture): void;
3728
3921
  }
3729
3922
 
3730
3923
  }
3731
3924
  declare module "babylonjs-gui/2D/controls/sliders/slider" {
3732
3925
  import { BaseSlider } from "babylonjs-gui/2D/controls/sliders/baseSlider";
3733
3926
  import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
3927
+ import { Nullable } from "babylonjs/types";
3928
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
3929
+ import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
3734
3930
  /**
3735
3931
  * Class used to create slider controls
3736
3932
  */
@@ -3741,6 +3937,7 @@ export class Slider extends BaseSlider {
3741
3937
  private _thumbColor;
3742
3938
  private _isThumbCircle;
3743
3939
  protected _displayValueBar: boolean;
3940
+ private _backgroundGradient;
3744
3941
  /** Gets or sets a boolean indicating if the value bar must be rendered */
3745
3942
  get displayValueBar(): boolean;
3746
3943
  set displayValueBar(value: boolean);
@@ -3750,6 +3947,9 @@ export class Slider extends BaseSlider {
3750
3947
  /** Gets or sets background color */
3751
3948
  get background(): string;
3752
3949
  set background(value: string);
3950
+ /** Gets or sets background gradient */
3951
+ get backgroundGradient(): Nullable<BaseGradient>;
3952
+ set backgroundGradient(value: Nullable<BaseGradient>);
3753
3953
  /** Gets or sets thumb's color */
3754
3954
  get thumbColor(): string;
3755
3955
  set thumbColor(value: string);
@@ -3762,7 +3962,11 @@ export class Slider extends BaseSlider {
3762
3962
  */
3763
3963
  constructor(name?: string | undefined);
3764
3964
  protected _getTypeName(): string;
3965
+ protected _getBackgroundColor(context: ICanvasRenderingContext): string | CanvasGradient;
3765
3966
  _draw(context: ICanvasRenderingContext): void;
3967
+ serialize(serializationObject: any): void;
3968
+ /** @internal */
3969
+ _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
3766
3970
  }
3767
3971
 
3768
3972
  }
@@ -3885,6 +4089,7 @@ export class TextBlock extends Control {
3885
4089
  private _underline;
3886
4090
  private _lineThrough;
3887
4091
  private _wordDivider;
4092
+ private _forceResizeWidth;
3888
4093
  /**
3889
4094
  * An event triggered after the text is changed
3890
4095
  */
@@ -3989,6 +4194,13 @@ export class TextBlock extends Control {
3989
4194
  * Gets or sets word divider
3990
4195
  */
3991
4196
  set wordDivider(value: string);
4197
+ /**
4198
+ * By default, if a text block has text wrapping other than Clip, its width
4199
+ * is not resized even if resizeToFit = true. This parameter forces the width
4200
+ * to be resized.
4201
+ */
4202
+ get forceResizeWidth(): boolean;
4203
+ set forceResizeWidth(value: boolean);
3992
4204
  /**
3993
4205
  * Creates a new TextBlock object
3994
4206
  * @param name defines the name of the control
@@ -9072,6 +9284,7 @@ declare module BABYLON.GUI {
9072
9284
  * @internal
9073
9285
  */
9074
9286
  _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
9287
+ protected _getRectangleFill(context: BABYLON.ICanvasRenderingContext): string | import("core/Engines/ICanvas").ICanvasGradient;
9075
9288
  /**
9076
9289
  * @internal
9077
9290
  */
@@ -9275,6 +9488,8 @@ declare module BABYLON.GUI {
9275
9488
  /** @internal */
9276
9489
  protected _background: string;
9277
9490
  /** @internal */
9491
+ protected _backgroundGradient: BABYLON.Nullable<BaseGradient>;
9492
+ /** @internal */
9278
9493
  protected _adaptWidthToChildren: boolean;
9279
9494
  /** @internal */
9280
9495
  protected _adaptHeightToChildren: boolean;
@@ -9302,6 +9517,9 @@ declare module BABYLON.GUI {
9302
9517
  /** Gets or sets background color */
9303
9518
  get background(): string;
9304
9519
  set background(value: string);
9520
+ /** Gets or sets background gradient color. Takes precedence over background */
9521
+ get backgroundGradient(): BABYLON.Nullable<BaseGradient>;
9522
+ set backgroundGradient(value: BABYLON.Nullable<BaseGradient>);
9305
9523
  /** Gets the list of children */
9306
9524
  get children(): Control[];
9307
9525
  get isReadOnly(): boolean;
@@ -9371,6 +9589,7 @@ declare module BABYLON.GUI {
9371
9589
  _offsetTop(offset: number): void;
9372
9590
  /** @internal */
9373
9591
  _markAllAsDirty(): void;
9592
+ protected _getBackgroundColor(context: BABYLON.ICanvasRenderingContext): string | BABYLON.ICanvasGradient;
9374
9593
  /**
9375
9594
  * @internal
9376
9595
  */
@@ -9512,6 +9731,7 @@ declare module BABYLON.GUI {
9512
9731
  protected _disabledColor: string;
9513
9732
  protected _disabledColorItem: string;
9514
9733
  protected _isReadOnly: boolean;
9734
+ private _gradient;
9515
9735
  /** @internal */
9516
9736
  protected _rebuildLayout: boolean;
9517
9737
  /** @internal */
@@ -9781,6 +10001,9 @@ declare module BABYLON.GUI {
9781
10001
  /** Gets or sets foreground color */
9782
10002
  get color(): string;
9783
10003
  set color(value: string);
10004
+ /** Gets or sets gradient. Setting a gradient will override the color */
10005
+ get gradient(): BABYLON.Nullable<BaseGradient>;
10006
+ set gradient(value: BABYLON.Nullable<BaseGradient>);
9784
10007
  /** Gets or sets z index which is used to reorder controls on the z axis */
9785
10008
  get zIndex(): number;
9786
10009
  set zIndex(value: number);
@@ -10077,6 +10300,7 @@ declare module BABYLON.GUI {
10077
10300
  * @internal
10078
10301
  */
10079
10302
  _renderHighlightSpecific(context: BABYLON.ICanvasRenderingContext): void;
10303
+ protected _getColor(context: BABYLON.ICanvasRenderingContext): string | BABYLON.ICanvasGradient;
10080
10304
  /**
10081
10305
  * @internal
10082
10306
  */
@@ -10388,6 +10612,162 @@ declare module BABYLON.GUI {
10388
10612
  }
10389
10613
 
10390
10614
 
10615
+ /**
10616
+ * Type that represents a single stop on the gradient.
10617
+ */
10618
+ export type GradientColorStop = {
10619
+ /**
10620
+ * Offset from the start where the color will be applied.
10621
+ */
10622
+ offset: number;
10623
+ /**
10624
+ * Color to be applied.
10625
+ */
10626
+ color: string;
10627
+ };
10628
+ /**
10629
+ * Class that serves as a base for all the gradients created from context.
10630
+ */
10631
+ export abstract class BaseGradient {
10632
+ private _colorStops;
10633
+ private _canvasGradient;
10634
+ private _context;
10635
+ private _gradientDirty;
10636
+ /**
10637
+ * Overwritten by child classes to create the canvas gradient.
10638
+ * @param context
10639
+ */
10640
+ protected abstract _createCanvasGradient(context: BABYLON.ICanvasRenderingContext): BABYLON.ICanvasGradient;
10641
+ private _addColorStopsToCanvasGradient;
10642
+ /**
10643
+ * If there are any changes or the context changed, regenerate the canvas gradient object. Else,
10644
+ * reuse the existing gradient.
10645
+ **/
10646
+ getCanvasGradient(context: BABYLON.ICanvasRenderingContext): CanvasGradient;
10647
+ /**
10648
+ * Adds a new color stop to the gradient.
10649
+ * @param offset the offset of the stop on the gradient. Should be between 0 and 1
10650
+ * @param color the color of the stop
10651
+ */
10652
+ addColorStop(offset: number, color: string): void;
10653
+ /**
10654
+ * Removes an existing color stop with the specified offset from the gradient
10655
+ * @param offset the offset of the stop to be removed
10656
+ */
10657
+ removeColorStop(offset: number): void;
10658
+ /**
10659
+ * Removes all color stops from the gradient
10660
+ */
10661
+ clearColorStops(): void;
10662
+ /** Color stops of the gradient */
10663
+ get colorStops(): GradientColorStop[];
10664
+ /** Type of the gradient */
10665
+ getClassName(): string;
10666
+ /** Serialize into a json object */
10667
+ serialize(serializationObject: any): void;
10668
+ /** Parse from json object */
10669
+ parse(serializationObject: any): void;
10670
+ }
10671
+
10672
+
10673
+ /**
10674
+ * Gradient along a line that connects two coordinates.
10675
+ * These coordinates are relative to the canvas' space, not to any control's space.
10676
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
10677
+ */
10678
+ export class LinearGradient extends BaseGradient {
10679
+ private _x0;
10680
+ private _y0;
10681
+ private _x1;
10682
+ private _y1;
10683
+ /**
10684
+ * Creates a new linear gradient
10685
+ * @param x0
10686
+ * @param y0
10687
+ * @param x1
10688
+ * @param y1
10689
+ */
10690
+ constructor(x0?: number, y0?: number, x1?: number, y1?: number);
10691
+ protected _createCanvasGradient(context: BABYLON.ICanvasRenderingContext): BABYLON.ICanvasGradient;
10692
+ /** X axis coordinate of the starting point in the line */
10693
+ get x0(): number;
10694
+ /** X axis coordinate of the ending point in the line */
10695
+ get x1(): number;
10696
+ /** Y axis coordinate of the starting point in the line */
10697
+ get y0(): number;
10698
+ /** Y axis coordinate of the ending point in the line */
10699
+ get y1(): number;
10700
+ /**
10701
+ * Class name of the gradient
10702
+ * @returns the class name of the gradient
10703
+ */
10704
+ getClassName(): string;
10705
+ /**
10706
+ * Serializes this gradient
10707
+ * @param serializationObject the object to serialize to
10708
+ */
10709
+ serialize(serializationObject: any): void;
10710
+ /**
10711
+ * Parses a gradient from a serialization object
10712
+ * @param serializationObject the object to parse from
10713
+ */
10714
+ parse(serializationObject: any): void;
10715
+ }
10716
+
10717
+
10718
+ /**
10719
+ * Gradient formed from two circles with their own centers and radius.
10720
+ * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
10721
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
10722
+ */
10723
+ export class RadialGradient extends BaseGradient {
10724
+ private _x0;
10725
+ private _y0;
10726
+ private _r0;
10727
+ private _x1;
10728
+ private _y1;
10729
+ private _r1;
10730
+ /**
10731
+ * Creates a new radial gradient
10732
+ * @param x0 x coordinate of the first circle's center
10733
+ * @param y0 y coordinate of the first circle's center
10734
+ * @param r0 radius of the first circle
10735
+ * @param x1 x coordinate of the second circle's center
10736
+ * @param y1 y coordinate of the second circle's center
10737
+ * @param r1 radius of the second circle
10738
+ */
10739
+ constructor(x0?: number, y0?: number, r0?: number, x1?: number, y1?: number, r1?: number);
10740
+ protected _createCanvasGradient(context: BABYLON.ICanvasRenderingContext): BABYLON.ICanvasGradient;
10741
+ /** x coordinate of the first circle's center */
10742
+ get x0(): number;
10743
+ /** x coordinate of the second circle's center */
10744
+ get x1(): number;
10745
+ /** y coordinate of the first circle's center */
10746
+ get y0(): number;
10747
+ /** y coordinate of the second circle's center */
10748
+ get y1(): number;
10749
+ /** radius of the first circle */
10750
+ get r0(): number;
10751
+ /** radius of the second circle */
10752
+ get r1(): number;
10753
+ /**
10754
+ * Class name of the gradient
10755
+ * @returns the class name of the gradient
10756
+ */
10757
+ getClassName(): string;
10758
+ /**
10759
+ * Serializes this gradient
10760
+ * @param serializationObject the object to serialize to
10761
+ */
10762
+ serialize(serializationObject: any): void;
10763
+ /**
10764
+ * Parses a gradient from a serialization object
10765
+ * @param serializationObject the object to parse from
10766
+ */
10767
+ parse(serializationObject: any): void;
10768
+ }
10769
+
10770
+
10391
10771
  /**
10392
10772
  * Class used to create a 2D grid container
10393
10773
  */
@@ -11301,6 +11681,7 @@ declare module BABYLON.GUI {
11301
11681
  protected _computeAdditionnalOffsetX(): 1 | 0;
11302
11682
  /** @internal */
11303
11683
  protected _computeAdditionnalOffsetY(): 1 | 0;
11684
+ protected _getRectangleFill(context: BABYLON.ICanvasRenderingContext): string | BABYLON.ICanvasGradient;
11304
11685
  protected _localDraw(context: BABYLON.ICanvasRenderingContext): void;
11305
11686
  protected _additionalProcessing(parentMeasure: Measure, context: BABYLON.ICanvasRenderingContext): void;
11306
11687
  private _drawRoundedRect;
@@ -11959,12 +12340,16 @@ declare module BABYLON.GUI {
11959
12340
  private _borderColor;
11960
12341
  private _tempMeasure;
11961
12342
  private _invertScrollDirection;
12343
+ private _backgroundGradient;
11962
12344
  /** Gets or sets border color */
11963
12345
  get borderColor(): string;
11964
12346
  set borderColor(value: string);
11965
12347
  /** Gets or sets background color */
11966
12348
  get background(): string;
11967
12349
  set background(value: string);
12350
+ /** Gets or sets background gradient. Takes precedence over gradient. */
12351
+ get backgroundGradient(): BABYLON.Nullable<BaseGradient>;
12352
+ set backgroundGradient(value: BABYLON.Nullable<BaseGradient>);
11968
12353
  /** Inverts the scrolling direction (default: false) */
11969
12354
  get invertScrollDirection(): boolean;
11970
12355
  set invertScrollDirection(invert: boolean);
@@ -11975,6 +12360,7 @@ declare module BABYLON.GUI {
11975
12360
  constructor(name?: string | undefined);
11976
12361
  protected _getTypeName(): string;
11977
12362
  protected _getThumbThickness(): number;
12363
+ private _getBackgroundColor;
11978
12364
  _draw(context: BABYLON.ICanvasRenderingContext): void;
11979
12365
  private _first;
11980
12366
  private _originX;
@@ -11984,6 +12370,8 @@ declare module BABYLON.GUI {
11984
12370
  */
11985
12371
  protected _updateValueFromPointer(x: number, y: number): void;
11986
12372
  _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
12373
+ serialize(serializationObject: any): void;
12374
+ _parseFromContent(serializationObject: any, host: AdvancedDynamicTexture): void;
11987
12375
  }
11988
12376
 
11989
12377
 
@@ -11997,6 +12385,7 @@ declare module BABYLON.GUI {
11997
12385
  private _thumbColor;
11998
12386
  private _isThumbCircle;
11999
12387
  protected _displayValueBar: boolean;
12388
+ private _backgroundGradient;
12000
12389
  /** Gets or sets a boolean indicating if the value bar must be rendered */
12001
12390
  get displayValueBar(): boolean;
12002
12391
  set displayValueBar(value: boolean);
@@ -12006,6 +12395,9 @@ declare module BABYLON.GUI {
12006
12395
  /** Gets or sets background color */
12007
12396
  get background(): string;
12008
12397
  set background(value: string);
12398
+ /** Gets or sets background gradient */
12399
+ get backgroundGradient(): BABYLON.Nullable<BaseGradient>;
12400
+ set backgroundGradient(value: BABYLON.Nullable<BaseGradient>);
12009
12401
  /** Gets or sets thumb's color */
12010
12402
  get thumbColor(): string;
12011
12403
  set thumbColor(value: string);
@@ -12018,7 +12410,11 @@ declare module BABYLON.GUI {
12018
12410
  */
12019
12411
  constructor(name?: string | undefined);
12020
12412
  protected _getTypeName(): string;
12413
+ protected _getBackgroundColor(context: BABYLON.ICanvasRenderingContext): string | CanvasGradient;
12021
12414
  _draw(context: BABYLON.ICanvasRenderingContext): void;
12415
+ serialize(serializationObject: any): void;
12416
+ /** @internal */
12417
+ _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
12022
12418
  }
12023
12419
 
12024
12420
 
@@ -12128,6 +12524,7 @@ declare module BABYLON.GUI {
12128
12524
  private _underline;
12129
12525
  private _lineThrough;
12130
12526
  private _wordDivider;
12527
+ private _forceResizeWidth;
12131
12528
  /**
12132
12529
  * An event triggered after the text is changed
12133
12530
  */
@@ -12232,6 +12629,13 @@ declare module BABYLON.GUI {
12232
12629
  * Gets or sets word divider
12233
12630
  */
12234
12631
  set wordDivider(value: string);
12632
+ /**
12633
+ * By default, if a text block has text wrapping other than Clip, its width
12634
+ * is not resized even if resizeToFit = true. This parameter forces the width
12635
+ * to be resized.
12636
+ */
12637
+ get forceResizeWidth(): boolean;
12638
+ set forceResizeWidth(value: boolean);
12235
12639
  /**
12236
12640
  * Creates a new TextBlock object
12237
12641
  * @param name defines the name of the control