Added the possibility to set the fields of the polygon class in a functional programming style
This commit is contained in:
parent
37198d4669
commit
48a1b3ade4
23
polygons.h
23
polygons.h
@ -1,8 +1,6 @@
|
|||||||
#ifndef POLYGONS_H_INCLUDED
|
#ifndef POLYGONS_H_INCLUDED
|
||||||
#define POLYGONS_H_INCLUDED
|
#define POLYGONS_H_INCLUDED
|
||||||
|
|
||||||
// extern ball spaceship;
|
|
||||||
|
|
||||||
#include "vec2d.h"
|
#include "vec2d.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
@ -15,6 +13,26 @@ class polygon {
|
|||||||
std::vector<vec2d> points;
|
std::vector<vec2d> points;
|
||||||
|
|
||||||
void draw(cairo_t* cr) const;
|
void draw(cairo_t* cr) const;
|
||||||
|
|
||||||
|
polygon& set_center(vec2d c) {
|
||||||
|
center = c;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
polygon& set_angle(double a) {
|
||||||
|
angle = a;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
polygon& translate(vec2d delta) {
|
||||||
|
center += delta;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
polygon& rotate(double delta) {
|
||||||
|
angle += delta;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern polygon* polygons;
|
extern polygon* polygons;
|
||||||
@ -22,7 +40,6 @@ extern uint n_polygons;
|
|||||||
|
|
||||||
extern void polygons_init_state();
|
extern void polygons_init_state();
|
||||||
extern void polygons_update_state();
|
extern void polygons_update_state();
|
||||||
// extern void polygon_control (double dx, double dy);
|
|
||||||
extern void polygons_draw(cairo_t* cr);
|
extern void polygons_draw(cairo_t* cr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user