Constructor
new Style(coloropt, linear_gradientopt, radial_gradientopt, imageopt)
Creates a new Style with the given color, linear gradient, radial gradient, or image. It must have exactly one of these.
Name | Type | Attributes | Description |
---|---|---|---|
color | Color | | <optional> | The color of the style, if provided. |
linear_gradient | LinearGradient | | <optional> | The linear gradient of the style, if provided. |
radial_gradient | RadialGradient | | <optional> | The radial gradient of the style, if provided. |
image | ImageBitmap | | <optional> | The image of the style, if provided. |
- Source
Classes
Members
color
Gets the Color of the style, if it's a color.
- Source
color
Sets the style to a Color.
- Source
image
Gets the ImageBitmap of the style, if it's an image.
- Source
image
Sets the style to an ImageBitmap.
- Source
linear_gradient
Gets the LinearGradient of the style, if it's a linear gradient.
- Source
linear_gradient
Sets the style to a LinearGradient.
- Source
radial_gradient
Gets the RadialGradient of the style, if it's a radial gradient.
- Source
radial_gradient
Sets the style to a RadialGradient.
- Source
Methods
clone() → {Style}
Clones the Style.
- Source
The cloned style.
- Type:
- Style
color_at(p) → {Color}
Gets the Color at a given point.
Name | Type | Description |
---|---|---|
p | Point2D | The x coordinate of the point. |
- Source
The color at the given point.
- Type:
- Color
fade(amount) → {Style}
Fades the Style by a given amount.
Name | Type | Description |
---|---|---|
amount | number | The amount to fade the style by. |
- Source
The faded style.
- Type:
- Style
(static) default_style() → {Style}
Returns the default Style, which is a color with the default color.
- Source
The default style.
- Type:
- Style
(static) from_color(color) → {Style}
Creates a new Style with the given color.
Name | Type | Description |
---|---|---|
color | Color | The color of the style. |
- Source
A new style from the color.
- Type:
- Style
(static) from_image(image) → {Style}
Creates a new Style with the given image.
Name | Type | Description |
---|---|---|
image | ImageBitmap | The image of the style. |
- Source
A new style from the image.
- Type:
- Style
(static) from_linear_gradient(gradient) → {Style}
Creates a new Style with the given linear gradient.
Name | Type | Description |
---|---|---|
gradient | LinearGradient | The linear gradient of the style. |
- Source
A new style from the linear gradient.
- Type:
- Style
(static) from_radial_gradient(gradient) → {Style}
Creates a new Style with the given radial gradient.
Name | Type | Description |
---|---|---|
gradient | RadialGradient |
- Source
A new style from the radial gradient.
- Type:
- Style
(static) lerp(style1, style2, t, xopt, yopt, widthopt, heightopt, data_widthopt, data_heightopt) → {Style}
Linearly interpolates between two Styles given a progress value.
Name | Type | Attributes | Description |
---|---|---|---|
style1 | Style | The first style. | |
style2 | Style | The second style. | |
t | number | The progress value. | |
x | number | | <optional> | Top left x coordinate of the bitmap. Must be provided if both styles are images. |
y | number | | <optional> | Top left y coordinate of the bitmap. Must be provided if both styles are images. |
width | number | | <optional> | Width of the bitmap. Must be provided if both styles are images. |
height | number | | <optional> | Height of the bitmap. Must be provided if both styles are images. |
data_width | number | | <optional> | Number of pixels in a row of the bitmap. Must be provided if both styles are different kinds of gradients or one of them is an image. |
data_height | number | | <optional> | Number of pixels in a column of the bitmap. Must be provided if both styles are different kinds of gradients or one of them is an image. |
- Source
The interpolated style.
- Type:
- Style