Skip to content

Commit 04cdcf2

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

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/hello/print/fmt.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,19 @@ 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+
`RGB = (R*65536)+(G*256)+B , (when R is RED, G is GREEN and B is BLUE)`.
85+
For more see [RGB color format & calculation][rgb_color].
8386
* You [may need to list each color more than once][named_parameters].
8487
* You can [pad with zeros to a width of 2][fmt_width] with `:0>2`.
8588

8689
### See also:
8790

8891
[`std::fmt`][fmt]
8992

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

0 commit comments

Comments
 (0)