Added min-size and max-size params
This commit is contained in:
parent
172933a46e
commit
67c2038d1d
@ -56,6 +56,8 @@ class Grid : public ScreensaverPlugin {
|
|||||||
int _wait {7}; // seconds
|
int _wait {7}; // seconds
|
||||||
int _fade {3}; // seconds
|
int _fade {3}; // seconds
|
||||||
double _border {75};
|
double _border {75};
|
||||||
|
double _min_size {2};
|
||||||
|
double _max_size {50};
|
||||||
|
|
||||||
void animate();
|
void animate();
|
||||||
};
|
};
|
||||||
@ -87,11 +89,11 @@ void Grid::setup(cairo_t* context, const cairo_rectangle_t& rect) {
|
|||||||
Rect r;
|
Rect r;
|
||||||
r.cx = _border + h_margin + x * _d;
|
r.cx = _border + h_margin + x * _d;
|
||||||
r.cy = _border + v_margin + y * _d;
|
r.cy = _border + v_margin + y * _d;
|
||||||
r.width = 50;
|
r.width = random_between(_min_size, _max_size);
|
||||||
r.color = black;
|
r.color = black;
|
||||||
_old.rects.push_back(r);
|
_old.rects.push_back(r);
|
||||||
_cur.rects.push_back(r);
|
_cur.rects.push_back(r);
|
||||||
r.width = random_between(2, 50);
|
r.width = random_between(_min_size, _max_size);
|
||||||
r.color = sc::random::choice(_colors);
|
r.color = sc::random::choice(_colors);
|
||||||
_new.rects.push_back(r);
|
_new.rects.push_back(r);
|
||||||
}
|
}
|
||||||
@ -99,6 +101,8 @@ void Grid::setup(cairo_t* context, const cairo_rectangle_t& rect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Grid::configure() {
|
void Grid::configure() {
|
||||||
|
_min_size = _j["min-size"];
|
||||||
|
_max_size = _j["max-size"];
|
||||||
_d = _j["dist"];
|
_d = _j["dist"];
|
||||||
_wait = _j["wait"];
|
_wait = _j["wait"];
|
||||||
_fade = _j["fade"];
|
_fade = _j["fade"];
|
||||||
@ -108,6 +112,7 @@ void Grid::configure() {
|
|||||||
for (const auto& hex : _j["colors"]) {
|
for (const auto& hex : _j["colors"]) {
|
||||||
_colors.emplace_back(hex);
|
_colors.emplace_back(hex);
|
||||||
}
|
}
|
||||||
|
setup(_c, _r);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Grid::fps() const {
|
int Grid::fps() const {
|
||||||
@ -128,7 +133,7 @@ void Grid::update() {
|
|||||||
_frames = 0;
|
_frames = 0;
|
||||||
_old = _new;
|
_old = _new;
|
||||||
for (Rect& r : _new.rects) {
|
for (Rect& r : _new.rects) {
|
||||||
r.width = random_between(2, 50);
|
r.width = random_between(_min_size, _max_size);
|
||||||
r.color = sc::random::choice(_colors);
|
r.color = sc::random::choice(_colors);
|
||||||
}
|
}
|
||||||
_s = State::wait;
|
_s = State::wait;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user