Use transparency for the fill color

This commit is contained in:
2025-10-29 11:21:34 +01:00
parent 43363b53b7
commit ffda761acc
2 changed files with 7 additions and 11 deletions

View File

@@ -27,8 +27,7 @@ private:
double _min_speed {0.2};
double _max_speed {2.0};
double _stroke_width {1.0};
Color _stroke_color {"#FFFFFF"};
Color _fill_color {"#606060"};
Color _color {"#FFFFFF"};
std::vector<Point> _points;
double _hue;
};
@@ -81,14 +80,12 @@ void Polygon::update() {
if (_hue >= 360.0) {
_hue -= 360.0;
}
// construct stroke and fill colors
// construct color
HSB hsb;
hsb.h = _hue;
hsb.s = 1.0;
hsb.b = 0.1;
_fill_color = hsb;
hsb.b = 0.7;
_stroke_color = hsb;
_color = hsb;
}
void Polygon::render() {
@@ -101,11 +98,10 @@ void Polygon::render() {
cairo_line_to(_c, p.x, p.y);
}
cairo_close_path(_c);
RGB c = RGB(_stroke_color);
RGB c = RGB(_color);
cairo_set_source_rgb(_c, c.r, c.g, c.b);
cairo_set_line_width(_c, _stroke_width);
cairo_stroke_preserve(_c);
RGB f = RGB(_fill_color);
cairo_set_source_rgb(_c, f.r, f.g, f.b);
cairo_set_source_rgba(_c, c.r, c.g, c.b, 0.2);
cairo_fill(_c);
}

View File

@@ -1,6 +1,6 @@
{
"num-points": 42,
"num-points": 11,
"min-speed": 0.2,
"max-speed": 2.0,
"stroke-width": 3.0
"stroke-width": 2.0
}