Moved the AColor type to a gfx/ header, so other code can use it.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@847 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-05-16 19:49:14 +00:00
parent 36c7e3ef43
commit d70c3d6d74
11 changed files with 118 additions and 81 deletions
-28
View File
@@ -11,34 +11,6 @@
#include <render/symbol/viewer.hpp>
#include <gfx/gfx.hpp>
#include <util/error.hpp>
#include <script/value.hpp> // for some strange reason the profile build needs this :(
// ----------------------------------------------------------------------------- : Color
template <> void GetDefaultMember::handle(const AColor& col) {
handle((const Color&)col);
}
template <> void Reader::handle(AColor& col) {
UInt r,g,b,a;
String v = getValue();
if (wxSscanf(v.c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
col.Set(r,g,b);
col.alpha = 255;
} else if (wxSscanf(v.c_str(),_("rgba(%u,%u,%u,%u)"),&r,&g,&b,&a)) {
col.Set(r,g,b);
col.alpha = a;
} else {
col = Color(v);
if (!col.Ok()) col = *wxBLACK;
}
}
template <> void Writer::handle(const AColor& col) {
if (col.alpha == 255) {
handle(String::Format(_("rgb(%u,%u,%u)"), col.Red(), col.Green(), col.Blue()));
} else {
handle(String::Format(_("rgba(%u,%u,%u,%u)"), col.Red(), col.Green(), col.Blue(), col.alpha));
}
}
// ----------------------------------------------------------------------------- : Symbol filtering
+1 -11
View File
@@ -11,21 +11,11 @@
#include <util/prec.hpp>
#include <util/reflect.hpp>
#include <gfx/color.hpp>
DECLARE_POINTER_TYPE(Symbol);
class SymbolFilter;
// ----------------------------------------------------------------------------- : Color
/// Color with alpha channel
class AColor : public Color {
public:
Byte alpha; ///< The alpha value, in the range [0..255]
inline AColor() : alpha(0) {}
inline AColor(Byte r, Byte g, Byte b, Byte a = 255) : Color(r,g,b), alpha(a) {}
inline AColor(const Color& color, Byte a = 255) : Color(color), alpha(a) {}
};
// ----------------------------------------------------------------------------- : Symbol filtering
/// Filter a symbol-image.