Beispiel #1
0
 public SvgGradientPaintServerColorStop(float offset, SvgColor color, float opacity = 1)
 {
     Offset  = Math.Max(0, Math.Min(1, offset));
     Color   = color;
     Opacity = opacity;
 }
Beispiel #2
0
 public SvgPaint(SvgPaintType paintType, SvgColor color)
 {
     PaintType = paintType;
     _color    = color;
 }
        /// <summary>
        /// Creates the paint server to use when painting the specified element
        /// </summary>
        /// <param name="elementToPaint">the element being painted</param>
        /// <param name="paint">the paint from which to create the paint server from</param>
        /// <param name="currentColor">the color value to use when <see cref="SvgPaintType"/> is CurrentColor</param>
        /// <returns>paint server or null if the <see cref="SvgPaintType"/> is <see cref="SvgPaintType.None"/></returns>
        public static SvgPaintServer CreatePaintServer(SvgElement elementToPaint, SvgPaint paint, SvgColor currentColor, float opacity)
        {
            if (paint == null)
            {
                throw new ArgumentNullException(nameof(paint));
            }
            if (elementToPaint == null)
            {
                throw new ArgumentNullException(nameof(elementToPaint));
            }
            switch (paint.PaintType)
            {
            case SvgPaintType.None:
                return(null);

            case SvgPaintType.CurrentColor:
                return(new SvgSolidColorPaintServer(currentColor, opacity));

            case SvgPaintType.ExplicitColor:
                return(new SvgSolidColorPaintServer(paint.Color, opacity));

            case SvgPaintType.IRIReference:
                return(CreatePaintServerFromReference(elementToPaint, paint.Reference));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }