From 4954ef899b2b7ba7852da0897e2aef7eb23934cd Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Wed, 22 Nov 2023 23:27:10 +0000 Subject: [PATCH] Add option to enable/disable background change --- modules/Grid/Grid.cpp | 13 ++++++++----- modules/Grid/Grid.json | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/Grid/Grid.cpp b/modules/Grid/Grid.cpp index 7a233d9..1d4a59f 100644 --- a/modules/Grid/Grid.cpp +++ b/modules/Grid/Grid.cpp @@ -50,7 +50,7 @@ class Grid : public ScreensaverPlugin { double _border {75}; double _min_size {2}; double _max_size {50}; - + bool _change_bg {true}; void animate(); }; @@ -100,6 +100,7 @@ void Grid::configure() { _fade = _j["fade"]; _border = _j["border"]; _new.bg = Color {_j["bg"]}; + _change_bg = _j["changebg"]; _colors.clear(); for (const auto& hex : _j["colors"]) { _colors.emplace_back(hex); @@ -156,10 +157,12 @@ void Grid::render() { void Grid::animate() { double f {static_cast(_frames) / (_fade * fps())}; - RGB bg1 {RGB(_old.bg)}; - RGB bg2 {RGB(_new.bg)}; - RGB bg3 {bg1.r + f * (bg2.r - bg1.r), bg1.g + f * (bg2.g - bg1.g), bg1.b + f * (bg2.b - bg1.b)}; - _cur.bg = bg3; + if (_change_bg) { + RGB bg1 {RGB(_old.bg)}; + RGB bg2 {RGB(_new.bg)}; + RGB bg3 {bg1.r + f * (bg2.r - bg1.r), bg1.g + f * (bg2.g - bg1.g), bg1.b + f * (bg2.b - bg1.b)}; + _cur.bg = bg3; + } for (size_t i = 0; i < _old.rects.size(); ++i) { Rect& r1 = _old.rects[i]; Rect& r2 = _new.rects[i]; diff --git a/modules/Grid/Grid.json b/modules/Grid/Grid.json index bddd090..05670cf 100644 --- a/modules/Grid/Grid.json +++ b/modules/Grid/Grid.json @@ -6,6 +6,7 @@ "fade": 7, "border": 100.0, "bg": "#B1D1AF", + "changebg": false, "colors": [ "#FFE3BF", "#170D00",