diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-28 15:26:29 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-28 15:26:29 +0200 |
commit | e7da86053b3df2882816b0df8089e1a51b61939f (patch) | |
tree | 8f7430f7d1e82ddb8449548886f57a3a7c646c05 /src/layer_box.cpp | |
parent | 9b134ea457f91ba8ea6ae558c9192f58c09f62bc (diff) | |
download | osc-graphics-e7da86053b3df2882816b0df8089e1a51b61939f.tar.gz |
autotools based build system
Diffstat (limited to 'src/layer_box.cpp')
-rw-r--r-- | src/layer_box.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/layer_box.cpp b/src/layer_box.cpp new file mode 100644 index 0000000..b720d5c --- /dev/null +++ b/src/layer_box.cpp @@ -0,0 +1,47 @@ +#include <math.h> + +#include <SDL.h> +#include <SDL_gfxPrimitives.h> + +#include "osc_graphics.h" +#include "layer_box.h" + +Layer::CtorInfo LayerBox::ctor_info = {"box", COLOR_TYPES}; + +LayerBox::LayerBox(const char *name, SDL_Rect geo, float opacity, + SDL_Color color) : Layer(name) +{ + color_osc_id = register_method("color", COLOR_TYPES, + (OSCServer::MethodHandlerCb)color_osc); + + LayerBox::geo(geo); + LayerBox::color(color); + LayerBox::alpha(opacity); +} + +void +LayerBox::geo(SDL_Rect geo) +{ + x1 = geo.x; + y1 = geo.y; + x2 = geo.x + geo.w; + y2 = geo.y + geo.h; +} + +void +LayerBox::alpha(float opacity) +{ + a = (Uint8)ceilf(opacity*SDL_ALPHA_OPAQUE); +} + +void +LayerBox::frame(SDL_Surface *target) +{ + boxRGBA(target, x1, y1, x2 ? : target->w, y2 ? : target->h, + r, g, b, a); +} + +LayerBox::~LayerBox() +{ + unregister_method(color_osc_id); +} |