Compare commits
3 Commits
38ee399483
...
62b10ca8d0
| Author | SHA1 | Date | |
|---|---|---|---|
| 62b10ca8d0 | |||
| 4ab4b99bd5 | |||
| f7db4d10ec |
@@ -1,7 +1,6 @@
|
||||
#include "Polygon.hpp"
|
||||
#include <cairo/cairo.h>
|
||||
#include <libsccolor.hpp>
|
||||
#include <libscnumerics.hpp>
|
||||
#include <libscscreensaver.hpp>
|
||||
#include <vector>
|
||||
|
||||
@@ -18,10 +17,10 @@ public:
|
||||
~Polygon() = default;
|
||||
|
||||
void configure() override;
|
||||
int fps() const override;
|
||||
void update() override;
|
||||
void render() override;
|
||||
std::string version() const override;
|
||||
void size_changed() override;
|
||||
|
||||
private:
|
||||
int _num_points {};
|
||||
@@ -29,7 +28,7 @@ private:
|
||||
double _max_speed {2.0};
|
||||
double _stroke_width {1.0};
|
||||
Color _stroke_color {"#FFFFFF"};
|
||||
Color _fill_color {"#006600"};
|
||||
Color _fill_color {"#606060"};
|
||||
std::vector<Point> _points;
|
||||
};
|
||||
|
||||
@@ -44,19 +43,24 @@ void Polygon::configure() {
|
||||
_fill_color = _j["fill-color"];
|
||||
for (int i = 0; i < _num_points; ++i) {
|
||||
Point p;
|
||||
p.x = sc::random::double_between(0, _r.width);
|
||||
p.y = sc::random::double_between(0, _r.height);
|
||||
p.speed_x = sc::random::double_between(_min_speed, _max_speed);
|
||||
p.speed_x *= sc::random::boolean() ? 1 : -1;
|
||||
p.speed_y = sc::random::double_between(_min_speed, _max_speed);
|
||||
p.speed_y *= sc::random::boolean() ? 1 : -1;
|
||||
p.x = random_x();
|
||||
p.y = random_y();
|
||||
p.speed_x = random_between(_min_speed, _max_speed);
|
||||
p.speed_x *= random_bool() ? 1 : -1;
|
||||
p.speed_y = random_between(_min_speed, _max_speed);
|
||||
p.speed_y *= random_bool() ? 1 : -1;
|
||||
_points.push_back(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Polygon::version() const { return "1.0.0"; }
|
||||
void Polygon::size_changed() {
|
||||
for (Point &p : _points) {
|
||||
p.x = random_x();
|
||||
p.y = random_y();
|
||||
}
|
||||
}
|
||||
|
||||
int Polygon::fps() const { return 30; }
|
||||
std::string Polygon::version() const { return "1.0.0"; }
|
||||
|
||||
void Polygon::update() {
|
||||
for (Point& p : _points) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
LDLIBS := -lcairo -lscscreensaver -lsccolor -lscnumerics
|
||||
LDLIBS := -lcairo -lscscreensaver -lsccolor
|
||||
UNAME_S := $(shell uname -s)
|
||||
PROJ := $(shell basename $$(pwd))
|
||||
PLUGIN := $(PROJ).saver
|
||||
|
||||
@@ -73,6 +73,7 @@ bool handle_window_resize(const SDL_Event& event, bool quit) {
|
||||
cairo_rectangle_t r {0, 0, static_cast<double>(event.window.data1), static_cast<double>(event.window.data2)};
|
||||
if (main_saver) {
|
||||
main_saver->setup(main_context.get(), r);
|
||||
main_saver->size_changed();
|
||||
}
|
||||
}
|
||||
return quit;
|
||||
|
||||
Reference in New Issue
Block a user