mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
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:
+11
-7
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user