Commit 508cb61e authored by twanvl's avatar twanvl

Fixed some problems where AColor was not used correctly; documentation of AColor.

parent 98bb8853
......@@ -2,20 +2,28 @@ Primitive type: color
--Syntax--
In files and scritps a color can be represented as
<pre>rgb(<i>red_component</i>, <i>green_component</i>, <i>blue_component</i>)</pre>
<pre><span class='hl-kw'>rgb</span>(<i>red_component</i>, <i>green_component</i>, <i>blue_component</i>)</pre>
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
<pre><span class='hl-kw'>rgba</span>(<i>red_component</i>, <i>green_component</i>, <i>blue_component</i>, <i>alpha_component</i>)</pre>
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 <div style="border:1px solid black; background:white;width:30px;height:15px;"> </div>
| @rgb(0,0,0)@ black <div style="border:1px solid black; background:black;width:30px;height:15px;"> </div>
| @rgb(255,0,0)@ red <div style="border:1px solid black; background:red; width:30px;height:15px;"> </div>
| @rgb(0,255,0)@ green <div style="border:1px solid black; background:rgb(0,255,0);width:30px;height:15px;"> </div>
| @rgb(0,0,255)@ blue <div style="border:1px solid black; background:blue; width:30px;height:15px;"> </div>
! Code Represents <<<
| @rgb(255,255,255)@ white <div style="border:1px solid black; background:white;width:30px;height:15px;"> </div>
| @rgb(0,0,0)@ black <div style="border:1px solid black; background:black;width:30px;height:15px;"> </div>
| @rgb(255,0,0)@ red <div style="border:1px solid black; background:red; width:30px;height:15px;"> </div>
| @rgb(0,255,0)@ green <div style="border:1px solid black; background:rgb(0,255,0);width:30px;height:15px;"> </div>
| @rgb(0,0,255)@ blue <div style="border:1px solid black; background:blue; width:30px;height:15px;"> </div>
| @rgba(0,0,0,0)@ transparent <div style="border:1px solid black; width:30px;height:15px;text-align:center;">over</div>
| @rgba(255,0,0,128)@ transparent red <div style="border:1px solid black; background:rgb(255,128,128);color:rgb(128,0,0);width:30px;height:15px;text-align:center;">over</div>
| @rgba(0,0,255,192)@ transparent blue <div style="border:1px solid black; background:rgb(64,64,255);color:rgb(0,0,192);width:30px;height:15px;text-align:center;">over</div>
......@@ -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 @"<sep-soft>"@ tags inserted by the [[fun:combined_editor]] function.
| @separator color@ [[type:color]] @rgba(0,0,0,128)@ Color for @"<sep-soft>"@ tags inserted by the [[fun:combined_editor]] function.
--Example--
>font:
......
......@@ -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) {
......
......@@ -45,7 +45,7 @@ class Font : public IntrusivePtrBase<Font> {
Scriptable<AColor> 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 <sep> text
AColor separator_color; ///< Color for <sep> text
int flags; ///< FontFlags for this font
Font();
......@@ -61,7 +61,7 @@ class Font : public IntrusivePtrBase<Font> {
}
/// 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;
......
......@@ -60,13 +60,13 @@ double TextElements::scaleStep() const {
}
// Colors for <atom-param> 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<Color> colors;
vector<AColor> colors;
vector<double> sizes;
/// put angle brackets around the text?
bool bracket;
......@@ -127,7 +127,7 @@ struct TextElementsFromString {
else if (is_substr(text, tag_start, _( "<color"))) {
size_t colon = text.find_first_of(_(">:"), 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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment