made animation smoother; cleaner code

This commit is contained in:
Bob Polis 2020-10-28 16:29:35 +01:00
parent 1ee2e636eb
commit d8c1c535f2

View File

@ -32,22 +32,28 @@ void Skembo::setup(cairo_t* context, const cairo_rectangle_t& rect) {
}
int Skembo::fps() const {
return 20;
return 40;
}
void Skembo::draw_frame() {
// std::uniform_real_distribution<double> dist {};
// next color
HSB hsb;
hsb.h = _hue;
hsb.s = 1;//dist(_eng);
hsb.b = 0.4;//dist(_eng);
hsb.s = 1.0;
hsb.b = 0.4;
// convert to rgb
Color color {hsb};
RGB rgb {RGB(color)};
// setup color, fill whole window
cairo_set_source_rgb(_c, rgb.r, rgb.g, rgb.b);
cairo_rectangle(_c, _r.x, _r.y, _r.width, _r.height);
cairo_fill(_c);
_hue += 1.0;
// update for next frame
_hue += 0.5;
if (_hue > 360.0) {
_hue = 0.0;
_hue -= 360.0;
}
}