Example #1
0
        /// <summary>
        /// Renders the fill of the <see cref="SvgVisualElement"/> to the specified <see cref="ISvgRenderer"/>
        /// </summary>
        /// <param name="renderer">The <see cref="ISvgRenderer"/> object to render to.</param>
        /// <param name="fill"></param>
        protected internal virtual bool RenderFill(ISvgRenderer renderer, SvgPaintServer fill = null)
        {
            fill = fill ?? Fill;

            if (fill != null && fill != SvgPaintServer.None)
            {
                renderer.FillPath(Path(renderer), fill.GetColor(this, renderer, FixOpacityValue(FillOpacity), false));
                return(true);
            }

            return(false);
        }
Example #2
0
 public override Color GetColor(SvgVisualElement styleOwner, ISvgRenderer renderer, float opacity, bool forStroke = false)
 {
     try
     {
         _primary.GetCallback = () => _fallbacks.FirstOrDefault();
         return(_primary.GetColor(styleOwner, renderer, opacity, forStroke));
     }
     finally
     {
         _primary.GetCallback = null;
     }
 }
Example #3
0
        /// <summary>
        /// Renders the stroke of the <see cref="SvgVisualElement"/> to the specified <see cref="ISvgRenderer"/>
        /// </summary>
        /// <param name="renderer">The <see cref="ISvgRenderer"/> object to render to.</param>
        /// <param name="stroke"></param>
        protected internal virtual bool RenderStroke(ISvgRenderer renderer, SvgPaintServer stroke = null)
        {
            stroke = stroke ?? Stroke;

            if (stroke != null && stroke != SvgPaintServer.None)
            {
                var strokeWidth = StrokeWidth.ToDeviceValue(renderer, UnitRenderingType.Other, this);

                renderer.DrawPath(Path(renderer), stroke.GetColor(this, renderer, FixOpacityValue(StrokeOpacity), true), strokeWidth);
                return(true);
            }

            return(false);
        }