diff --git a/doc/type/color.txt b/doc/type/color.txt index 6dd8e31e..3cc05049 100644 --- a/doc/type/color.txt +++ b/doc/type/color.txt @@ -2,20 +2,28 @@ Primitive type: color --Syntax-- In files and scritps a color can be represented as -
rgb(red_component, green_component, blue_component)
+
rgb(red_component, green_component, blue_component)
where red_component, green_component and blue_component are numbers between 0 and 255 (inclusive). +In some places MSE also supports colors with a transparency value, notated as +
rgba(red_component, green_component, blue_component, alpha_component)
+An alpha value of @0@ indicates a transparent color, an alpha value of @255@ is completely opaque. + --Named colors-- MSE also supports named colors, for instance @"white"@ is the same as @rgb(255,255,255)@. For a full list of supported colors, see [[http://www.wxwidgets.org/manuals/stable/wx_wxcolourdatabase.html|the wxWidgets documentation]]. +In addition, the named color @"transparent"@ stands for the completely transparent color, @rgba(0,0,0,0)@. In scripts named colors are represented as [[type:string]]s. --Examples-- For example: -! Code Represents <<< -| @rgb(255,255,255)@ white
-| @rgb(0,0,0)@ black
-| @rgb(255,0,0)@ red
-| @rgb(0,255,0)@ green
-| @rgb(0,0,255)@ blue
+! Code Represents <<< +| @rgb(255,255,255)@ white
+| @rgb(0,0,0)@ black
+| @rgb(255,0,0)@ red
+| @rgb(0,255,0)@ green
+| @rgb(0,0,255)@ blue
+| @rgba(0,0,0,0)@ transparent
over
+| @rgba(255,0,0,128)@ transparent red
over
+| @rgba(0,0,255,192)@ transparent blue
over
diff --git a/doc/type/font.txt b/doc/type/font.txt index 83fcddde..03e73382 100644 --- a/doc/type/font.txt +++ b/doc/type/font.txt @@ -19,7 +19,7 @@ A reference to a normal [[type:font]] for drawing text. | @shadow displacement x@ [[type:double]] @0@ Relative position of the shadow in pixels. A shadow is only drawn if the displacement is nonzero. | @shadow displacement y@ [[type:double]] @0@ ^^^ | @shadow blur@ [[type:double]] @0@ How much should the shadow be blurred? -| @separator color@ [[type:color]] @rgb(128,128,128)@ Color for @""@ tags inserted by the [[fun:combined_editor]] function. +| @separator color@ [[type:color]] @rgba(0,0,0,128)@ Color for @""@ tags inserted by the [[fun:combined_editor]] function. --Example-- >font: diff --git a/src/data/font.cpp b/src/data/font.cpp index e575540c..c4f668f5 100644 --- a/src/data/font.cpp +++ b/src/data/font.cpp @@ -20,7 +20,7 @@ Font::Font() , color(AColor(0,0,0)) , shadow_displacement(0,0) , shadow_blur(0) - , separator_color(128,128,128) + , separator_color(AColor(0,0,0,128)) , flags(FONT_NORMAL) {} @@ -50,7 +50,7 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const { shadow_color.initDependencies(ctx, dep); } -FontP Font::make(int add_flags, Color* other_color, double* other_size) const { +FontP Font::make(int add_flags, AColor* other_color, double* other_size) const { FontP f(new Font(*this)); f->flags |= add_flags; if (add_flags & FONT_CODE_STRING) { diff --git a/src/data/font.hpp b/src/data/font.hpp index bf8c6b07..c1811920 100644 --- a/src/data/font.hpp +++ b/src/data/font.hpp @@ -45,7 +45,7 @@ class Font : public IntrusivePtrBase { Scriptable shadow_color; ///< Color for shadow RealSize shadow_displacement; ///< Position of the shadow double shadow_blur; ///< Blur radius of the shadow - Color separator_color; ///< Color for text + AColor separator_color; ///< Color for text int flags; ///< FontFlags for this font Font(); @@ -61,7 +61,7 @@ class Font : public IntrusivePtrBase { } /// Add style to a font, and optionally change the color and size - FontP make(int add_flags, Color* other_color, double* other_size) const; + FontP make(int add_flags, AColor* other_color, double* other_size) const; /// Convert this font to a wxFont wxFont toWxFont(double scale) const; diff --git a/src/render/text/element.cpp b/src/render/text/element.cpp index 5b487773..3eb54c6c 100644 --- a/src/render/text/element.cpp +++ b/src/render/text/element.cpp @@ -60,13 +60,13 @@ double TextElements::scaleStep() const { } // Colors for tags -Color param_colors[] = - { Color(0,170,0) - , Color(0,0,200) - , Color(200,0,100) - , Color(200,200,0) - , Color(0,170,170) - , Color(200,0,0) +AColor param_colors[] = + { AColor(0,170,0) + , AColor(0,0,200) + , AColor(200,0,100) + , AColor(200,200,0) + , AColor(0,170,170) + , AColor(200,0,0) }; const size_t param_colors_count = sizeof(param_colors) / sizeof(param_colors[0]); @@ -77,7 +77,7 @@ struct TextElementsFromString { int soft, kwpph, param, line, soft_line; int code, code_kw, code_string, param_ref, error; int param_id; - vector colors; + vector colors; vector sizes; /// put angle brackets around the text? bool bracket; @@ -127,7 +127,7 @@ struct TextElementsFromString { else if (is_substr(text, tag_start, _( ":"), tag_start); if (colon < pos - 1 && text.GetChar(colon) == _(':')) { - Color c = parse_color(text.substr(colon+1, pos-colon-2)); + AColor c = parse_acolor(text.substr(colon+1, pos-colon-2)); if (!c.Ok()) c = style.font.color; colors.push_back(c); }