diff --git a/modules/Polygon/Polygon.cpp b/modules/Polygon/Polygon.cpp index 254fe21..5e5ee41 100644 --- a/modules/Polygon/Polygon.cpp +++ b/modules/Polygon/Polygon.cpp @@ -30,6 +30,7 @@ private: Color _stroke_color {"#FFFFFF"}; Color _fill_color {"#606060"}; std::vector _points; + double _hue; }; ScreensaverPlugin *create_instance() { return new Polygon; } @@ -39,8 +40,6 @@ void Polygon::configure() { _min_speed = _j["min-speed"]; _max_speed = _j["max-speed"]; _stroke_width = _j["stroke-width"]; - _stroke_color = _j["stroke-color"]; - _fill_color = _j["fill-color"]; for (int i = 0; i < _num_points; ++i) { Point p; p.x = random_x(); @@ -51,6 +50,7 @@ void Polygon::configure() { p.speed_y *= random_bool() ? 1 : -1; _points.push_back(p); } + _hue = random_between(0.0, 360.0); } void Polygon::size_changed() { @@ -63,6 +63,7 @@ void Polygon::size_changed() { std::string Polygon::version() const { return "1.0.0"; } void Polygon::update() { + // update points for (Point& p : _points) { p.x += p.speed_x; if (p.x < 0 || p.x > _r.width) { @@ -75,6 +76,19 @@ void Polygon::update() { p.y += p.speed_y; } } + // update hue + _hue += 0.5; + if (_hue >= 360.0) { + _hue -= 360.0; + } + // construct stroke and fill colors + HSB hsb; + hsb.h = _hue; + hsb.s = 1.0; + hsb.b = 0.1; + _fill_color = hsb; + hsb.b = 0.7; + _stroke_color = hsb; } void Polygon::render() { diff --git a/modules/Polygon/Polygon.json b/modules/Polygon/Polygon.json index c969533..d0147c0 100644 --- a/modules/Polygon/Polygon.json +++ b/modules/Polygon/Polygon.json @@ -1,8 +1,6 @@ { - "num-points": 7, + "num-points": 42, "min-speed": 0.2, "max-speed": 2.0, - "stroke-width": 3.0, - "stroke-color": "#00D000", - "fill-color": "#006000" + "stroke-width": 3.0 }