Ejemplo n.º 1
0
        /// <summary>
        /// Applies to text nodes.
        /// </summary>
        public override void ApplyText(TextRenderingProperty text, RenderableData data, ComputedStyle style, Value value)
        {
            // Get:
            TextShadowProperty tsp = data.GetProperty(typeof(TextShadowProperty)) as TextShadowProperty;

            // Apply the property:
            if (value != null && !(value.IsType(typeof(Css.Keywords.None))) && value.Type == ValueType.Set)
            {
                // The glow properties:
                float blur   = 0;
                Color colour = Color.black;

                if (tsp == null)
                {
                    // Required - Create:
                    tsp      = new TextShadowProperty(data);
                    tsp.Text = text;

                    // Add it:
                    data.AddOrReplaceProperty(tsp, typeof(TextShadowProperty));
                }

                tsp.HOffset = value[0].GetDecimal(data, this);
                tsp.VOffset = value[1].GetDecimal(data, this);

                // Grab the blur:
                Value innerValue = value[2];

                if (innerValue.Type == ValueType.Set)
                {
                    colour = innerValue.GetColour(data, this);
                }
                else
                {
                    blur = innerValue.GetDecimal(data, this);

                    // Grab the colour:
                    innerValue = value[3];

                    if (innerValue.Type == ValueType.Set)
                    {
                        colour = innerValue.GetColour(data, this);
                    }
                }

                if (colour.a == 1f)
                {
                    // Default transparency:
                    colour.a = 0.8f;
                }

                tsp.Colour = colour;
                tsp.Blur   = blur;
            }
            else if (tsp != null)
            {
                // Remove:
                data.AddOrReplaceProperty(null, typeof(TextShadowProperty));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Applies to text nodes.
        /// </summary>
        public override void ApplyText(TextRenderingProperty text, RenderableData data, ComputedStyle style, Value value)
        {
            // Get:
            TextStrokeProperty tsp = data.GetProperty(typeof(TextStrokeProperty)) as TextStrokeProperty;

            // Apply the property:
            if (value != null && !(value.IsType(typeof(Css.Keywords.None))))
            {
                // The stroke properties:
                float thickness = value[0].GetDecimal(style.RenderData, this);

                if (thickness != 0)
                {
                    if (tsp == null)
                    {
                        // Required - Create:
                        tsp      = new TextStrokeProperty(data);
                        tsp.Text = text;

                        // Add it:
                        data.AddOrReplaceProperty(tsp, typeof(TextStrokeProperty));
                    }

                    tsp.Thickness = thickness;

                    tsp.Colour = value[1].GetColour(style.RenderData, this);

                    return;
                }
            }

            // Remove if it falls down here:

            if (tsp != null)
            {
                // Remove:
                data.AddOrReplaceProperty(null, typeof(TextStrokeProperty));
            }
        }