Exemplo n.º 1
0
        /// <summary>
        /// Renders the fill of the <see cref="SvgVisualElement"/> to the specified <see cref="RenderContext"/>
        /// </summary>
        protected internal virtual void BuildFill(VectorPath path, RenderContext renderer)
        {
            // Get the fill:
            Loonim.TextureNode fill = Fill;

            if (fill == null)
            {
                // Fill isn't active.
                return;
            }

            // Get as a property:
            Loonim.Property prop = (fill as Loonim.Property);

            if (prop != null)
            {
                // Check if it's transparent:
                if (prop.Colour.a == 0f)
                {
                    return;
                }
            }

            ApplyOpacity(FillOpacity, prop, ref fill);

            // Fill now!
            renderer.FillPath(fill, path, (FillRule == "evenodd"));
        }
Exemplo n.º 2
0
        /// <summary>Applies an opacity value to a Loonim node.</summary>
        private void ApplyOpacity(float opacity, Loonim.Property prop, ref Loonim.TextureNode fill)
        {
            opacity = (float)Math.Min(Math.Max(opacity * Opacity, 0), 1);

            if (opacity == 1f)
            {
                return;
            }

            // If the value is simply a property, apply opacity straight to that:

            if (prop == null)
            {
                // Must create a multiply by..
                Color mult = new Color(1f, 1f, 1f, opacity);

                fill = new Loonim.Multiply(
                    fill,
                    new Loonim.Property(mult)
                    );
            }
            else
            {
                // Must overwrite (because this can be called multiple times):
                prop.Colour.a = opacity;
            }
        }
Exemplo n.º 3
0
        public override Loonim.TextureNode ToLoonimNode(RenderableData context)
        {
            // Create node:
            Loonim.Blur node = new Loonim.Blur();
            node.BlurMethod = Loonim.BlurMethod.Gaussian;

            // Apply radius:
            Loonim.Property radius = new Loonim.Property(this[0].GetRawDecimal());
            node.RadiusX = radius;
            node.RadiusY = radius;

            return(node);
        }
Exemplo n.º 4
0
        private bool BuildDefaultStroke(VectorPath path, RenderContext renderer)
        {
            Loonim.TextureNode stroke = Stroke;

            if (stroke == null || path.FirstPathNode == null)
            {
                return(false);
            }

            // Get as a property:
            Loonim.Property prop = (stroke as Loonim.Property);

            if (prop != null)
            {
                // Check if it's transparent:
                if (prop.Colour.a == 0f)
                {
                    return(false);
                }
            }

            float strokeWidth = StrokeWidth;

            if (strokeWidth <= 0)
            {
                return(false);
            }

            ApplyOpacity(StrokeOpacity, prop, ref stroke);

            if (path.Width == 0f)
            {
                path.RecalculateBounds();
            }

            // Stroke now!
            renderer.StrokePath(stroke, path, strokeWidth, this);

            // Ok:
            return(true);
        }