Add option to enable/disable background change
This commit is contained in:
parent
de1f188a6d
commit
4954ef899b
@ -50,7 +50,7 @@ class Grid : public ScreensaverPlugin {
|
|||||||
double _border {75};
|
double _border {75};
|
||||||
double _min_size {2};
|
double _min_size {2};
|
||||||
double _max_size {50};
|
double _max_size {50};
|
||||||
|
bool _change_bg {true};
|
||||||
void animate();
|
void animate();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,6 +100,7 @@ void Grid::configure() {
|
|||||||
_fade = _j["fade"];
|
_fade = _j["fade"];
|
||||||
_border = _j["border"];
|
_border = _j["border"];
|
||||||
_new.bg = Color {_j["bg"]};
|
_new.bg = Color {_j["bg"]};
|
||||||
|
_change_bg = _j["changebg"];
|
||||||
_colors.clear();
|
_colors.clear();
|
||||||
for (const auto& hex : _j["colors"]) {
|
for (const auto& hex : _j["colors"]) {
|
||||||
_colors.emplace_back(hex);
|
_colors.emplace_back(hex);
|
||||||
@ -156,10 +157,12 @@ void Grid::render() {
|
|||||||
|
|
||||||
void Grid::animate() {
|
void Grid::animate() {
|
||||||
double f {static_cast<double>(_frames) / (_fade * fps())};
|
double f {static_cast<double>(_frames) / (_fade * fps())};
|
||||||
RGB bg1 {RGB(_old.bg)};
|
if (_change_bg) {
|
||||||
RGB bg2 {RGB(_new.bg)};
|
RGB bg1 {RGB(_old.bg)};
|
||||||
RGB bg3 {bg1.r + f * (bg2.r - bg1.r), bg1.g + f * (bg2.g - bg1.g), bg1.b + f * (bg2.b - bg1.b)};
|
RGB bg2 {RGB(_new.bg)};
|
||||||
_cur.bg = bg3;
|
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) {
|
for (size_t i = 0; i < _old.rects.size(); ++i) {
|
||||||
Rect& r1 = _old.rects[i];
|
Rect& r1 = _old.rects[i];
|
||||||
Rect& r2 = _new.rects[i];
|
Rect& r2 = _new.rects[i];
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"fade": 7,
|
"fade": 7,
|
||||||
"border": 100.0,
|
"border": 100.0,
|
||||||
"bg": "#B1D1AF",
|
"bg": "#B1D1AF",
|
||||||
|
"changebg": false,
|
||||||
"colors": [
|
"colors": [
|
||||||
"#FFE3BF",
|
"#FFE3BF",
|
||||||
"#170D00",
|
"#170D00",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user