@ringozz/godot 4.7.2-583 → 4.7.2-592
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/README.md +19 -1
- package/gen/classes/ArrayOccluder3D.ts +1 -1
- package/gen/classes/CPUParticles2D.ts +3 -3
- package/gen/classes/CPUParticles3D.ts +3 -3
- package/gen/classes/CSGPolygon3D.ts +1 -1
- package/gen/classes/CollisionPolygon2D.ts +1 -1
- package/gen/classes/CollisionPolygon3D.ts +1 -1
- package/gen/classes/ColorPalette.ts +1 -1
- package/gen/classes/ConcavePolygonShape2D.ts +1 -1
- package/gen/classes/ConcavePolygonShape3D.ts +1 -1
- package/gen/classes/ConvexPolygonShape2D.ts +1 -1
- package/gen/classes/ConvexPolygonShape3D.ts +1 -1
- package/gen/classes/FontVariation.ts +1 -1
- package/gen/classes/Gradient.ts +1 -1
- package/gen/classes/Line2D.ts +1 -1
- package/gen/classes/MultiMesh.ts +4 -4
- package/gen/classes/NavigationMesh.ts +1 -1
- package/gen/classes/NavigationObstacle2D.ts +1 -1
- package/gen/classes/NavigationObstacle3D.ts +1 -1
- package/gen/classes/NavigationPathQueryResult2D.ts +1 -1
- package/gen/classes/NavigationPathQueryResult3D.ts +1 -1
- package/gen/classes/NavigationPolygon.ts +1 -1
- package/gen/classes/OccluderPolygon2D.ts +1 -1
- package/gen/classes/Polygon2D.ts +3 -3
- package/gen/classes/PolygonOccluder3D.ts +1 -1
- package/gen/classes/Window.ts +1 -1
- package/gen/index.ts +0 -3
- package/gen/utility-functions.ts +114 -114
- package/gen/value-types/AABB.ts +267 -277
- package/gen/value-types/Basis.ts +313 -264
- package/gen/value-types/Color.ts +398 -268
- package/gen/value-types/Plane.ts +121 -125
- package/gen/value-types/Projection.ts +178 -126
- package/gen/value-types/Quaternion.ts +180 -179
- package/gen/value-types/Rect2.ts +169 -171
- package/gen/value-types/Rect2i.ts +148 -150
- package/gen/value-types/Transform2D.ts +192 -194
- package/gen/value-types/Transform3D.ts +133 -126
- package/gen/value-types/Vector2.ts +370 -354
- package/gen/value-types/Vector2i.ts +192 -191
- package/gen/value-types/Vector3.ts +354 -354
- package/gen/value-types/Vector3i.ts +187 -192
- package/gen/value-types/Vector4.ts +263 -274
- package/gen/value-types/Vector4i.ts +187 -198
- package/gen/value-types/index.ts +16 -16
- package/package.json +20 -4
- package/src/debug.ts +30 -27
- package/src/index.ts +0 -2
- package/src/runtime.ts +16 -7
package/gen/value-types/Color.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Auto-generated from extension_api.json - DO NOT EDIT
|
|
2
2
|
// Generated by dev/codegen.ts
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { _V } from '../../src/runtime.ts';
|
|
5
5
|
import type { GodotArray, GodotDictionary, PackedColorArray, Variant } from '../heap-types/index.ts';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -13,270 +13,400 @@ import type { GodotArray, GodotDictionary, PackedColorArray, Variant } from '../
|
|
|
13
13
|
* **Note:** In a boolean context, a Color will evaluate to `false` if it is equal to `Color(0, 0, 0, 1)` (opaque black). Otherwise, a Color will always evaluate to `true`.
|
|
14
14
|
* **Note:** In C#, color constants are defined in the `Colors` static class instead of {@link code skip-lint}Color. Additionally, named colors use `PascalCase` syntax instead of `UPPER_SNAKE_CASE`. For example, {@link code skip-lint}Color.ALICE_BLUE in GDScript is {@link code skip-lint}Colors.AliceBlue in C#.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
16
|
+
export type Color = [r: number, g: number, b: number, a?: number];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the color converted to a 32-bit integer in ARGB format (each component is 8 bits). ARGB is more compatible with DirectX.
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* ```gdscript
|
|
23
|
+
*
|
|
24
|
+
* var color = Color(1, 0.5, 0.2)
|
|
25
|
+
* print(color.to_argb32()) # Prints 4294934323
|
|
26
|
+
*
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function toArgb32(self: Color): number { return _V(20, 14286, self) as number; }
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the color converted to a 32-bit integer in ABGR format (each component is 8 bits). ABGR is the reversed version of the default RGBA format.
|
|
33
|
+
*
|
|
34
|
+
*
|
|
35
|
+
* ```gdscript
|
|
36
|
+
*
|
|
37
|
+
* var color = Color(1, 0.5, 0.2)
|
|
38
|
+
* print(color.to_abgr32()) # Prints 4281565439
|
|
39
|
+
*
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function toAbgr32(self: Color): number { return _V(20, 14284, self) as number; }
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Returns the color converted to a 32-bit integer in RGBA format (each component is 8 bits). RGBA is Godot's default format. This method is the inverse of {@link hex}.
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* ```gdscript
|
|
49
|
+
*
|
|
50
|
+
* var color = Color(1, 0.5, 0.2)
|
|
51
|
+
* print(color.to_rgba32()) # Prints 4286526463
|
|
52
|
+
*
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function toRgba32(self: Color): number { return _V(20, 14309, self) as number; }
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the color converted to a 64-bit integer in ARGB format (each component is 16 bits). ARGB is more compatible with DirectX.
|
|
59
|
+
*
|
|
60
|
+
*
|
|
61
|
+
* ```gdscript
|
|
62
|
+
*
|
|
63
|
+
* var color = Color(1, 0.5, 0.2)
|
|
64
|
+
* print(color.to_argb64()) # Prints -2147470541
|
|
65
|
+
*
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function toArgb64(self: Color): number { return _V(20, 14287, self) as number; }
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns the color converted to a 64-bit integer in ABGR format (each component is 16 bits). ABGR is the reversed version of the default RGBA format.
|
|
72
|
+
*
|
|
73
|
+
*
|
|
74
|
+
* ```gdscript
|
|
75
|
+
*
|
|
76
|
+
* var color = Color(1, 0.5, 0.2)
|
|
77
|
+
* print(color.to_abgr64()) # Prints -225178692812801
|
|
78
|
+
*
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export function toAbgr64(self: Color): number { return _V(20, 14285, self) as number; }
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns the color converted to a 64-bit integer in RGBA format (each component is 16 bits). RGBA is Godot's default format. This method is the inverse of {@link hex64}.
|
|
85
|
+
*
|
|
86
|
+
*
|
|
87
|
+
* ```gdscript
|
|
88
|
+
*
|
|
89
|
+
* var color = Color(1, 0.5, 0.2)
|
|
90
|
+
* print(color.to_rgba64()) # Prints -140736629309441
|
|
91
|
+
*
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function toRgba64(self: Color): number { return _V(20, 14310, self) as number; }
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns the color converted to an HTML hexadecimal color {@link String} in RGBA format, without the hash (`#`) prefix.
|
|
98
|
+
* Setting `withAlpha` to `false`, excludes alpha from the hexadecimal string, using RGB format instead of RGBA format.
|
|
99
|
+
*
|
|
100
|
+
*
|
|
101
|
+
* ```gdscript
|
|
102
|
+
*
|
|
103
|
+
* var white = Color(1, 1, 1, 0.5)
|
|
104
|
+
* var with_alpha = white.to_html() # Returns "ffffff7f"
|
|
105
|
+
* var without_alpha = white.to_html(false) # Returns "ffffff"
|
|
106
|
+
*
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export function toHtml(self: Color, withAlpha?: boolean /* = true */): string { return _V(20, 14297, self, withAlpha) as string; }
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns a new color with all components clamped between the components of `min` and `max`, by running {@link clamp} on each component.
|
|
113
|
+
*/
|
|
114
|
+
export function clamp(self: Color, min?: Color /* = Color(0, 0, 0, 0) */, max?: Color /* = Color(1, 1, 1, 1) */): Color { return _V(20, 2202, self, min, max) as Color; }
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns the color with its {@link r}, {@link g}, and {@link b} components inverted (`(1 - r, 1 - g, 1 - b, a)`).
|
|
118
|
+
*
|
|
119
|
+
*
|
|
120
|
+
* ```gdscript
|
|
121
|
+
*
|
|
122
|
+
* var black = Color.WHITE.inverted()
|
|
123
|
+
* var color = Color(0.3, 0.4, 0.9)
|
|
124
|
+
* var inverted_color = color.inverted() # Equivalent to `Color(0.7, 0.6, 0.1)`
|
|
125
|
+
*
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export function inverted(self: Color): Color { return _V(20, 7723, self) as Color; }
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Returns the linear interpolation between this color's components and `to`'s components. The interpolation factor `weight` should be between 0.0 and 1.0 (inclusive). See also {@link lerp}.
|
|
132
|
+
*
|
|
133
|
+
*
|
|
134
|
+
* ```gdscript
|
|
135
|
+
*
|
|
136
|
+
* var red = Color(1.0, 0.0, 0.0)
|
|
137
|
+
* var aqua = Color(0.0, 1.0, 0.8)
|
|
138
|
+
*
|
|
139
|
+
* red.lerp(aqua, 0.2) # Returns Color(0.8, 0.2, 0.16)
|
|
140
|
+
* red.lerp(aqua, 0.5) # Returns Color(0.5, 0.5, 0.4)
|
|
141
|
+
* red.lerp(aqua, 1.0) # Returns Color(0.0, 1.0, 0.8)
|
|
142
|
+
*
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export function lerp(self: Color, to: Color, weight: number): Color { return _V(20, 8548, self, to, weight) as Color; }
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Returns a new color resulting from making this color lighter by the specified `amount`, which should be a ratio from 0.0 to 1.0. See also {@link darkened}.
|
|
149
|
+
*
|
|
150
|
+
*
|
|
151
|
+
* ```gdscript
|
|
152
|
+
*
|
|
153
|
+
* var green = Color(0.0, 1.0, 0.0)
|
|
154
|
+
* var light_green = green.lightened(0.2) # 20% lighter than regular green
|
|
155
|
+
*
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export function lightened(self: Color, amount: number): Color { return _V(20, 8592, self, amount) as Color; }
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns a new color resulting from making this color darker by the specified `amount` (ratio from 0.0 to 1.0). See also {@link lightened}.
|
|
162
|
+
*
|
|
163
|
+
*
|
|
164
|
+
* ```gdscript
|
|
165
|
+
*
|
|
166
|
+
* var green = Color(0.0, 1.0, 0.0)
|
|
167
|
+
* var darkgreen = green.darkened(0.2) # 20% darker than regular green
|
|
168
|
+
*
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export function darkened(self: Color, amount: number): Color { return _V(20, 2651, self, amount) as Color; }
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Returns a new color resulting from overlaying this color over the given color. In a painting program, you can imagine it as the `over` color painted over this color (including alpha).
|
|
175
|
+
*
|
|
176
|
+
*
|
|
177
|
+
* ```gdscript
|
|
178
|
+
*
|
|
179
|
+
* var bg = Color(0.0, 1.0, 0.0, 0.5) # Green with alpha of 50%
|
|
180
|
+
* var fg = Color(1.0, 0.0, 0.0, 0.5) # Red with alpha of 50%
|
|
181
|
+
* var blended_color = bg.blend(fg) # Brown with alpha of 75%
|
|
182
|
+
*
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
export function blend(self: Color, over: Color): Color { return _V(20, 1787, self, over) as Color; }
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Returns the light intensity of the color, as a value between 0.0 and 1.0 (inclusive). This is useful when determining light or dark color. Colors with a luminance smaller than 0.5 can be generally considered dark.
|
|
189
|
+
* **Note:** {@link getLuminance} relies on the color using linear encoding to return an accurate relative luminance value. If the color uses the default nonlinear sRGB encoding, use {@link srgbToLinear} to convert it to linear encoding first.
|
|
190
|
+
*/
|
|
191
|
+
export function getLuminance(self: Color): number { return _V(20, 5427, self) as number; }
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Returns a copy of the color that uses linear encoding. This method requires the original color to be encoded using the [nonlinear sRGB transfer function](https://en.wikipedia.org/wiki/SRGB). See also {@link linearToSrgb} which performs the opposite operation.
|
|
195
|
+
* **Note:** The color's alpha channel ({@link a}) is not affected. The alpha channel is always stored with linear encoding, regardless of the color space of the other color channels.
|
|
196
|
+
*/
|
|
197
|
+
export function srgbToLinear(self: Color): Color { return _V(20, 13806, self) as Color; }
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Returns a copy of the color that is encoded using the [nonlinear sRGB transfer function](https://en.wikipedia.org/wiki/SRGB). This method requires the original color to use linear encoding. See also {@link srgbToLinear} which performs the opposite operation.
|
|
201
|
+
* **Note:** The color's alpha channel ({@link a}) is not affected. The alpha channel is always stored with linear encoding, regardless of the color space of the other color channels.
|
|
202
|
+
*/
|
|
203
|
+
export function linearToSrgb(self: Color): Color { return _V(20, 8634, self) as Color; }
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns `true` if this color and `to` are approximately equal, by running {@link isEqualApprox} on each component.
|
|
207
|
+
*/
|
|
208
|
+
export function isEqualApprox(self: Color, to: Color): boolean { return _V(20, 7938, self, to) as boolean; }
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Returns the {@link Color} associated with the provided `hex` integer in 32-bit RGBA format (8 bits per channel). This method is the inverse of {@link toRgba32}.
|
|
212
|
+
* In GDScript and C#, the {@link int} is best visualized with hexadecimal notation (`"0x"` prefix, making it `"0xRRGGBBAA"`).
|
|
213
|
+
*
|
|
214
|
+
*
|
|
215
|
+
* ```gdscript
|
|
216
|
+
*
|
|
217
|
+
* var red = Color.hex(0xff0000ff)
|
|
218
|
+
* var dark_cyan = Color.hex(0x008b8bff)
|
|
219
|
+
* var my_color = Color.hex(0xbbefd2a4)
|
|
220
|
+
*
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
*
|
|
224
|
+
*
|
|
225
|
+
* If you want to use hex notation in a constant expression, use the equivalent constructor instead (i.e. `Color(0xRRGGBBAA)`).
|
|
226
|
+
*/
|
|
227
|
+
export function hex(hex: number): Color { return _V(20, 7504, undefined, hex) as Color; }
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Returns the {@link Color} associated with the provided `hex` integer in 64-bit RGBA format (16 bits per channel). This method is the inverse of {@link toRgba64}.
|
|
231
|
+
* In GDScript and C#, the {@link int} is best visualized with hexadecimal notation (`"0x"` prefix, making it `"0xRRRRGGGGBBBBAAAA"`).
|
|
232
|
+
*/
|
|
233
|
+
export function hex64(hex: number): Color { return _V(20, 7505, undefined, hex) as Color; }
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Returns a new color from `rgba`, an HTML hexadecimal color string. `rgba` is not case-sensitive, and may be prefixed by a hash sign (`#`).
|
|
237
|
+
* `rgba` must be a valid three-digit or six-digit hexadecimal color string, and may contain an alpha channel value. If `rgba` does not contain an alpha channel value, an alpha channel value of 1.0 is applied. If `rgba` is invalid, returns an empty color.
|
|
238
|
+
*
|
|
239
|
+
*
|
|
240
|
+
* ```gdscript
|
|
241
|
+
*
|
|
242
|
+
* var blue = Color.html("#0000ff") # blue is Color(0.0, 0.0, 1.0, 1.0)
|
|
243
|
+
* var green = Color.html("#0F0") # green is Color(0.0, 1.0, 0.0, 1.0)
|
|
244
|
+
* var col = Color.html("663399cc") # col is Color(0.4, 0.2, 0.6, 0.8)
|
|
245
|
+
*
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
export function html(rgba: string): Color { return _V(20, 7542, undefined, rgba) as Color; }
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns `true` if `color` is a valid HTML hexadecimal color string. The string must be a hexadecimal value (case-insensitive) of either 3, 4, 6 or 8 digits, and may be prefixed by a hash sign (`#`). This method is identical to {@link String.isValidHtmlColor}.
|
|
252
|
+
*
|
|
253
|
+
*
|
|
254
|
+
* ```gdscript
|
|
255
|
+
*
|
|
256
|
+
* Color.html_is_valid("#55aaFF") # Returns true
|
|
257
|
+
* Color.html_is_valid("#55AAFF20") # Returns true
|
|
258
|
+
* Color.html_is_valid("55AAFF") # Returns true
|
|
259
|
+
* Color.html_is_valid("#F2C") # Returns true
|
|
260
|
+
*
|
|
261
|
+
* Color.html_is_valid("#AABBC") # Returns false
|
|
262
|
+
* Color.html_is_valid("#55aaFF5") # Returns false
|
|
263
|
+
*
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export function htmlIsValid(color: string): boolean { return _V(20, 7543, undefined, color) as boolean; }
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Creates a {@link Color} from the given string, which can be either an HTML color code or a named color (case-insensitive). Returns `default` if the color cannot be inferred from the string.
|
|
270
|
+
* If you want to create a color from String in a constant expression, use the equivalent constructor instead (i.e. `Color("color string")`).
|
|
271
|
+
*/
|
|
272
|
+
export function fromString(str: string, _default: Color): Color { return _V(20, 3605, undefined, str, _default) as Color; }
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Constructs a color from an [HSV profile](https://en.wikipedia.org/wiki/HSL_and_HSV). The hue (`h`), saturation (`s`), and value (`v`) are typically between 0.0 and 1.0.
|
|
276
|
+
*
|
|
277
|
+
*
|
|
278
|
+
* ```gdscript
|
|
279
|
+
*
|
|
280
|
+
* var color = Color.from_hsv(0.58, 0.5, 0.79, 0.8)
|
|
281
|
+
*
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
export function fromHsv(h: number, s: number, v: number, alpha?: number /* = 1.0 */): Color { return _V(20, 3596, undefined, h, s, v, alpha) as Color; }
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Constructs a color from an [OK HSL profile](https://bottosson.github.io/posts/colorpicker/). The hue (`h`), saturation (`s`), and lightness (`l`) are typically between 0.0 and 1.0.
|
|
288
|
+
*
|
|
289
|
+
*
|
|
290
|
+
* ```gdscript
|
|
291
|
+
*
|
|
292
|
+
* var color = Color.from_ok_hsl(0.58, 0.5, 0.79, 0.8)
|
|
293
|
+
*
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export function fromOkHsl(h: number, s: number, l: number, alpha?: number /* = 1.0 */): Color { return _V(20, 3600, undefined, h, s, l, alpha) as Color; }
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Decodes a {@link Color} from an RGBE9995 format integer. See {@link Image.FORMAT_RGBE9995}.
|
|
300
|
+
*/
|
|
301
|
+
export function fromRgbe9995(rgbe: number): Color { return _V(20, 3603, undefined, rgbe) as Color; }
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Returns a {@link Color} constructed from red (`r8`), green (`g8`), blue (`b8`), and optionally alpha (`a8`) integer channels, each divided by `255.0` for their final value.
|
|
305
|
+
*
|
|
306
|
+
* ```text
|
|
307
|
+
*
|
|
308
|
+
* var red = Color.from_rgba8(255, 0, 0) # Same as Color(1, 0, 0).
|
|
309
|
+
* var dark_blue = Color.from_rgba8(0, 0, 51) # Same as Color(0, 0, 0.2).
|
|
310
|
+
* var my_color = Color.from_rgba8(306, 255, 0, 102) # Same as Color(1.2, 1, 0, 0.4).
|
|
311
|
+
*
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* **Note:** Due to the lower precision of {@link fromRgba8} compared to the standard {@link Color} constructor, a color created with {@link fromRgba8} will generally not be equal to the same color created with the standard {@link Color} constructor. Use {@link isEqualApprox} for comparisons to avoid issues with floating-point precision error.
|
|
315
|
+
*/
|
|
316
|
+
export function fromRgba8(r8: number, g8: number, b8: number, a8?: number /* = 255 */): Color { return _V(20, 3602, undefined, r8, g8, b8, a8) as Color; }
|
|
317
|
+
|
|
318
|
+
export function equals(a: Color, b: Variant | Color): boolean { return _V(20, -1, a, b) as boolean; }
|
|
319
|
+
|
|
320
|
+
export function notEquals(a: Color, b: Variant | Color): boolean { return _V(20, -2, a, b) as boolean; }
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Inverts the given color. This is equivalent to `Color.WHITE - c` or `Color(1 - c.r, 1 - c.g, 1 - c.b, 1 - c.a)`. Unlike with {@link inverted}, the {@link a} component is inverted, too.
|
|
324
|
+
*/
|
|
325
|
+
export function neg(self: Color): Color { return _V(20, -11, self, undefined) as Color; }
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Returns the same value as if the `+` was not there. Unary `+` does nothing, but sometimes it can make your code more readable.
|
|
329
|
+
*/
|
|
330
|
+
export function pos(self: Color): Color { return _V(20, -12, self, undefined) as Color; }
|
|
331
|
+
|
|
332
|
+
export function not(self: Color): boolean { return _V(20, -24, self, undefined) as boolean; }
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Multiplies each component of the {@link Color} by the given {@link int}.
|
|
336
|
+
*/
|
|
337
|
+
export function mul(a: Color, b: number | Color): Color { return _V(20, -9, a, b) as Color; }
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Divides each component of the {@link Color} by the given {@link int}.
|
|
341
|
+
*/
|
|
342
|
+
export function div(a: Color, b: number | Color): Color { return _V(20, -10, a, b) as Color; }
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Adds each component of the {@link Color} with the components of the given {@link Color}.
|
|
346
|
+
*/
|
|
347
|
+
export function add(a: Color, b: Color): Color { return _V(20, -7, a, b) as Color; }
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Subtracts each component of the {@link Color} by the components of the given {@link Color}.
|
|
351
|
+
*/
|
|
352
|
+
export function sub(a: Color, b: Color): Color { return _V(20, -8, a, b) as Color; }
|
|
353
|
+
|
|
354
|
+
export function contains(a: Color, b: GodotDictionary | GodotArray | PackedColorArray): boolean { return _V(20, -25, a, b) as boolean; }
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Constructs a default {@link Color} from opaque black. This is the same as {@link BLACK}.
|
|
358
|
+
* **Note:** In C#, this constructs a {@link Color} with all of its components set to `0.0` (transparent black).
|
|
359
|
+
*/
|
|
360
|
+
export function create(): Color { return _V(20, -4096, 0) as Color; }
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Constructs a {@link Color} as a copy of the given {@link Color}.
|
|
364
|
+
*/
|
|
365
|
+
export function fromColor(from: Color): Color { return _V(20, -4096, 1, from) as Color; }
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Constructs a {@link Color} from the existing color, with {@link a} set to the given `alpha` value.
|
|
369
|
+
*
|
|
370
|
+
*
|
|
371
|
+
* ```gdscript
|
|
372
|
+
*
|
|
373
|
+
* var red = Color(Color.RED, 0.2) # 20% opaque red.
|
|
374
|
+
*
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
export function fromAlpha(from: Color, alpha: number): Color { return _V(20, -4096, 2, from, alpha) as Color; }
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Constructs a {@link Color} from RGB values, typically between 0.0 and 1.0. {@link a} is set to 1.0.
|
|
381
|
+
*
|
|
382
|
+
*
|
|
383
|
+
* ```gdscript
|
|
384
|
+
*
|
|
385
|
+
* var color = Color(0.2, 1.0, 0.7) # Similar to `Color.from_rgba8(51, 255, 178, 255)`
|
|
386
|
+
*
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
export function fromRGB(r: number, g: number, b: number): Color { return _V(20, -4096, 3, r, g, b) as Color; }
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Constructs a {@link Color} from RGBA values, typically between 0.0 and 1.0.
|
|
393
|
+
*
|
|
394
|
+
*
|
|
395
|
+
* ```gdscript
|
|
396
|
+
*
|
|
397
|
+
* var color = Color(0.2, 1.0, 0.7, 0.8) # Similar to `Color.from_rgba8(51, 255, 178, 204)`
|
|
398
|
+
*
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
export function fromRGBA(r: number, g: number, b: number, a: number): Color { return _V(20, -4096, 4, r, g, b, a) as Color; }
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Constructs a {@link Color} either from an HTML color code or from a standardized color name. The supported color names are the same as the constants.
|
|
405
|
+
*/
|
|
406
|
+
export function fromCode(code: string): Color { return _V(20, -4096, 5, code) as Color; }
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Constructs a {@link Color} either from an HTML color code or from a standardized color name, with `alpha` on the range of 0.0 to 1.0. The supported color names are the same as the constants.
|
|
410
|
+
*/
|
|
411
|
+
export function fromCodeAlpha(code: string, alpha: number): Color { return _V(20, -4096, 6, code, alpha) as Color; }
|
|
412
|
+
|