Fix minor issues in item drawing

* Add some utilities functions
This commit is contained in:
Eduardo Bart
2013-01-08 17:40:25 -02:00
parent 122577a916
commit 9d5abb0243
10 changed files with 59 additions and 39 deletions

View File

@@ -63,6 +63,12 @@ public:
void setRGBA(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) { m_r = r/255.0f; m_g = g/255.0f; m_b = b/255.0f; m_a = a/255.0f; }
void setRGBA(uint32 rgba) { setRGBA((rgba >> 0) & 0xff, (rgba >> 8) & 0xff, (rgba >> 16) & 0xff, (rgba >> 24) & 0xff); }
Color operator+(const Color& other) const { return Color(m_r + other.m_r, m_g + other.m_g, m_b + other.m_b, m_a + other.m_a); }
Color operator-(const Color& other) const { return Color(m_r - other.m_r, m_g - other.m_g, m_b - other.m_b, m_a - other.m_a); }
Color operator*(float v) const { return Color(m_r*v, m_g*v, m_b*v, m_a*v); }
Color operator/(float v) const { return Color(m_r/v, m_g/v, m_b/v, m_a/v); }
Color& operator=(uint32_t rgba) { setRGBA(rgba); return *this; }
bool operator==(uint32_t rgba) const { return this->rgba() == rgba; }

View File

@@ -24,6 +24,7 @@
#define RECT_H
#include "../stdext/types.h"
#include "../const.h"
#include <sstream>
template<class T>
@@ -108,6 +109,10 @@ public:
void moveBottomRight(const TPoint<T> &p) { moveRight(p.x); moveBottom(p.y); }
void moveTopRight(const TPoint<T> &p) { moveRight(p.x); moveTop(p.y); }
void moveBottomLeft(const TPoint<T> &p) { moveLeft(p.x); moveBottom(p.y); }
void moveTopCenter(const TPoint<T> &p) { moveHorizontalCenter(p.x); moveTop(p.y); }
void moveBottomCenter(const TPoint<T> &p) { moveHorizontalCenter(p.x); moveBottom(p.y); }
void moveCenterLeft(const TPoint<T> &p) { moveLeft(p.x); moveVerticalCenter(p.y); }
void moveCenterRight(const TPoint<T> &p) { moveRight(p.x); moveVerticalCenter(p.y); }
TRect<T> translated(int x, int y) const { return TRect<T>(TPoint<T>(x1 + x, y1 + y), TPoint<T>(x2 + x, y2 + y)); }
TRect<T> translated(const TPoint<T> &p) const { return TRect<T>(TPoint<T>(x1 + p.x, y1 + p.y), TPoint<T>(x2 + p.x, y2 + p.y)); }