Skip to content

Commit

Permalink
Allow transforms to be started and restored for object2d
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkOates committed Jan 1, 2017
1 parent d7c3c3b commit 14949c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/allegro_flare/object2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class object2d

virtual object2d &transform_on();
virtual object2d &appearance_on();
virtual object2d &start_transform();
virtual object2d &restore_transform();
virtual object2d &rotation(float rotation);
virtual object2d &scale(float scale);
virtual object2d &anchor(float x, float y);
Expand All @@ -73,6 +75,7 @@ class object2d
virtual object2d &move(float disp_x, float disp_y);

virtual object2d &draw();
virtual object2d &draw_raw();

virtual void draw_origin(ALLEGRO_COLOR col=al_map_rgb(255,0,0));

Expand Down
27 changes: 27 additions & 0 deletions source/object2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ object2d &object2d::appearance_on()



object2d &object2d::start_transform()
{
if (!_placement) transform_on();
_placement->start_transform();
return *this;
}



object2d &object2d::restore_transform()
{
if (!_placement) transform_on();
_placement->restore_transform();
return *this;
}



object2d &object2d::rotation(float rotation)
{
Expand Down Expand Up @@ -332,6 +349,16 @@ object2d &object2d::draw()



object2d &object2d::draw_raw()
{
al_draw_filled_rectangle(0, 0, 0+*_w, 0+*_h, _appearance->color);
al_draw_rectangle(0, 0, 0+*_w, 0+*_h, al_color_name("dodgerblue"), 1.0);
return *this;
}




void object2d::draw_origin(ALLEGRO_COLOR col)
{
draw_crosshair(*_x, *_y, col);
Expand Down

0 comments on commit 14949c4

Please sign in to comment.