Added comments to enhance readability

This commit is contained in:
Bob Polis 2021-08-18 12:28:27 +02:00
parent 5c699484ab
commit ab024a7ec0

View File

@ -53,20 +53,28 @@ void Huey::render() {
cairo_rectangle(_c, _r.x, _r.y, _r.width, _r.height);
cairo_fill(_c);
// show hue value
// build hue text
std::ostringstream hue_oss;
hue_oss << "hue: " << std::setw(3) << static_cast<int>(_hue);
// build rgb text
std::ostringstream rgb_oss;
rgb_oss << "red: " << std::setw(3) << static_cast<int>(255 * rgb.r);
rgb_oss << ", green: " << std::setw(3) << static_cast<int>(255 * rgb.g);
rgb_oss << ", blue: " << std::setw(3) << static_cast<int>(255 * rgb.b);
cairo_set_source_rgb(_c, 0, 0, 0);
// font setup
cairo_select_font_face(_c, "JuliaMono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(_c, 24);
// render hue and rgb texts in black (shadow)
cairo_set_source_rgb(_c, 0, 0, 0);
cairo_move_to(_c, 31, 51);
cairo_show_text(_c, hue_oss.str().c_str());
cairo_move_to(_c, 31, 87);
cairo_show_text(_c, rgb_oss.str().c_str());
// render hue and rgb texts in white, sligtly offset
cairo_set_source_rgb(_c, 1, 1, 1);
cairo_move_to(_c, 29, 49);
cairo_show_text(_c, hue_oss.str().c_str());