Example #1
0
 public ShapeFill(string name, bool fillEnabled, SKPathFillType fillType, AnimatableColorValue color, AnimatableIntegerValue opacity, bool hidden)
 {
     Name         = name;
     _fillEnabled = fillEnabled;
     FillType     = fillType;
     Color        = color;
     Opacity      = opacity;
     IsHidden     = hidden;
 }
Example #2
0
 public GradientFill(string name, GradientType gradientType, SKPathFillType fillType,
                     AnimatableGradientColorValue gradientColor, AnimatableIntegerValue opacity, AnimatablePointValue startPoint,
                     AnimatablePointValue endPoint, AnimatableFloatValue highlightLength, AnimatableFloatValue highlightAngle, bool hidden)
 {
     GradientType    = gradientType;
     FillType        = fillType;
     GradientColor   = gradientColor;
     Opacity         = opacity;
     StartPoint      = startPoint;
     EndPoint        = endPoint;
     Name            = name;
     HighlightLength = highlightLength;
     HighlightAngle  = highlightAngle;
     IsHidden        = hidden;
 }
Example #3
0
 public void Draw(ref SKCanvas canvas, SKPaint paint, SKPathFillType fillType)
 {
     for (int iter = 1; iter < base.Count; iter++)
     {
         using (SKPath path = new SKPath())
         {
             path.MoveTo(base[iter - 1].intersect);
             path.CubicTo(base[iter - 1].touch, base[iter].touch, base[iter].intersect);
             path.FillType = fillType;
             canvas.DrawPath(path, paint);
         }
         canvas.DrawCircle(base[iter].touch.X, base[iter].touch.Y, 6, paint);
         canvas.DrawCircle(base[iter].intersect.X, base[iter].intersect.Y, 6, paint);
     }
     canvas.DrawCircle(base[0].touch.X, base[0].touch.Y, 6, paint);
     canvas.DrawCircle(base[0].intersect.X, base[0].intersect.Y, 6, paint);
 }
Example #4
0
        internal static PathFillType ToPathFillType(SKPathFillType fillType)
        {
            switch (fillType)
            {
            default:
            case SKPathFillType.Winding:
                return(PathFillType.Winding);

            case SKPathFillType.EvenOdd:
                return(PathFillType.EvenOdd);

            case SKPathFillType.InverseWinding:
                return(PathFillType.InverseWinding);

            case SKPathFillType.InverseEvenOdd:
                return(PathFillType.InverseEvenOdd);
            }
        }
Example #5
0
        private List <SkiaPathFigure> PathGeometryToSkiaPathFigures(IPathGeometry pathGeometry)
        {
            SKPathFillType fillType = pathGeometry.FillRule switch
            {
                FillRule.EvenOdd => SKPathFillType.EvenOdd,
                FillRule.Nonzero => SKPathFillType.Winding,
                _ => throw new InvalidOperationException($"Unknown fillRule value {pathGeometry.FillRule}")
            };

            List <SkiaPathFigure> skiaPathFigures = new List <SkiaPathFigure>();

            // TODO: Decide how (or if) to support geometry.StandardFlatteningTolerance

            foreach (IPathFigure pathFigure in pathGeometry.Figures)
            {
                Point startPoint = pathFigure.StartPoint;

                SKPath skPath = new SKPath();

                skPath.FillType = fillType;
                skPath.MoveTo((float)startPoint.X, (float)startPoint.Y);

                foreach (IPathSegment pathSegment in pathFigure.Segments)
                {
                    AddPathSegmentToSkiaPath(skPath, pathSegment);
                }

                if (pathFigure.IsClosed)
                {
                    skPath.LineTo((float)startPoint.X, (float)startPoint.Y);
                }

                skiaPathFigures.Add(new SkiaPathFigure(skPath, pathFigure.IsFilled));
            }

            return(skiaPathFigures);
        }
        internal static GradientFill Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            AnimatableGradientColorValue color   = null;
            AnimatableIntegerValue       opacity = null;
            GradientType         gradientType    = GradientType.Linear;
            AnimatablePointValue startPoint      = null;
            AnimatablePointValue endPoint        = null;
            SKPathFillType       fillType        = SKPathFillType.EvenOdd;


            bool hidden = false;

            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "nm":
                    name = reader.NextString();
                    break;

                case "g":
                    int points = -1;
                    reader.BeginObject();
                    while (reader.HasNext())
                    {
                        switch (reader.NextName())
                        {
                        case "p":
                            points = reader.NextInt();
                            break;

                        case "k":
                            color = AnimatableValueParser.ParseGradientColor(reader, composition, points);
                            break;

                        default:
                            reader.SkipValue();
                            break;
                        }
                    }
                    reader.EndObject();
                    break;

                case "o":
                    opacity = AnimatableValueParser.ParseInteger(reader, composition);
                    break;

                case "t":
                    gradientType = reader.NextInt() == 1 ? GradientType.Linear : GradientType.Radial;
                    break;

                case "s":
                    startPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "e":
                    endPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "r":
                    fillType = reader.NextInt() == 1 ? SKPathFillType.Winding : SKPathFillType.EvenOdd;
                    break;

                case "hd":
                    hidden = reader.NextBoolean();
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            return(new GradientFill(
                       name, gradientType, fillType, color, opacity, startPoint, endPoint, null, null, hidden));
        }
Example #7
0
		public extern static void sk_path_set_filltype (sk_path_t t, SKPathFillType filltype);
        public static void DrawSplineCurve(SKCanvas canvas, SKPaint paint, List <SKPoint> points, bool closePath, SKPathFillType pathFillType)
        {
            if (points == null || points.Count == 0)// < 4
            {
                return;
            }

            var path = new SKPath()
            {
                FillType = pathFillType
            };

            path.MoveTo(points[0]);
            Common.SplineUtility.CreateSpline(path, points.ToArray());

            if (closePath)
            {
                path.Close();
            }

            canvas.DrawPath(path, paint);
        }
        public static void DrawSimplePath(SKCanvas canvas, SKPaint paint, List <SKPoint> points, bool closePath, SKPathFillType pathFillType)
        {
            if (points == null || points.Count == 0)// < 4
            {
                return;
            }

            var path = new SKPath()
            {
                FillType = pathFillType
            };
            bool start = true;

            for (int i = 0; i < points.Count; i++)
            {
                if (start)
                {
                    path.MoveTo(points[i]);
                    start = false;
                }
                else
                {
                    path.LineTo(points[i]);
                }
            }

            if (closePath)
            {
                path.Close();
            }

            canvas.DrawPath(path, paint);
        }