Skip to content

Commit d512dcc

Browse files
committed
Color doc amendments
1 parent d3511ed commit d512dcc

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

gdnative-core/src/core_types/color.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::sys;
33
use std::mem::transmute;
44

55
use crate::core_types::GodotString;
6-
/// RGBA color with 32 bits floating point components.
6+
7+
/// RGBA color with 32-bit floating point components.
78
#[repr(C)]
89
#[derive(Copy, Clone, Debug, PartialEq)]
910
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
@@ -43,20 +44,22 @@ impl Color {
4344

4445
/// Parses from a HTML color code, or `None` on parse error.
4546
///
47+
/// Note that unlike most other constructors, this has `ARGB` and not `RGBA` format.
48+
/// In particular, `from_html("AB123456")` would correspond to `from_rgba_u32(0x123456AB)`.
49+
///
4650
/// ```
4751
/// use gdnative::prelude::Color;
4852
///
49-
/// // Each of the following creates the same color RGBA(178, 217, 10, 255).
5053
/// let c1 = Color::from_html("#9eb2d90a"); // ARGB format with "#".
5154
/// let c2 = Color::from_html("9eb2d90a"); // ARGB format.
5255
/// let c3 = Color::from_html("#b2d90a"); // RGB format with "#".
5356
/// let c4 = Color::from_html("b2d90a"); // RGB format.
5457
///
55-
/// let expected = Color::from_rgba_u8(178, 217, 10, 158);
58+
/// let expected = Color::from_rgba_u8(0xb2, 0xd9, 0x0a, 0x9e);
5659
/// assert_eq!(c1, Some(expected));
5760
/// assert_eq!(c2, Some(expected));
5861
///
59-
/// let expected = Color::from_rgba_u8(178, 217, 10, 255);
62+
/// let expected = Color::from_rgba_u8(0xb2, 0xd9, 0x0a, 0xff);
6063
/// assert_eq!(c3, Some(expected));
6164
/// assert_eq!(c4, Some(expected));
6265
/// ```
@@ -112,7 +115,8 @@ impl Color {
112115

113116
/// Constructs a color from four integer channels, each in range 0-255.
114117
///
115-
/// This corresponds to the [GDScript method `Color8`](https://docs.godotengine.org/en/stable/classes/class_%40gdscript.html#class-gdscript-method-color8)
118+
/// This corresponds to the
119+
/// [GDScript method `Color8`](https://docs.godotengine.org/en/stable/classes/class_%40gdscript.html#class-gdscript-method-color8).
116120
#[inline]
117121
pub fn from_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Self {
118122
Self::from_rgba(

0 commit comments

Comments
 (0)