Script support for AColors. All colors in script related code are now AColor.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@852 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-05-16 20:51:16 +00:00
parent b0c0d8e97c
commit 1b516e781f
16 changed files with 115 additions and 44 deletions
+11 -7
View File
@@ -24,13 +24,7 @@ template <> void Reader::handle(AColor& col) {
if (!col.Ok()) col = AColor(0,0,0,0);
}
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 if (col.alpha == 0) {
handle(_("transparent"));
} else {
handle(String::Format(_("rgba(%u,%u,%u,%u)"), col.Red(), col.Green(), col.Blue(), col.alpha));
}
handle(format_acolor(col));
}
@@ -56,6 +50,16 @@ AColor parse_acolor(const String& v) {
}
}
String format_acolor(AColor col) {
if (col.alpha == 255) {
return String::Format(_("rgb(%u,%u,%u)"), col.Red(), col.Green(), col.Blue());
} else if (col.alpha == 0) {
return _("transparent");
} else {
return String::Format(_("rgba(%u,%u,%u,%u)"), col.Red(), col.Green(), col.Blue(), col.alpha);
}
}
// ----------------------------------------------------------------------------- : Color utility functions
Color lerp(const Color& a, const Color& b, double t) {