Fix configuration step

This commit is contained in:
2025-10-26 23:09:09 +01:00
parent 6ed3bdb941
commit 6e1ddf1b86

View File

@@ -17,7 +17,6 @@ public:
Polygon() = default;
~Polygon() = default;
void setup(cairo_t *context, const cairo_rectangle_t &rect) override;
void configure() override;
int fps() const override;
void update() override;
@@ -25,7 +24,7 @@ public:
std::string version() const override;
private:
int _num_points {10};
int _num_points {};
double _min_speed {0.2};
double _max_speed {2.0};
double _stroke_width {1.0};
@@ -36,8 +35,13 @@ private:
ScreensaverPlugin *create_instance() { return new Polygon; }
void Polygon::setup(cairo_t* context, const cairo_rectangle_t& rect) {
ScreensaverPlugin::setup(context, rect);
void Polygon::configure() {
_num_points = _j["num-points"];
_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 = sc::random::double_between(0, _r.width);
@@ -50,16 +54,6 @@ void Polygon::setup(cairo_t* context, const cairo_rectangle_t& rect) {
}
}
void Polygon::configure() {
_num_points = _j["num-points"];
_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"];
setup(_c, _r);
}
std::string Polygon::version() const { return "1.0.0"; }
int Polygon::fps() const { return 30; }