Skip to content

Commit a2f30ce

Browse files
committed
Hint for RGB color calculation
1 parent 57636d6 commit a2f30ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/hello/print/fmt.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,21 @@ RGB (0, 3, 254) 0x0003FE
7878
RGB (0, 0, 0) 0x000000
7979
```
8080

81-
Two hints if you get stuck:
81+
Three hints if you get stuck:
8282

83+
* The formula for calculating a color in the RGB color space is:
84+
```
85+
RGB = (R*65536)+(G*256)+B , (when R is RED, G is GREEN and B is BLUE)
86+
```
87+
For more see [RGB color format & calculation][rgb_color].
8388
* You [may need to list each color more than once][named_parameters].
8489
* You can [pad with zeros to a width of 2][fmt_width] with `:0>2`.
8590

8691
### See also:
8792

8893
[`std::fmt`][fmt]
8994

95+
[rgb_color]: https://www.rapidtables.com/web/color/RGB_Color.html#rgb-format
9096
[named_parameters]: https://doc.rust-lang.org/std/fmt/#named-parameters
9197
[deadbeef]: https://en.wikipedia.org/wiki/Deadbeef#Magic_debug_values
9298
[fmt]: https://doc.rust-lang.org/std/fmt/

0 commit comments

Comments
 (0)