diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-11-08 13:22:45 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-11-08 13:22:45 +0000 |
| commit | 880c6f67ca3637c54c97c51081e0649743292af3 (patch) | |
| tree | 872e4b351514bd4f34bcc569f63b0017d1afa779 /src/types.cc | |
| parent | badcfc45f972fef9e2ebb895965bfd4b971dd4a3 (diff) | |
Add Colour::to_rgb_string.
Diffstat (limited to 'src/types.cc')
| -rw-r--r-- | src/types.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/types.cc b/src/types.cc index 812e0f89..0347d02f 100644 --- a/src/types.cc +++ b/src/types.cc @@ -126,6 +126,17 @@ Colour::to_argb_string () const return buffer; } +/** @return An RGB string of the form RRGGBB, where e.g. RR is a two-character + * hex value. + */ +string +Colour::to_rgb_string () const +{ + char buffer[7]; + snprintf (buffer, sizeof(buffer), "%02X%02X%02X", r, g, b); + return buffer; +} + /** operator== for Colours. * @param a First colour to compare. * @param b Second colour to compare. |
