Skip to content
0.2.0-dev Download ZIP
116 lines ·5.4 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="Gradient" inherits="Resource" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A color transition.
5 </brief_description>
6 <description>
7 This resource describes a color transition by defining a set of colored points and how to interpolate between them.
8 See also [Curve] which supports more complex easing methods, but does not support colors.
9 </description>
10 <tutorials>
11 </tutorials>
12 <methods>
13 <method name="add_point">
14 <return type="void" />
15 <param index="0" name="offset" type="float" />
16 <param index="1" name="color" type="Color" />
17 <description>
18 Adds the specified color to the gradient, with the specified offset.
19 </description>
20 </method>
21 <method name="get_color">
22 <return type="Color" />
23 <param index="0" name="point" type="int" />
24 <description>
25 Returns the color of the gradient color at index [param point].
26 </description>
27 </method>
28 <method name="get_offset">
29 <return type="float" />
30 <param index="0" name="point" type="int" />
31 <description>
32 Returns the offset of the gradient color at index [param point].
33 </description>
34 </method>
35 <method name="get_point_count" qualifiers="const">
36 <return type="int" />
37 <description>
38 Returns the number of colors in the gradient.
39 </description>
40 </method>
41 <method name="remove_point">
42 <return type="void" />
43 <param index="0" name="point" type="int" />
44 <description>
45 Removes the color at index [param point].
46 </description>
47 </method>
48 <method name="reverse">
49 <return type="void" />
50 <description>
51 Reverses/mirrors the gradient.
52 [b]Note:[/b] This method mirrors all points around the middle of the gradient, which may produce unexpected results when [member interpolation_mode] is set to [constant GRADIENT_INTERPOLATE_CONSTANT].
53 </description>
54 </method>
55 <method name="sample">
56 <return type="Color" />
57 <param index="0" name="offset" type="float" />
58 <description>
59 Returns the interpolated color specified by [param offset]. [param offset] should be between [code]0.0[/code] and [code]1.0[/code] (inclusive). Using a value lower than [code]0.0[/code] will return the same color as [code]0.0[/code], and using a value higher than [code]1.0[/code] will return the same color as [code]1.0[/code]. If your input value is not within this range, consider using [method @GlobalScope.remap] on the input value with output values set to [code]0.0[/code] and [code]1.0[/code].
60 </description>
61 </method>
62 <method name="set_color">
63 <return type="void" />
64 <param index="0" name="point" type="int" />
65 <param index="1" name="color" type="Color" />
66 <description>
67 Sets the color of the gradient color at index [param point].
68 </description>
69 </method>
70 <method name="set_offset">
71 <return type="void" />
72 <param index="0" name="point" type="int" />
73 <param index="1" name="offset" type="float" />
74 <description>
75 Sets the offset for the gradient color at index [param point].
76 </description>
77 </method>
78 </methods>
79 <members>
80 <member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)">
81 Gradient's colors as a [PackedColorArray].
82 [b]Note:[/b] Setting this property updates all colors at once. To update any color individually use [method set_color].
83 </member>
84 <member name="interpolation_color_space" type="int" setter="set_interpolation_color_space" getter="get_interpolation_color_space" enum="Gradient.ColorSpace" default="0">
85 The color space used to interpolate between points of the gradient. It does not affect the returned colors, which will always use nonlinear sRGB encoding.
86 [b]Note:[/b] This setting has no effect when [member interpolation_mode] is set to [constant GRADIENT_INTERPOLATE_CONSTANT].
87 </member>
88 <member name="interpolation_mode" type="int" setter="set_interpolation_mode" getter="get_interpolation_mode" enum="Gradient.InterpolationMode" default="0">
89 The algorithm used to interpolate between points of the gradient.
90 </member>
91 <member name="offsets" type="PackedFloat32Array" setter="set_offsets" getter="get_offsets" default="PackedFloat32Array(0, 1)">
92 Gradient's offsets as a [PackedFloat32Array].
93 [b]Note:[/b] Setting this property updates all offsets at once. To update any offset individually use [method set_offset].
94 </member>
95 </members>
96 <constants>
97 <constant name="GRADIENT_INTERPOLATE_LINEAR" value="0" enum="InterpolationMode">
98 Linear interpolation.
99 </constant>
100 <constant name="GRADIENT_INTERPOLATE_CONSTANT" value="1" enum="InterpolationMode">
101 Constant interpolation, color changes abruptly at each point and stays uniform between. This might cause visible aliasing when used for a gradient texture in some cases.
102 </constant>
103 <constant name="GRADIENT_INTERPOLATE_CUBIC" value="2" enum="InterpolationMode">
104 Cubic interpolation.
105 </constant>
106 <constant name="GRADIENT_COLOR_SPACE_SRGB" value="0" enum="ColorSpace">
107 sRGB color space.
108 </constant>
109 <constant name="GRADIENT_COLOR_SPACE_LINEAR_SRGB" value="1" enum="ColorSpace">
110 Linear sRGB color space.
111 </constant>
112 <constant name="GRADIENT_COLOR_SPACE_OKLAB" value="2" enum="ColorSpace">
113 [url=https://bottosson.github.io/posts/oklab/]Oklab[/url] color space. This color space provides a smooth and uniform-looking transition between colors.
114 </constant>
115 </constants>
116</class>