Skip to content

Commit b8f53c6

Browse files
committed
Add ColorU::to_hex
1 parent 99c4c99 commit b8f53c6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pathfinder/common/color.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ struct ColorU {
7373

7474
ColorF to_f32() const;
7575

76+
std::string to_hex() const {
77+
char hex_color[8]; // #RRGGBB\0
78+
std::snprintf(hex_color, sizeof(hex_color), "#%02x%02x%02x", r_, g_, b_);
79+
return hex_color;
80+
}
81+
7682
ColorU apply_alpha(float alpha) const {
7783
alpha = clamp(alpha, 0.0f, 1.0f);
7884
auto new_color = *this;

0 commit comments

Comments
 (0)