From 48a1b3ade4eff02dc6c8abfdbb9f1342f0c4ab82 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Tue, 14 Mar 2023 23:09:48 +0100 Subject: [PATCH] Added the possibility to set the fields of the polygon class in a functional programming style --- polygons.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/polygons.h b/polygons.h index 471cdf9..168b225 100644 --- a/polygons.h +++ b/polygons.h @@ -1,8 +1,6 @@ #ifndef POLYGONS_H_INCLUDED #define POLYGONS_H_INCLUDED -// extern ball spaceship; - #include "vec2d.h" #include @@ -15,6 +13,26 @@ class polygon { std::vector points; 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; @@ -22,7 +40,6 @@ extern uint n_polygons; extern void polygons_init_state(); extern void polygons_update_state(); -// extern void polygon_control (double dx, double dy); extern void polygons_draw(cairo_t* cr); #endif