Exemple #1
0
        private static void DrawEllipse(SKCanvas canvas, SKColor color, TmxMap tmxMap, TmxObjectEllipse tmxEllipse)
        {
            SKRect  rc     = new SKRect(0, 0, tmxEllipse.Size.Width, tmxEllipse.Size.Height);
            SKColor stroke = color;
            SKColor fill   = color.WithAlpha(128);

            using (SKPaint paint = new SKPaint())
                using (SKPath path = new SKPath())
                {
                    if (tmxMap.Orientation == TmxMap.MapOrientation.Isometric)
                    {
                        // Circles and ellipses not supported in Insometric mode
                        stroke = SKColors.Black;
                        fill   = SKColors.Red;
                        Logger.WriteWarning("Circles/Ellipses not supported in isometric mode: {0}", tmxEllipse.GetNonEmptyName());
                    }
                    else if (!tmxEllipse.IsCircle())
                    {
                        stroke = SKColors.Black;
                        fill   = SKColors.Red;
                        Logger.WriteWarning("Object is an ellipse and will be ignored (only circles supported): {0}", tmxEllipse.GetNonEmptyName());
                    }
                    path.AddOval(rc);

                    paint.Style = SKPaintStyle.Fill;
                    paint.Color = fill;
                    canvas.DrawPath(path, paint);

                    paint.Style       = SKPaintStyle.Stroke;
                    paint.StrokeWidth = StrokeWidthThick;
                    paint.Color       = stroke;
                    canvas.DrawPath(path, paint);
                }
        }
Exemple #2
0
        public void ParsePathReturnsValidPath()
        {
            // based on ParsePath

            foreach (var test in parsePathTestCases)
            {
                var path = SKPath.ParseSvgPathData(test.Item1);

                Assert.IsNotNull(path);
                Assert.AreEqual(test.Item2, path.Bounds);

                TestToFromSvgPath(path);
            }

            var r = SKRect.Create(0, 0, 10, 10.5f);

            using (var p = new SKPath()) {
                p.AddRect(r);
                TestToFromSvgPath(p);

                p.AddOval(r);
                TestToFromSvgPath(p);

                p.AddRoundedRect(r, 4, 4.5f);
                TestToFromSvgPath(p);
            }
        }
        private void DrawTrouble(SKCanvas canvas, SKRect bounds)
        {
            SKPath  gp = new SKPath();
            SKColor firstColor;
            SKColor secondColor;

            firstColor  = new SKColor(255, 255, 255, 150); // 60 instead of 100 seems to do the trick
            secondColor = new SKColor(0, 0, 0, 150);
            var    br_Fill = MiscHelpers.GetLinearGradientPaint(firstColor, secondColor, bounds, MiscHelpers.EnumLinearGradientPercent.Angle180);
            SKRect rect_Temp;
            float  int_Offset = bounds.Width / 6;

            gp.AddLine(new SKPoint(bounds.Left + int_Offset, bounds.Top + (bounds.Height / 4)), new SKPoint((bounds.Left + bounds.Width) - (int_Offset), bounds.Top + (bounds.Height / 4)), true);
            gp.ArcTo(SKRect.Create(bounds.Left + int_Offset, (bounds.Top + (bounds.Height / 2)) - int_Offset, bounds.Width - (int_Offset * 2), bounds.Height / 2), 0, 180, false);
            gp.Close();
            canvas.DrawPath(gp, MainPaint);
            canvas.DrawPath(gp, br_Fill);
            gp        = new SKPath();
            rect_Temp = SKRect.Create(bounds.Left + int_Offset, bounds.Top, bounds.Width - (int_Offset * 2), bounds.Height / 2);
            gp.AddOval(rect_Temp);
            gp.Close();
            canvas.DrawPath(gp, MainPaint);
            rect_Temp = SKRect.Create(rect_Temp.Left + (rect_Temp.Width / 4), rect_Temp.Top + (rect_Temp.Height / 4), (rect_Temp.Width / 2), rect_Temp.Height / 2);
            br_Fill   = MiscHelpers.GetLinearGradientPaint(secondColor, firstColor, bounds, MiscHelpers.EnumLinearGradientPercent.Angle180);
            canvas.DrawOval(rect_Temp, br_Fill);
        }
        public void FillEllipse(Brush brush, float x, float y, float width, float height)
        {
            var path = new SKPath();

            path.AddOval(SKRect.Create(x, y, width, height));
            _image.DrawPath(path, brush.ToSKPaint());
        }
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            // Create elliptical path
            using (SKPath ellipsePath = new SKPath())
            {
                ellipsePath.AddOval(new SKRect(50, 50, info.Width - 50, info.Height - 50));

                // Create animated path effect
                TimeSpan timeSpan = new TimeSpan(DateTime.Now.Ticks);
                float    t        = (float)(timeSpan.TotalSeconds % 3 / 3);
                float    phase    = 0;

                if (t < 0.25f)  // 1, 0, 1, 2 --> 0, 2, 0, 2
                {
                    float tsub = 4 * t;
                    dashArray[0] = strokeWidth * (1 - tsub);
                    dashArray[1] = strokeWidth * 2 * tsub;
                    dashArray[2] = strokeWidth * (1 - tsub);
                    dashArray[3] = strokeWidth * 2;
                }
                else if (t < 0.5f)  // 0, 2, 0, 2 --> 1, 2, 1, 0
                {
                    float tsub = 4 * (t - 0.25f);
                    dashArray[0] = strokeWidth * tsub;
                    dashArray[1] = strokeWidth * 2;
                    dashArray[2] = strokeWidth * tsub;
                    dashArray[3] = strokeWidth * 2 * (1 - tsub);
                    phase        = strokeWidth * tsub;
                }
                else if (t < 0.75f) // 1, 2, 1, 0 --> 0, 2, 0, 2
                {
                    float tsub = 4 * (t - 0.5f);
                    dashArray[0] = strokeWidth * (1 - tsub);
                    dashArray[1] = strokeWidth * 2;
                    dashArray[2] = strokeWidth * (1 - tsub);
                    dashArray[3] = strokeWidth * 2 * tsub;
                    phase        = strokeWidth * (1 - tsub);
                }
                else               // 0, 2, 0, 2 --> 1, 0, 1, 2
                {
                    float tsub = 4 * (t - 0.75f);
                    dashArray[0] = strokeWidth * tsub;
                    dashArray[1] = strokeWidth * 2 * (1 - tsub);
                    dashArray[2] = strokeWidth * tsub;
                    dashArray[3] = strokeWidth * 2;
                }

                using (SKPathEffect pathEffect = SKPathEffect.CreateDash(dashArray, phase))
                {
                    ellipsePaint.PathEffect = pathEffect;
                    canvas.DrawPath(ellipsePath, ellipsePaint);
                }
            }
        }
Exemple #6
0
        /// <inheritdoc />
        public override void CalculateRenderProperties()
        {
            SKPath path = new SKPath();

            path.AddOval(SKRect.Create(Layer.Bounds.Width, Layer.Bounds.Height));
            Path = path;
        }
Exemple #7
0
        private SKPath NonPathShapeToSkiaPath(IShape shape)
        {
            SKPath skPath = new SKPath();

            if (shape is IRectangle rectangle)
            {
                SKRect skRect = SKRect.Create((float)rectangle.Left, (float)rectangle.Top, (float)rectangle.Width, (float)rectangle.Height);
                if (rectangle.RadiusX > 0 || rectangle.RadiusY > 0)
                {
                    skPath.AddRoundRect(skRect, (float)rectangle.RadiusX, (float)rectangle.RadiusY);
                }
                else
                {
                    skPath.AddRect(skRect);
                }
            }
            else if (shape is ILine line)
            {
                skPath.MoveTo((float)line.X1, (float)line.Y1);
                skPath.LineTo((float)line.X2, (float)line.Y2);
            }
            else if (shape is IEllipse ellipse)
            {
                SKRect skRect = SKRect.Create((float)ellipse.Left, (float)ellipse.Top, (float)ellipse.Width, (float)ellipse.Height);
                skPath.AddOval(skRect);
            }
            return(skPath);
        }
Exemple #8
0
 public override void DrawSpecial(SKCanvas canvas)
 {
     using (var path = new SKPath())
     {
         path.AddOval(Box);
         DrawPath(canvas, path);
     }
 }
Exemple #9
0
        public void AddArc(RectangleF rect, float startAngle, float sweepAngle)
        {
            if (rect.IsEmpty || sweepAngle == 0)
            {
                return;
            }
            var r = Convert(rect);

            if (sweepAngle >= 360 || sweepAngle <= -360)
            {
                skPath.AddOval(r, sweepAngle > 0 ? SKPathDirection.Clockwise : SKPathDirection.CounterClockwise);
            }
            else
            {
                skPath.ArcTo(r, startAngle, sweepAngle, false);
            }
        }
Exemple #10
0
        public EllipseGeometryImpl(Rect rect)
        {
            var path = new SKPath();

            path.AddOval(rect.ToSKRect());

            EffectivePath = path;
            Bounds        = rect;
        }
Exemple #11
0
        public void DrawEllipse(IEllipse ellipse)
        {
            SKPath skPath = new SKPath();
            SKRect skRect = SKRect.Create(0, 0, (float)ellipse.Width, (float)ellipse.Height);

            skPath.AddOval(skRect);

            DrawShapePath(skPath, ellipse);
        }
Exemple #12
0
        public override void CalculateRenderProperties()
        {
            RenderRectangle = GetUnscaledRectangle();

            var path = new SKPath();

            path.AddOval(RenderRectangle);
            RenderPath = path;
        }
Exemple #13
0
        protected override void DrawMarks(SKCanvas c)
        {
            // Get the rect vectors
            var pTR         = new SKPoint(p1.X, p0.Y);
            var pBL         = new SKPoint(p0.X, p1.Y);
            var vHorizontal = new SKPoint(p1.X - p0.X, 0);
            var vVertical   = new SKPoint(0, p1.Y - p0.Y);

            // Clip path as defined by the oval
            var clipBounds = new SKRect(
                frame.Bounds.Left + 3,
                frame.Bounds.Top + 3,
                frame.Bounds.Right - 3,
                frame.Bounds.Bottom - 3);
            var clipPath = new SKPath();

            clipPath.AddOval(clipBounds);

            // Draw all visible marks
            foreach (var mark in marks)
            {
                if (!mark.Visible)
                {
                    continue;
                }

                // Clip all marks but Endpoints (they're the bounding box)
                if (mark.MarkId != MarkId.Endpoint)
                {
                    c.Save();
                    c.ClipPath(clipPath);
                }

                foreach (var m in mark.Pos)
                {
                    // Positions relative the the sides
                    var v0 = p0.Pos + vHorizontal.Scale(m);
                    var v1 = pBL + vHorizontal.Scale(m);
                    var h0 = p0.Pos + vVertical.Scale(m);
                    var h1 = pTR + vVertical.Scale(m);

                    // Draw them
                    c.DrawLine(v0, v1, mark.PaintMark);
                    c.DrawLine(h0, h1, mark.PaintMark);
                }

                if (mark.MarkId != MarkId.Endpoint)
                {
                    c.Restore();
                }
            }
        }
Exemple #14
0
        static SKPath MakePath(EllipseGeometry ellipseGeometry)
        {
            var path = new SKPath();

            path.AddOval(new SKRect(
                             Forms.ConvertToScaledPixel(ellipseGeometry.Center.X - ellipseGeometry.RadiusX),
                             Forms.ConvertToScaledPixel(ellipseGeometry.Center.Y - ellipseGeometry.RadiusY),
                             Forms.ConvertToScaledPixel(ellipseGeometry.Center.X + ellipseGeometry.RadiusX),
                             Forms.ConvertToScaledPixel(ellipseGeometry.Center.Y + ellipseGeometry.RadiusY)),
                         SKPathDirection.Clockwise);

            return(path);
        }
        public override SKPath GetPath()
        {
            if (path != null)
            {
                return(path);
            }

            path = new SKPath();
            var rect = SKRect.Create(0, 0, (float)Width, (float)Height);

            path.AddOval(rect);

            return(path);
        }
Exemple #16
0
        public void TestGeneratedShape(SKCanvas canvas)
        {
            // Fill color for Group Style
            var GroupStyleFillColor = new SKColor(230, 230, 230, 255);

            // Create Group Style fill paint
            var GroupStyleFillPaint = new SKPaint()
            {
                Style       = SKPaintStyle.Fill,
                Color       = GroupStyleFillColor,
                BlendMode   = SKBlendMode.SrcOver,
                IsAntialias = true
            };

            // Frame color for Group Style
            var GroupStyleFrameColor = new SKColor(0, 0, 0, 255);

            // Create Group Style frame paint
            var GroupStyleFramePaint = new SKPaint()
            {
                Style       = SKPaintStyle.Stroke,
                Color       = GroupStyleFrameColor,
                BlendMode   = SKBlendMode.SrcOver,
                IsAntialias = true,
                StrokeWidth = 1f,
                StrokeMiter = 4f,
                StrokeJoin  = SKStrokeJoin.Mitter,
                StrokeCap   = SKStrokeCap.Butt
            };

            //-----------------------------------------------------------------------------
            // Draw Group shape group
            // Define Rectangle shape path
            var RectanglePath = new SKPath();

            RectanglePath.AddRect(new SKRect(29.55859f, 28.60938f, 193.6055f, 149.0313f), SKPathDirection.Clockwise);
            var GroupPath = RectanglePath;

            // Define Oval shape path
            var OvalPath = new SKPath();

            OvalPath.AddOval(new SKRect(113.043f, 72.44141f, 294.5547f, 234.2383f), SKPathDirection.Clockwise);
            GroupPath = GroupPath.Op(OvalPath, SKPathOp.Union);


            // Draw Group boolean shape
            canvas.DrawPath(GroupPath, GroupStyleFillPaint);
            canvas.DrawPath(GroupPath, GroupStyleFramePaint);
            //-----------------------------------------------------------------------------
        }
        public void OvalPathIsOval()
        {
            using (var path = new SKPath())
            {
                var rect = SKRect.Create(10, 10, 100, 100);
                path.AddOval(rect);

                Assert.True(path.IsOval);
                Assert.False(path.IsLine);
                Assert.False(path.IsRect);
                Assert.False(path.IsRoundRect);
                Assert.Equal(rect, path.GetOvalBounds());
            }
        }
Exemple #18
0
        /// <summary>
        /// Converts the current shape to a path.
        /// </summary>
        /// <returns>The shape as a <c>SKPath</c>.</returns>
        public override SKPath ToPath()
        {
            // Update any attached properties
            EvaluateConnectedProperties();

            // Construct new path
            var path = new SKPath();

            // Add oval to path
            path.AddOval(Rect, SKPathDirection.Clockwise);

            // Return path
            return(path);
        }
        private void DrawMarble(SKCanvas canvas, SKRect thisRect) // start with the marble piece.
        {
            var    br_Fill = MiscHelpers.GetCenterGradientPaint(SKColors.White, MainColor.ToSKColor(), new SKPoint(thisRect.Left + (thisRect.Width / 2), thisRect.Top + (thisRect.Height / 2)), thisRect.Height / 2);
            SKPath gp      = new SKPath();

            gp.AddOval(thisRect);
            SKColor firstColor;
            SKColor secondColor;

            firstColor  = new SKColor(255, 255, 255, 50); // 60 instead of 100 seems to do the trick
            secondColor = new SKColor(0, 0, 0, 50);
            var br_Shade = MiscHelpers.GetLinearGradientPaint(firstColor, secondColor, thisRect, MiscHelpers.EnumLinearGradientPercent.Angle45);

            canvas.DrawPath(gp, br_Fill);
            canvas.DrawPath(gp, br_Shade);
        }
Exemple #20
0
        public bool HitTest(Point p, IShape shape)
        {
            var stroke = shape.Stroke;

            if (stroke is not null && stroke.Width < 4)
            {
                stroke = new Stroke(color: stroke.Color, width: 4);
            }
            using var path = new SKPath();
            path.AddOval(shape.Bounds.ToSk());

            using var paint = new SKPaint()
                              .SetStroke(stroke)
                              .SetFill(shape.Fill)
                              .SetPaintStyle(stroke, shape.Fill);

            using var fillPath = paint.GetFillPath(path);
            using var region   = new SKRegion(fillPath);
            return(region.Contains((int)p.X, (int)p.Y));
        }
Exemple #21
0
        public virtual void DrawThumb(SKCanvas canvas, float progress, float hSpace, RectangleF rectangle)
        {
            using var paint = new SKPaint();

            var fillColor = TypedVirtualView.GetThumbColor(defaultThumbColor, CurrentState).ToSKColor();

            ThumbRect.X = (rectangle.Width - (hSpace * 2) - ThumbRect.Width) * progress + hSpace;
            ThumbRect.Y = rectangle.Y + (rectangle.Height - ThumbRect.Height) / 2;
            TouchTargetRect.Center(ThumbRect.Center());
            var knobRect = ThumbRect.ToSKRect();

            using var knobPath = new SKPath();
            knobPath.Reset();
            knobPath.AddOval(knobRect, SKPathDirection.Clockwise);

            paint.Reset();
            paint.IsAntialias = true;
            paint.Style       = SKPaintStyle.Fill;
            paint.Color       = fillColor;
            canvas.DrawPath(knobPath, paint);
        }
        private SKPath NonPathShapeToSkiaPath(IShape shape)
        {
            SKPath skPath = new SKPath();

            if (shape is IRectangle rectangle)
            {
                SKRect skRect = SKRect.Create((float)rectangle.Left, (float)rectangle.Top, (float)rectangle.Width, (float)rectangle.Height);
                if (rectangle.RadiusX > 0 || rectangle.RadiusY > 0)
                {
                    skPath.AddRoundRect(skRect, (float)rectangle.RadiusX, (float)rectangle.RadiusY);
                }
                else
                {
                    skPath.AddRect(skRect);
                }
            }
            else if (shape is ILine line)
            {
                skPath.MoveTo((float)line.X1, (float)line.Y1);
                skPath.LineTo((float)line.X2, (float)line.Y2);
            }
            else if (shape is IEllipse ellipse)
            {
                SKRect skRect = SKRect.Create((float)ellipse.Left, (float)ellipse.Top, (float)ellipse.Width, (float)ellipse.Height);
                skPath.AddOval(skRect);
            }
            else if (shape is IPolygon polygon)
            {
                skPath.FillType = FillRuleToSkiaPathFillType(polygon.FillRule);
                skPath.AddPoly(PointsToSkiaPoints(polygon.Points), close: true);
            }
            else if (shape is IPolyline polyline)
            {
                skPath.FillType = FillRuleToSkiaPathFillType(polyline.FillRule);
                skPath.AddPoly(PointsToSkiaPoints(polyline.Points), close: false);
            }
            return(skPath);
        }
Exemple #23
0
        public void DrawLaunchScreen(SKCanvas canvas)
        {
            //-----------------------------------------------------------------------------
            // Draw Sheild shape group
            // Define Oval shape path
            var OvalPath = new SKPath();

            OvalPath.AddOval(new SKRect(215.3477f, 114.1523f, 414.7578f, 317.2344f), SKPathDirection.Clockwise);
            var SheildPath = OvalPath;

            // Define Star shape path
            var StarPath = new SKPath();

            StarPath.MoveTo(new SKPoint(315.4297f, 128.6055f));
            StarPath.LineTo(new SKPoint(334.3599f, 191.2784f));
            StarPath.LineTo(new SKPoint(395.6194f, 191.2784f));
            StarPath.LineTo(new SKPoint(346.0594f, 230.0125f));
            StarPath.LineTo(new SKPoint(364.9896f, 292.6854f));
            StarPath.LineTo(new SKPoint(315.4297f, 253.9514f));
            StarPath.LineTo(new SKPoint(265.8698f, 292.6854f));
            StarPath.LineTo(new SKPoint(284.8f, 230.0125f));
            StarPath.LineTo(new SKPoint(235.24f, 191.2784f));
            StarPath.LineTo(new SKPoint(296.4995f, 191.2784f));
            StarPath.LineTo(new SKPoint(315.4297f, 128.6055f));
            SheildPath = SheildPath.Op(StarPath, SKPathOp.Difference);


            // Draw Sheild boolean shape
            VeryBerryFillPaint.Shader = SKShader.CreateLinearGradient(new SKPoint(308.8389f, 121.1026f), new SKPoint(305.8028f, 308.4947f), BerryBlastColors, BerryBlastWeights, SKShaderTileMode.Clamp);
            canvas.DrawPath(SheildPath, VeryBerryFillPaint);
            canvas.DrawPath(SheildPath, VeryBerryFramePaint);
            //-----------------------------------------------------------------------------


            // Draw Text shape
            canvas.DrawText("Berry Blaster", 316.8008f, 364.5391f, CustomFillPaint);
        }
Exemple #24
0
        public override void DrawImage(SKCanvas dc)
        {
            if (NeedsToClear == true)
            {
                dc.Clear();
            }
            var    bounds = GetMainRect();
            SKPath gp     = new SKPath();

            gp.AddOval(SKRect.Create(bounds.Left, bounds.Top + bounds.Height * 4 / 5, bounds.Width, bounds.Height / 5));
            dc.DrawPath(gp, MainPaint);
            dc.DrawPath(gp, _borderBrush);
            gp = new SKPath();
            gp.AddLine(new SKPoint(bounds.Left + bounds.Width / 4, bounds.Top + bounds.Height * 9 / 10), new SKPoint(bounds.Left + bounds.Width * 3 / 8, bounds.Top + bounds.Height * 5 / 10), true);
            gp.ArcTo(SKRect.Create(bounds.Left, bounds.Top + bounds.Height * 3 / 8, bounds.Width / 4, bounds.Height * 2 / 16), 90, 180, false);
            gp.ArcTo(SKRect.Create(bounds.Left + bounds.Width / 4, bounds.Top, bounds.Width / 2, bounds.Height * 3 / 8), 110, 320, false); // was 320
            gp.ArcTo(SKRect.Create(bounds.Left + bounds.Width * 3 / 4, bounds.Top + bounds.Height * 3 / 8, bounds.Width / 4, bounds.Height * 2 / 16), -90, 180, false);
            gp.AddLine(new SKPoint(bounds.Left + bounds.Width * 5 / 8, bounds.Top + bounds.Height * 5 / 10), new SKPoint(bounds.Left + bounds.Width * 3 / 4, bounds.Top + bounds.Height * 9 / 10));
            gp.AddLine(new SKPoint(bounds.Left + bounds.Width * 9 / 16, bounds.Top + bounds.Height * 9 / 10), new SKPoint(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height * 7 / 10));
            gp.AddLine(new SKPoint(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height * 7 / 10), new SKPoint(bounds.Left + bounds.Width * 7 / 16, bounds.Top + bounds.Height * 9 / 10));
            gp.Close();
            dc.DrawPath(gp, MainPaint);
            dc.DrawPath(gp, _borderBrush);
        }
        public static SKPath ToSKPath(this IEnumerable <IBaseShape> shapes, double dx, double dy, Func <double, float> scale)
        {
            var path = new SKPath
            {
                FillType = SKPathFillType.Winding
            };
            var previous = default(IPointShape);

            foreach (var shape in shapes)
            {
                switch (shape)
                {
                case ILineShape lineShape:
                {
                    if (previous == null || previous != lineShape.Start)
                    {
                        path.MoveTo(
                            scale(lineShape.Start.X + dx),
                            scale(lineShape.Start.Y + dy));
                    }
                    path.LineTo(
                        scale(lineShape.End.X + dx),
                        scale(lineShape.End.Y + dy));
                    previous = lineShape.End;
                }
                break;

                case IRectangleShape rectangleShape:
                {
                    path.AddRect(
                        SkiaSharpRenderer.CreateRect(rectangleShape.TopLeft, rectangleShape.BottomRight, dx, dy, scale),
                        SKPathDirection.Clockwise);
                }
                break;

                case IEllipseShape ellipseShape:
                {
                    path.AddOval(
                        SkiaSharpRenderer.CreateRect(ellipseShape.TopLeft, ellipseShape.BottomRight, dx, dy, scale),
                        SKPathDirection.Clockwise);
                }
                break;

                case IArcShape arcShape:
                {
                    var a = new GdiArc(
                        Point2.FromXY(arcShape.Point1.X, arcShape.Point1.Y),
                        Point2.FromXY(arcShape.Point2.X, arcShape.Point2.Y),
                        Point2.FromXY(arcShape.Point3.X, arcShape.Point3.Y),
                        Point2.FromXY(arcShape.Point4.X, arcShape.Point4.Y));
                    var rect = new SKRect(
                        scale(a.X + dx),
                        scale(a.Y + dy),
                        scale(a.X + dx + a.Width),
                        scale(a.Y + dy + a.Height));
                    path.AddArc(rect, (float)a.StartAngle, (float)a.SweepAngle);
                }
                break;

                case ICubicBezierShape cubicBezierShape:
                {
                    if (previous == null || previous != cubicBezierShape.Point1)
                    {
                        path.MoveTo(
                            scale(cubicBezierShape.Point1.X + dx),
                            scale(cubicBezierShape.Point1.Y + dy));
                    }
                    path.CubicTo(
                        scale(cubicBezierShape.Point2.X + dx),
                        scale(cubicBezierShape.Point2.Y + dy),
                        scale(cubicBezierShape.Point3.X + dx),
                        scale(cubicBezierShape.Point3.Y + dy),
                        scale(cubicBezierShape.Point4.X + dx),
                        scale(cubicBezierShape.Point4.Y + dy));
                    previous = cubicBezierShape.Point4;
                }
                break;

                case IQuadraticBezierShape quadraticBezierShape:
                {
                    if (previous == null || previous != quadraticBezierShape.Point1)
                    {
                        path.MoveTo(
                            scale(quadraticBezierShape.Point1.X + dx),
                            scale(quadraticBezierShape.Point1.Y + dy));
                    }
                    path.QuadTo(
                        scale(quadraticBezierShape.Point2.X + dx),
                        scale(quadraticBezierShape.Point2.Y + dy),
                        scale(quadraticBezierShape.Point3.X + dx),
                        scale(quadraticBezierShape.Point3.Y + dy));
                    previous = quadraticBezierShape.Point3;
                }
                break;

                case ITextShape textShape:
                {
                    var resultPath = ToSKPath(textShape, dx, dy, scale);
                    if (resultPath != null && !resultPath.IsEmpty)
                    {
                        path.AddPath(resultPath, SKPathAddMode.Append);
                    }
                }
                break;

                case IPathShape pathShape:
                {
                    var resultPath = ToSKPath(pathShape, dx, dy, scale);
                    if (resultPath != null && !resultPath.IsEmpty)
                    {
                        path.AddPath(resultPath, SKPathAddMode.Append);
                    }
                }
                break;

                case IGroupShape groupShape:
                {
                    var resultPath = ToSKPath(groupShape.Shapes, dx, dy, scale);
                    if (resultPath != null && !resultPath.IsEmpty)
                    {
                        path.AddPath(resultPath, SKPathAddMode.Append);
                    }
                }
                break;
                }
            }
            return(path);
        }
        public static void drawClock(SKCanvas canvas, Context context, SKRect targetFrame, ResizingBehavior resizing, SKColor numbersColor, SKColor darkHandsColor, SKColor lightHandColor, SKColor rimColor, SKColor tickColor, SKColor faceColor, float hours, float minutes, float seconds)
        {
            // General Declarations
//         Stack<Matrix> currentTransformation = new Stack<Matrix>(); // skipping - we do not support Matrix yet
//         currentTransformation.push(new Matrix()); // skipping - we do not support Matrix yet
            SKPaint paint = CacheForClock.paint;

            // Local Variables
            String expression   = hours > 12f ? "PM" : "AM";
            float  secondsAngle = -seconds / 60f * 360f;
            float  minuteAngle  = -(minutes / 60f * 360f - secondsAngle / 60f);
            float  hourAngle    = -hours / 12f * 360f + minuteAngle / 12f;

            // Resize to Target Frame
            canvas.Save();
            var resizedFrame = Helpers.ResizingBehaviorApply(resizing, CacheForClock.originalFrame, targetFrame);

            canvas.Translate(resizedFrame.Left, resizedFrame.Top);
            canvas.Scale(resizedFrame.Width / 260f, resizedFrame.Height / 260f);

            // Oval 2
            canvas.Save();
            canvas.Translate(130f, 130f);
//         currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
            var    oval2Rect = new SKRect(-116f, -116f, 116f, 116f);
            SKPath oval2Path = CacheForClock.oval2Path;

            oval2Path.Reset();
            oval2Path.AddOval(oval2Rect, SKPathDirection.Clockwise);

            paint.Reset();
            paint.IsAntialias = true;
            paint.Style       = SKPaintStyle.Fill;
            paint.Color       = (SKColor)rimColor;
            canvas.DrawPath(oval2Path, paint);
            canvas.Restore();

            // Oval
            canvas.Save();
            canvas.Translate(130f, 130f);
//         currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
            var    ovalRect = new SKRect(-110f, -110f, 110f, 110f);
            SKPath ovalPath = CacheForClock.ovalPath;

            ovalPath.Reset();
            ovalPath.AddOval(ovalRect, SKPathDirection.Clockwise);

            paint.Reset();
            paint.IsAntialias = true;
            paint.Style       = SKPaintStyle.Fill;
            paint.Color       = (SKColor)faceColor;
            canvas.DrawPath(ovalPath, paint);
            canvas.Restore();

            // Text
            var    textRect = new SKRect(118.48f, 34.85f, 142.5f, 53f);
            SKPath textPath = CacheForClock.textPath;

            textPath.Reset();
            textPath.MoveTo(123.73f, 38.95f);
            textPath.LineTo(120.23f, 41.82f);
            textPath.LineTo(118.48f, 39.75f);
            textPath.LineTo(124f, 35.3f);
            textPath.LineTo(126.73f, 35.3f);
            textPath.LineTo(126.73f, 53f);
            textPath.LineTo(123.73f, 53f);
            textPath.LineTo(123.73f, 38.95f);
            textPath.Close();
            textPath.MoveTo(130.73f, 50.25f);
            textPath.LineTo(137.55f, 43.55f);
            textPath.CubicTo(138.1f, 43.02f, 138.54f, 42.48f, 138.86f, 41.94f);
            textPath.CubicTo(139.19f, 41.4f, 139.35f, 40.78f, 139.35f, 40.07f);
            textPath.CubicTo(139.35f, 39.24f, 139.08f, 38.58f, 138.54f, 38.09f);
            textPath.CubicTo(138f, 37.6f, 137.33f, 37.35f, 136.53f, 37.35f);
            textPath.CubicTo(135.67f, 37.35f, 134.99f, 37.64f, 134.48f, 38.21f);
            textPath.CubicTo(133.96f, 38.79f, 133.64f, 39.51f, 133.53f, 40.38f);
            textPath.LineTo(130.6f, 39.92f);
            textPath.CubicTo(130.68f, 39.19f, 130.89f, 38.52f, 131.23f, 37.9f);
            textPath.CubicTo(131.56f, 37.28f, 131.98f, 36.75f, 132.5f, 36.3f);
            textPath.CubicTo(133.02f, 35.85f, 133.62f, 35.5f, 134.31f, 35.24f);
            textPath.CubicTo(135f, 34.98f, 135.76f, 34.85f, 136.57f, 34.85f);
            textPath.CubicTo(137.34f, 34.85f, 138.08f, 34.96f, 138.79f, 35.17f);
            textPath.CubicTo(139.5f, 35.39f, 140.12f, 35.72f, 140.68f, 36.16f);
            textPath.CubicTo(141.23f, 36.6f, 141.66f, 37.15f, 141.99f, 37.79f);
            textPath.CubicTo(142.31f, 38.43f, 142.48f, 39.17f, 142.48f, 40.03f);
            textPath.CubicTo(142.48f, 40.59f, 142.4f, 41.12f, 142.25f, 41.61f);
            textPath.CubicTo(142.1f, 42.1f, 141.9f, 42.57f, 141.64f, 43f);
            textPath.CubicTo(141.38f, 43.43f, 141.08f, 43.85f, 140.74f, 44.24f);
            textPath.CubicTo(140.4f, 44.63f, 140.03f, 45.01f, 139.63f, 45.38f);
            textPath.LineTo(134.53f, 50.25f);
            textPath.LineTo(142.5f, 50.25f);
            textPath.LineTo(142.5f, 53f);
            textPath.LineTo(130.73f, 53f);
            textPath.LineTo(130.73f, 50.25f);
            textPath.Close();

            paint.Reset();
            paint.IsAntialias = true;
            paint.Style       = SKPaintStyle.Fill;
            paint.Color       = (SKColor)numbersColor;
            canvas.DrawPath(textPath, paint);

            // Bezier
            canvas.Save();
            canvas.Translate(130f, 130f);
//         currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
            canvas.RotateDegrees(-(minuteAngle + 90f));
//         currentTransformation.peek().postRotate(-(minuteAngle + 90f)); // skipping - we do not support Matrix yet
            var    bezierRect = new SKRect(-10f, -10f, 95f, 10f);
            SKPath bezierPath = CacheForClock.bezierPath;

            bezierPath.Reset();
            bezierPath.MoveTo(7.07f, -7.07f);
            bezierPath.CubicTo(8.25f, -5.89f, 9.07f, -4.49f, 9.54f, -3f);
            bezierPath.LineTo(95f, -3f);
            bezierPath.LineTo(95f, 3f);
            bezierPath.LineTo(9.54f, 3f);
            bezierPath.CubicTo(9.07f, 4.49f, 8.25f, 5.89f, 7.07f, 7.07f);
            bezierPath.CubicTo(3.17f, 10.98f, -3.17f, 10.98f, -7.07f, 7.07f);
            bezierPath.CubicTo(-10.98f, 3.17f, -10.98f, -3.17f, -7.07f, -7.07f);
            bezierPath.CubicTo(-3.17f, -10.98f, 3.17f, -10.98f, 7.07f, -7.07f);
            bezierPath.Close();

            paint.Reset();
            paint.IsAntialias = true;
            paint.Style       = SKPaintStyle.Fill;
            paint.Color       = (SKColor)darkHandsColor;
            canvas.DrawPath(bezierPath, paint);
            canvas.Restore();

            // Bezier 2
            canvas.Save();
            canvas.Translate(130f, 130f);
//         currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
            canvas.RotateDegrees(-(hourAngle + 90f));
//         currentTransformation.peek().postRotate(-(hourAngle + 90f)); // skipping - we do not support Matrix yet
            var    bezier2Rect = new SKRect(-10f, -10f, 56f, 10f);
            SKPath bezier2Path = CacheForClock.bezier2Path;

            bezier2Path.Reset();
            bezier2Path.MoveTo(7.07f, -7.07f);
            bezier2Path.CubicTo(7.7f, -6.44f, 8.24f, -5.74f, 8.66f, -5f);
            bezier2Path.LineTo(56f, -5f);
            bezier2Path.LineTo(56f, 5f);
            bezier2Path.LineTo(8.66f, 5f);
            bezier2Path.CubicTo(8.24f, 5.74f, 7.7f, 6.44f, 7.07f, 7.07f);
            bezier2Path.CubicTo(3.17f, 10.98f, -3.17f, 10.98f, -7.07f, 7.07f);
            bezier2Path.CubicTo(-10.98f, 3.17f, -10.98f, -3.17f, -7.07f, -7.07f);
            bezier2Path.CubicTo(-3.17f, -10.98f, 3.17f, -10.98f, 7.07f, -7.07f);
            bezier2Path.Close();

            paint.Reset();
            paint.IsAntialias = true;
            paint.Style       = SKPaintStyle.Fill;
            paint.Color       = (SKColor)darkHandsColor;
            canvas.DrawPath(bezier2Path, paint);
            canvas.Restore();

            // Bezier 3
            canvas.Save();
            canvas.Translate(130f, 130f);
//         currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
            canvas.RotateDegrees(-(secondsAngle + 90f));
//         currentTransformation.peek().postRotate(-(secondsAngle + 90f)); // skipping - we do not support Matrix yet
            var    bezier3Rect = new SKRect(-6f, -6f, 99f, 6f);
            SKPath bezier3Path = CacheForClock.bezier3Path;

            bezier3Path.Reset();
            bezier3Path.MoveTo(4.24f, -4.24f);
            bezier3Path.CubicTo(5.16f, -3.33f, 5.72f, -2.19f, 5.92f, -1f);
            bezier3Path.LineTo(99f, -1f);
            bezier3Path.LineTo(99f, 1f);
            bezier3Path.LineTo(5.92f, 1f);
            bezier3Path.CubicTo(5.72f, 2.19f, 5.16f, 3.33f, 4.24f, 4.24f);
            bezier3Path.CubicTo(1.9f, 6.59f, -1.9f, 6.59f, -4.24f, 4.24f);
            bezier3Path.CubicTo(-6.59f, 1.9f, -6.59f, -1.9f, -4.24f, -4.24f);
            bezier3Path.CubicTo(-1.9f, -6.59f, 1.9f, -6.59f, 4.24f, -4.24f);
            bezier3Path.Close();

            paint.Reset();
            paint.IsAntialias = true;
            paint.Style       = SKPaintStyle.Fill;
            paint.Color       = (SKColor)lightHandColor;
            canvas.DrawPath(bezier3Path, paint);
            canvas.Restore();

            // Group
            {
                // Rectangle
                var    rectangleRect = new SKRect(127f, 20f, 133f, 28f);
                SKPath rectanglePath = CacheForClock.rectanglePath;
                rectanglePath.Reset();
                rectanglePath.AddRect(rectangleRect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectanglePath, paint);

                // Rectangle 2
                var    rectangle2Rect = new SKRect(127f, 232f, 133f, 240f);
                SKPath rectangle2Path = CacheForClock.rectangle2Path;
                rectangle2Path.Reset();
                rectangle2Path.AddRect(rectangle2Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle2Path, paint);
            }

            // Group 2
            {
                canvas.Save();
                canvas.Translate(130f, 130f);
//             currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
                canvas.RotateDegrees(90f);
//             currentTransformation.peek().postRotate(90f); // skipping - we do not support Matrix yet

                // Rectangle 3
                var    rectangle3Rect = new SKRect(-3f, -110f, 3f, -102f);
                SKPath rectangle3Path = CacheForClock.rectangle3Path;
                rectangle3Path.Reset();
                rectangle3Path.AddRect(rectangle3Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle3Path, paint);

                // Rectangle 4
                var    rectangle4Rect = new SKRect(-3f, 102f, 3f, 110f);
                SKPath rectangle4Path = CacheForClock.rectangle4Path;
                rectangle4Path.Reset();
                rectangle4Path.AddRect(rectangle4Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle4Path, paint);

                canvas.Restore();
            }

            // Group 3
            {
                canvas.Save();
                canvas.Translate(130f, 130f);
//             currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
                canvas.RotateDegrees(-30f);
//             currentTransformation.peek().postRotate(-30f); // skipping - we do not support Matrix yet

                // Rectangle 5
                var    rectangle5Rect = new SKRect(-3f, -110f, 3f, -102f);
                SKPath rectangle5Path = CacheForClock.rectangle5Path;
                rectangle5Path.Reset();
                rectangle5Path.AddRect(rectangle5Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle5Path, paint);

                // Rectangle 6
                var    rectangle6Rect = new SKRect(-3f, 102f, 3f, 110f);
                SKPath rectangle6Path = CacheForClock.rectangle6Path;
                rectangle6Path.Reset();
                rectangle6Path.AddRect(rectangle6Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle6Path, paint);

                canvas.Restore();
            }

            // Group 4
            {
                canvas.Save();
                canvas.Translate(130f, 130f);
//             currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
                canvas.RotateDegrees(-60f);
//             currentTransformation.peek().postRotate(-60f); // skipping - we do not support Matrix yet

                // Rectangle 7
                var    rectangle7Rect = new SKRect(-3f, -110f, 3f, -102f);
                SKPath rectangle7Path = CacheForClock.rectangle7Path;
                rectangle7Path.Reset();
                rectangle7Path.AddRect(rectangle7Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle7Path, paint);

                // Rectangle 8
                var    rectangle8Rect = new SKRect(-3f, 102f, 3f, 110f);
                SKPath rectangle8Path = CacheForClock.rectangle8Path;
                rectangle8Path.Reset();
                rectangle8Path.AddRect(rectangle8Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle8Path, paint);

                canvas.Restore();
            }

            // Group 5
            {
                canvas.Save();
                canvas.Translate(130f, 130f);
//             currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
                canvas.RotateDegrees(-120f);
//             currentTransformation.peek().postRotate(-120f); // skipping - we do not support Matrix yet

                // Rectangle 9
                var    rectangle9Rect = new SKRect(-3f, -110f, 3f, -102f);
                SKPath rectangle9Path = CacheForClock.rectangle9Path;
                rectangle9Path.Reset();
                rectangle9Path.AddRect(rectangle9Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle9Path, paint);

                // Rectangle 10
                var    rectangle10Rect = new SKRect(-3f, 102f, 3f, 110f);
                SKPath rectangle10Path = CacheForClock.rectangle10Path;
                rectangle10Path.Reset();
                rectangle10Path.AddRect(rectangle10Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle10Path, paint);

                canvas.Restore();
            }

            // Group 6
            {
                canvas.Save();
                canvas.Translate(130f, 130f);
//             currentTransformation.peek().postTranslate(130f, 130f); // skipping - we do not support Matrix yet
                canvas.RotateDegrees(-150f);
//             currentTransformation.peek().postRotate(-150f); // skipping - we do not support Matrix yet

                // Rectangle 11
                var    rectangle11Rect = new SKRect(-3f, -110f, 3f, -102f);
                SKPath rectangle11Path = CacheForClock.rectangle11Path;
                rectangle11Path.Reset();
                rectangle11Path.AddRect(rectangle11Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle11Path, paint);

                // Rectangle 12
                var    rectangle12Rect = new SKRect(-3f, 102f, 3f, 110f);
                SKPath rectangle12Path = CacheForClock.rectangle12Path;
                rectangle12Path.Reset();
                rectangle12Path.AddRect(rectangle12Rect, SKPathDirection.Clockwise);

                paint.Reset();
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;
                paint.Color       = (SKColor)tickColor;
                canvas.DrawPath(rectangle12Path, paint);

                canvas.Restore();
            }

            // Text 2
            var text2Rect      = new SKRect(111f, 198f, 149f, 238f);
            var text2TextPaint = CacheForClock.text2TextPaint;

            text2TextPaint.Reset();
            text2TextPaint.IsAntialias = true;
            text2TextPaint.Color       = (SKColor)numbersColor;
            text2TextPaint.Typeface    = TypefaceManager.GetTypeface("Avenir Next.ttc");
            text2TextPaint.TextSize    = 25f;
            StaticLayout text2StaticLayout = CacheForClock.text2StaticLayout.get((int)text2Rect.Width, SKTextAlign.Center, "6", text2TextPaint);

            canvas.Save();
            canvas.ClipRect(text2Rect);
            canvas.Translate(text2Rect.Left, text2Rect.Top + (text2Rect.Height - text2StaticLayout.getHeight()) / 2f);
            text2StaticLayout.draw(canvas);
            canvas.Restore();

            // Text 3
            var text3Rect      = new SKRect(201f, 110f, 239f, 150f);
            var text3TextPaint = CacheForClock.text3TextPaint;

            text3TextPaint.Reset();
            text3TextPaint.IsAntialias = true;
            text3TextPaint.Color       = (SKColor)numbersColor;
            text3TextPaint.Typeface    = TypefaceManager.GetTypeface("Avenir Next.ttc");
            text3TextPaint.TextSize    = 25f;
            StaticLayout text3StaticLayout = CacheForClock.text3StaticLayout.get((int)text3Rect.Width, SKTextAlign.Center, "3", text3TextPaint);

            canvas.Save();
            canvas.ClipRect(text3Rect);
            canvas.Translate(text3Rect.Left, text3Rect.Top + (text3Rect.Height - text3StaticLayout.getHeight()) / 2f);
            text3StaticLayout.draw(canvas);
            canvas.Restore();

            // Text 4
            var text4Rect      = new SKRect(22f, 110f, 60f, 150f);
            var text4TextPaint = CacheForClock.text4TextPaint;

            text4TextPaint.Reset();
            text4TextPaint.IsAntialias = true;
            text4TextPaint.Color       = (SKColor)numbersColor;
            text4TextPaint.Typeface    = TypefaceManager.GetTypeface("Avenir Next.ttc");
            text4TextPaint.TextSize    = 25f;
            StaticLayout text4StaticLayout = CacheForClock.text4StaticLayout.get((int)text4Rect.Width, SKTextAlign.Center, "9", text4TextPaint);

            canvas.Save();
            canvas.ClipRect(text4Rect);
            canvas.Translate(text4Rect.Left, text4Rect.Top + (text4Rect.Height - text4StaticLayout.getHeight()) / 2f);
            text4StaticLayout.draw(canvas);
            canvas.Restore();

            // Text 13
            var text13Rect      = new SKRect(99f, 144f, 161f, 178f);
            var text13TextPaint = CacheForClock.text13TextPaint;

            text13TextPaint.Reset();
            text13TextPaint.IsAntialias = true;
            text13TextPaint.Color       = (SKColor)numbersColor;
            text13TextPaint.Typeface    = TypefaceManager.GetTypeface("Avenir Next.ttc");
            text13TextPaint.TextSize    = 20f;
            StaticLayout text13StaticLayout = CacheForClock.text13StaticLayout.get((int)text13Rect.Width, SKTextAlign.Center, expression, text13TextPaint);

            canvas.Save();
            canvas.ClipRect(text13Rect);
            canvas.Translate(text13Rect.Left, text13Rect.Top + (text13Rect.Height - text13StaticLayout.getHeight()) / 2f);
            text13StaticLayout.draw(canvas);
            canvas.Restore();

            canvas.Restore();
        }
        private SKPath ReadElement(XElement e)
        {
            var path = new SKPath();

            var elementName = e.Name.LocalName;

            switch (elementName)
            {
            case "rect":
                var rect = ReadRoundedRect(e);
                if (rect.IsRounded)
                {
                    path.AddRoundedRect(rect.Rect, rect.RadiusX, rect.RadiusY);
                }
                else
                {
                    path.AddRect(rect.Rect);
                }
                break;

            case "ellipse":
                var oval = ReadOval(e);
                path.AddOval(oval.BoundingRect);
                break;

            case "circle":
                var circle = ReadCircle(e);
                path.AddCircle(circle.Center.X, circle.Center.Y, circle.Radius);
                break;

            case "path":
                var d = e.Attribute("d")?.Value;
                if (!string.IsNullOrWhiteSpace(d))
                {
                    path.Dispose();
                    path = SKPath.ParseSvgPathData(d);
                }
                break;

            case "polygon":
            case "polyline":
                var close = elementName == "polygon";
                var p     = e.Attribute("points")?.Value;
                if (!string.IsNullOrWhiteSpace(p))
                {
                    p = "M" + p;
                    if (close)
                    {
                        p += " Z";
                    }
                    path.Dispose();
                    path = SKPath.ParseSvgPathData(p);
                }
                break;

            case "line":
                var line = ReadLine(e);
                path.MoveTo(line.P1);
                path.LineTo(line.P2);
                break;

            default:
                path.Dispose();
                path = null;
                break;
            }

            return(path);
        }
        private void DrawCareerSymbol(SKCanvas canvas, SKRect rect_Career, EnumCareerType whatCareer)
        {
            _symbolHeightWidth = rect_Career.Height;
            SKPath  gp_Career;
            SKPaint pn_Career;

            SKPoint[] pts_Curve  = new SKPoint[3];
            SKMatrix  tmp_Matrix = new SKMatrix();

            canvas.DrawOval(rect_Career, _steelBluePaint);
            switch (whatCareer)
            {
            case EnumCareerType.Artist:
            {
                tmp_Matrix.RotateAt(45, new SKPoint(rect_Career.Left + (rect_Career.Width / 2), rect_Career.Top + (rect_Career.Height / 2)));
                gp_Career = new SKPath();
                gp_Career.AddRect(SKRect.Create(rect_Career.Left + ActualSize(9), rect_Career.Top + ActualSize(7), ActualSize(2), ActualSize(11)));
                pts_Curve    = new SKPoint[6];
                pts_Curve[0] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(7));
                pts_Curve[1] = new SKPoint(rect_Career.Left + ActualSize(9), rect_Career.Top + ActualSize(4));
                pts_Curve[2] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(1));
                pts_Curve[3] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(1));
                pts_Curve[4] = new SKPoint(rect_Career.Left + ActualSize(11), rect_Career.Top + ActualSize(4));
                pts_Curve[5] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(7));
                gp_Career.AddPoly(pts_Curve);
                gp_Career.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Career, _whitePaint);
                break;
            }

            case EnumCareerType.Athlete:
            {
                gp_Career = new SKPath();
                gp_Career.AddLine(rect_Career.Left + ActualSize(14), rect_Career.Top + ActualSize(3), rect_Career.Left + ActualSize(6), rect_Career.Top + ActualSize(3), true);
                gp_Career.ArcTo(SKRect.Create(rect_Career.Left + ActualSize(6), rect_Career.Top + ActualSize(3), ActualSize(5), ActualSize(8)), 180, -90, false);
                gp_Career.AddLine(rect_Career.Left + ActualSize(9), rect_Career.Top + ActualSize(15), rect_Career.Left + ActualSize(9), rect_Career.Top + ActualSize(16));
                gp_Career.AddLine(rect_Career.Left + ActualSize(9), rect_Career.Top + ActualSize(16), rect_Career.Left + ActualSize(7), rect_Career.Top + ActualSize(16));
                gp_Career.AddLine(rect_Career.Left + ActualSize(7), rect_Career.Top + ActualSize(16), rect_Career.Left + ActualSize(7), rect_Career.Top + ActualSize(18));
                gp_Career.AddLine(rect_Career.Left + ActualSize(7), rect_Career.Top + ActualSize(18), rect_Career.Left + ActualSize(13), rect_Career.Top + ActualSize(18));
                gp_Career.AddLine(rect_Career.Left + ActualSize(13), rect_Career.Top + ActualSize(18), rect_Career.Left + ActualSize(13), rect_Career.Top + ActualSize(16));
                gp_Career.AddLine(rect_Career.Left + ActualSize(13), rect_Career.Top + ActualSize(16), rect_Career.Left + ActualSize(11), rect_Career.Top + ActualSize(16));
                gp_Career.AddLine(rect_Career.Left + ActualSize(11), rect_Career.Top + ActualSize(16), rect_Career.Left + ActualSize(11), rect_Career.Top + ActualSize(15));
                gp_Career.ArcTo(SKRect.Create(rect_Career.Left + ActualSize(9), rect_Career.Top + ActualSize(3), ActualSize(5), ActualSize(8)), 90, -90, false);
                gp_Career.Close();
                canvas.DrawPath(gp_Career, _whitePaint);
                pts_Curve[0] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(3));
                pts_Curve[1] = new SKPoint(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(7));
                pts_Curve[2] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(12));
                canvas.DrawLines(pts_Curve, _whiteBorder !);
                pts_Curve[0] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(3));
                pts_Curve[1] = new SKPoint(rect_Career.Left + ActualSize(16), rect_Career.Top + ActualSize(7));
                pts_Curve[2] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(12));
                canvas.DrawLines(pts_Curve, _whiteBorder !);
                break;
            }

            case EnumCareerType.Entertainer:
            {
                gp_Career = new SKPath();
                gp_Career.AddLine(rect_Career.Left + ActualSize(10), rect_Career.Top, rect_Career.Left + ActualSize(8), rect_Career.Top + ActualSize(7), true);
                gp_Career.AddLine(rect_Career.Left + ActualSize(2), rect_Career.Top + ActualSize(7), rect_Career.Left + ActualSize(7), rect_Career.Top + ActualSize(12));
                gp_Career.AddLine(rect_Career.Left + ActualSize(5), rect_Career.Top + ActualSize(18), rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(14));
                gp_Career.AddLine(rect_Career.Left + ActualSize(15), rect_Career.Top + ActualSize(18), rect_Career.Left + ActualSize(14), rect_Career.Top + ActualSize(12));
                gp_Career.AddLine(rect_Career.Left + ActualSize(18), rect_Career.Top + ActualSize(7), rect_Career.Left + ActualSize(12), rect_Career.Top + ActualSize(7));
                gp_Career.Close();
                canvas.DrawPath(gp_Career, _whitePaint);
                break;
            }

            case EnumCareerType.Doctor:
            {
                pn_Career = MiscHelpers.GetStrokePaint(SKColors.White, ActualSize(6));
                canvas.DrawLine(System.Convert.ToInt32((rect_Career.Left + (rect_Career.Width / 2))), rect_Career.Top + ActualSize(2), System.Convert.ToInt32((rect_Career.Left + (rect_Career.Width / 2))), (rect_Career.Top + rect_Career.Height) - ActualSize(2), pn_Career);
                canvas.DrawLine(rect_Career.Left + ActualSize(2), System.Convert.ToInt32((rect_Career.Top + (rect_Career.Height / 2))), (rect_Career.Left + rect_Career.Width) - ActualSize(2), System.Convert.ToInt32((rect_Career.Top + (rect_Career.Height / 2))), pn_Career);
                break;
            }

            case EnumCareerType.Teacher:
            {
                canvas.DrawOval(SKRect.Create(rect_Career.Left + ActualSize(3), rect_Career.Top + ActualSize(6), ActualSize(14), ActualSize(12)), _whitePaint);
                gp_Career    = new SKPath();
                pts_Curve    = new SKPoint[9];
                pts_Curve[0] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(6));
                pts_Curve[1] = new SKPoint(rect_Career.Left + ActualSize(8), rect_Career.Top + ActualSize(4));
                pts_Curve[2] = new SKPoint(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(2));
                pts_Curve[3] = new SKPoint(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(2));
                pts_Curve[4] = new SKPoint(rect_Career.Left + ActualSize(5), rect_Career.Top + ActualSize(5));
                pts_Curve[5] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(6));
                pts_Curve[6] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(6));
                pts_Curve[7] = new SKPoint(rect_Career.Left + ActualSize(12), rect_Career.Top + ActualSize(4));
                pts_Curve[8] = new SKPoint(rect_Career.Left + ActualSize(13), rect_Career.Top + ActualSize(2));
                gp_Career.AddPoly(pts_Curve);
                canvas.DrawPath(gp_Career, _whitePaint);
                break;
            }

            case EnumCareerType.Accountant:
            {
                var TextPaint = MiscHelpers.GetTextPaint(SKColors.White, ActualSize(16), "Times New Roman");
                canvas.DrawCustomText("$", TextExtensions.EnumLayoutOptions.Center, TextExtensions.EnumLayoutOptions.Center, TextPaint, rect_Career, out _);
                break;
            }

            case EnumCareerType.PoliceOfficer:
            {
                gp_Career     = new SKPath();
                pts_Curve     = new SKPoint[18];
                pts_Curve[0]  = new SKPoint(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(4));
                pts_Curve[1]  = new SKPoint(rect_Career.Left + ActualSize(7), rect_Career.Top + ActualSize(6));
                pts_Curve[2]  = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(4));
                pts_Curve[3]  = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(4));
                pts_Curve[4]  = new SKPoint(rect_Career.Left + ActualSize(13), rect_Career.Top + ActualSize(6));
                pts_Curve[5]  = new SKPoint(rect_Career.Left + ActualSize(16), rect_Career.Top + ActualSize(4));
                pts_Curve[6]  = new SKPoint(rect_Career.Left + ActualSize(17), rect_Career.Top + ActualSize(5));
                pts_Curve[7]  = new SKPoint(rect_Career.Left + ActualSize(16), rect_Career.Top + ActualSize(6));
                pts_Curve[8]  = new SKPoint(rect_Career.Left + ActualSize(16), rect_Career.Top + ActualSize(7));
                pts_Curve[9]  = new SKPoint(rect_Career.Left + ActualSize(16), rect_Career.Top + ActualSize(7));
                pts_Curve[10] = new SKPoint(rect_Career.Left + ActualSize(15), rect_Career.Top + ActualSize(14));
                pts_Curve[11] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(18));
                pts_Curve[12] = new SKPoint(rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(18));
                pts_Curve[13] = new SKPoint(rect_Career.Left + ActualSize(5), rect_Career.Top + ActualSize(14));
                pts_Curve[14] = new SKPoint(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(7));
                pts_Curve[15] = new SKPoint(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(7));
                pts_Curve[16] = new SKPoint(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(6));
                pts_Curve[17] = new SKPoint(rect_Career.Left + ActualSize(3), rect_Career.Top + ActualSize(5));
                gp_Career.AddPoly(pts_Curve);
                canvas.DrawPath(gp_Career, _whitePaint);
                break;
            }

            case EnumCareerType.SalesPerson:
            {
                gp_Career = new SKPath();
                gp_Career.AddLine(rect_Career.Left + ActualSize(2), rect_Career.Top + ActualSize(10), rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(18));
                gp_Career.AddLine(rect_Career.Left + ActualSize(18), rect_Career.Top + ActualSize(10), rect_Career.Left + ActualSize(10), rect_Career.Top + ActualSize(2));
                gp_Career.AddLine(rect_Career.Left + ActualSize(6), rect_Career.Top + ActualSize(2), rect_Career.Left + ActualSize(2), rect_Career.Top + ActualSize(6));
                gp_Career.Close();
                gp_Career.AddOval(SKRect.Create(rect_Career.Left + ActualSize(4), rect_Career.Top + ActualSize(4), ActualSize(2), ActualSize(2)));
                canvas.DrawPath(gp_Career, _whitePaint);
                break;
            }

            case EnumCareerType.ComputerConsultant:
            {
                canvas.DrawRect(SKRect.Create(rect_Career.Left + ActualSize(5), rect_Career.Top + ActualSize(2), ActualSize(10), ActualSize(8)), _whitePaint);
                canvas.DrawRect(SKRect.Create(rect_Career.Left + ActualSize(3), rect_Career.Top + ActualSize(12), ActualSize(14), ActualSize(4)), _whitePaint);
                break;
            }
            }
            canvas.DrawRect(rect_Career, _whiteBorder);
        }
Exemple #29
0
    public static SKPath ToSKPath(this IEnumerable <BaseShapeViewModel> shapes)
    {
        var path = new SKPath
        {
            FillType = SKPathFillType.Winding
        };
        var previous = default(PointShapeViewModel);

        foreach (var shape in shapes)
        {
            switch (shape)
            {
            case LineShapeViewModel lineShape:
            {
                if (previous is null || previous != lineShape.Start)
                {
                    path.MoveTo(
                        (float)(lineShape.Start.X),
                        (float)(lineShape.Start.Y));
                }
                path.LineTo(
                    (float)(lineShape.End.X),
                    (float)(lineShape.End.Y));
                previous = lineShape.End;
            }
            break;

            case RectangleShapeViewModel rectangleShape:
            {
                path.AddRect(
                    SkiaSharpDrawUtil.CreateRect(rectangleShape.TopLeft, rectangleShape.BottomRight),
                    SKPathDirection.Clockwise);
            }
            break;

            case EllipseShapeViewModel ellipseShape:
            {
                path.AddOval(
                    SkiaSharpDrawUtil.CreateRect(ellipseShape.TopLeft, ellipseShape.BottomRight),
                    SKPathDirection.Clockwise);
            }
            break;

            case ArcShapeViewModel arcShape:
            {
                var a = new GdiArc(
                    Point2.FromXY(arcShape.Point1.X, arcShape.Point1.Y),
                    Point2.FromXY(arcShape.Point2.X, arcShape.Point2.Y),
                    Point2.FromXY(arcShape.Point3.X, arcShape.Point3.Y),
                    Point2.FromXY(arcShape.Point4.X, arcShape.Point4.Y));
                var rect = new SKRect(
                    (float)(a.X),
                    (float)(a.Y),
                    (float)(a.X + a.Width),
                    (float)(a.Y + a.Height));
                path.AddArc(rect, (float)a.StartAngle, (float)a.SweepAngle);
            }
            break;

            case CubicBezierShapeViewModel cubicBezierShape:
            {
                if (previous is null || previous != cubicBezierShape.Point1)
                {
                    path.MoveTo(
                        (float)(cubicBezierShape.Point1.X),
                        (float)(cubicBezierShape.Point1.Y));
                }
                path.CubicTo(
                    (float)(cubicBezierShape.Point2.X),
                    (float)(cubicBezierShape.Point2.Y),
                    (float)(cubicBezierShape.Point3.X),
                    (float)(cubicBezierShape.Point3.Y),
                    (float)(cubicBezierShape.Point4.X),
                    (float)(cubicBezierShape.Point4.Y));
                previous = cubicBezierShape.Point4;
            }
            break;

            case QuadraticBezierShapeViewModel quadraticBezierShape:
            {
                if (previous is null || previous != quadraticBezierShape.Point1)
                {
                    path.MoveTo(
                        (float)(quadraticBezierShape.Point1.X),
                        (float)(quadraticBezierShape.Point1.Y));
                }
                path.QuadTo(
                    (float)(quadraticBezierShape.Point2.X),
                    (float)(quadraticBezierShape.Point2.Y),
                    (float)(quadraticBezierShape.Point3.X),
                    (float)(quadraticBezierShape.Point3.Y));
                previous = quadraticBezierShape.Point3;
            }
            break;

            case TextShapeViewModel textShape:
            {
                var resultPath = ToSKPath(textShape);
                if (resultPath is { } && !resultPath.IsEmpty)
                {
                    path.AddPath(resultPath, SKPathAddMode.Append);
                }
            }
            break;
Exemple #30
0
        public void DrawImage(SKCanvas canvas, SKRect rect_Card)
        {
            SKPath  gp_Card;
            SKPaint tempPen;

            SKPoint[] pts;
            int       int_Temp;
            SKMatrix  tmp_Matrix;
            SKRegion  reg_Temp;
            SKPoint   pt_Center;

            pt_Center = new SKPoint(rect_Card.Left + (rect_Card.Width / 2), rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Width / 100));
            SKPaint textPaint;
            SKPaint textBorder;

            switch (Category)
            {
            case EnumCompleteCategories.Accident:
                gp_Card = new SKPath();
                gp_Card.AddLine(System.Convert.ToInt32(((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 8))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 10))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2) + (rect_Card.Width / 8))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 10))), true);
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 3) / 4))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 9) / 10))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))));
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 9) / 10))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 8))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 10))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 8))));
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 10))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 4))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))));
                gp_Card.Close();     // i think
                canvas.DrawPath(gp_Card, _basicPen);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create((rect_Card.Left + (rect_Card.Width / 4)) - (rect_Card.Width / 12), (rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 8)) - (rect_Card.Width / 12), rect_Card.Width / 6, rect_Card.Width / 6));
                canvas.DrawPath(gp_Card, _whitePaint);
                canvas.DrawPath(gp_Card, _basicPen);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create((rect_Card.Left + ((rect_Card.Width * 3) / 4)) - (rect_Card.Width / 12), (rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 8)) - (rect_Card.Width / 12), rect_Card.Width / 6, rect_Card.Width / 6));
                canvas.DrawPath(gp_Card, _whitePaint);
                canvas.DrawPath(gp_Card, _basicPen);
                tempPen = MiscHelpers.GetStrokePaint(SKColors.Red, rect_Card.Width / 30);
                canvas.DrawLine(System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 3) / 4))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 19) / 20))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 10))), tempPen);
                canvas.DrawLine(System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 3) / 4))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 10))), System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 19) / 20))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), tempPen);
                break;

            case EnumCompleteCategories.OutOfGas:
                tempPen  = MiscHelpers.GetStrokePaint(SKColors.Black, rect_Card.Height / 40);
                int_Temp = (int)rect_Card.Width;
                gp_Card  = new SKPath();
                gp_Card.AddArc(SKRect.Create(rect_Card.Left - (int_Temp / 2) + (rect_Card.Width / 2), rect_Card.Top + (rect_Card.Height / 3), int_Temp, int_Temp), -135, 90);
                canvas.DrawPath(gp_Card, tempPen);
                tempPen           = MiscHelpers.GetStrokePaint(SKColors.Red, rect_Card.Height / 40);
                tempPen.StrokeCap = SKStrokeCap.Round;     // strokejoin did not help one bit
                canvas.DrawLine(rect_Card.Left + (rect_Card.Width / 2), rect_Card.Top + (rect_Card.Height / 3) + (int_Temp / 2), rect_Card.Width / 3.5f, rect_Card.Height / 2.16f, tempPen);
                var ThisPaint = MiscHelpers.GetTextPaint(SKColors.Red, rect_Card.Height / 4, "Ariel");
                ThisPaint.FakeBoldText = true;
                canvas.DrawText("E", rect_Card.Left + (rect_Card.Width / 10), rect_Card.Top + (rect_Card.Height / 3), ThisPaint);
                ThisPaint = MiscHelpers.GetTextPaint(SKColors.Black, rect_Card.Height / 4, "Ariel");
                ThisPaint.FakeBoldText = true;
                canvas.DrawText("F", rect_Card.Left + ((rect_Card.Width * 15) / 20), rect_Card.Top + (rect_Card.Height / 3), ThisPaint);
                break;

            case EnumCompleteCategories.FlatTire:
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 6), pt_Center.Y - ((rect_Card.Width * 4) / 12), (rect_Card.Width * 4) / 6, (rect_Card.Width * 4) / 6));
                reg_Temp = MiscHelpers.GetNewRegion(SKRect.Create(rect_Card.Left + (rect_Card.Width / 6), (pt_Center.Y - ((rect_Card.Width * 4) / 12)) + ((((rect_Card.Width * 4) / 6) * 5) / 6), (rect_Card.Width * 4) / 6, (rect_Card.Width * 4) / 6));
                var OtherRegion = new SKRegion(reg_Temp);
                reg_Temp.SetPath(gp_Card);
                canvas.DrawRegion(reg_Temp, _redFill);
                reg_Temp.SetPath(gp_Card, OtherRegion);
                canvas.DrawRegion(reg_Temp, _whitePaint);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + ((rect_Card.Width * 2) / 6), pt_Center.Y - ((rect_Card.Width * 2) / 12), (rect_Card.Width * 2) / 6, (rect_Card.Width * 2) / 6));
                canvas.DrawPath(gp_Card, _whitePaint);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 3) + (rect_Card.Width / 12), pt_Center.Y - (rect_Card.Width / 12), rect_Card.Width / 6, rect_Card.Width / 6));
                canvas.DrawPath(gp_Card, _blackPaint);
                break;

            case EnumCompleteCategories.SpeedLimit:
                textPaint  = MiscHelpers.GetTextPaint(SKColors.Black, rect_Card.Height / 3);
                textBorder = MiscHelpers.GetStrokePaint(SKColors.Black, 1);     // for speed limit, 1 is fine
                canvas.DrawBorderText("50", TextExtensions.EnumLayoutOptions.Center, TextExtensions.EnumLayoutOptions.Center, textPaint, textBorder, rect_Card);
                tempPen = MiscHelpers.GetStrokePaint(SKColors.Red, rect_Card.Width / 10);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 8), (rect_Card.Top + (rect_Card.Height / 2)) - ((rect_Card.Width * 3) / 8), (rect_Card.Width * 3) / 4, (rect_Card.Width * 3) / 4));
                canvas.DrawPath(gp_Card, tempPen);
                break;

            case EnumCompleteCategories.Stop:
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 6), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Width / 6), rect_Card.Width / 3, rect_Card.Width / 3));
                canvas.DrawPath(gp_Card, _grayPaint);
                tmp_Matrix = SKMatrix.MakeTranslation(0, (rect_Card.Width * 5) / 13);
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, _grayPaint);
                tmp_Matrix = SKMatrix.MakeTranslation(0, (-rect_Card.Width * 10) / 13);
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, _redFill);
                break;

            case EnumCompleteCategories.Repairs:
                gp_Card  = new SKPath();
                reg_Temp = MiscHelpers.GetNewRegion(SKRect.Create(rect_Card.Left + (rect_Card.Width / 3), rect_Card.Top, rect_Card.Width / 3, rect_Card.Height / 3));
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 6), rect_Card.Top + (rect_Card.Height / 10), (rect_Card.Width * 4) / 6, (rect_Card.Height * 3) / 7));
                gp_Card.AddRect(SKRect.Create(rect_Card.Left + (rect_Card.Width / 3), rect_Card.Top + (rect_Card.Height / 2), rect_Card.Width / 3, (rect_Card.Height * 4) / 9));
                var OtherRegion2 = new SKRegion(reg_Temp);
                reg_Temp.SetPath(gp_Card);
                canvas.DrawRegion(reg_Temp, _greenPaint);
                reg_Temp.SetPath(gp_Card, OtherRegion2);
                canvas.DrawRegion(reg_Temp, _whitePaint);
                gp_Card = new SKPath();
                gp_Card.AddRect(SKRect.Create((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 12), rect_Card.Top + (rect_Card.Height / 8), rect_Card.Width / 6, rect_Card.Height / 7));
                canvas.DrawPath(gp_Card, _blackPaint);
                break;

            case EnumCompleteCategories.Gasoline:
                gp_Card = new SKPath();
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 4))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 4))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 4))), true);
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 4))), System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 3) / 4))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 3))));
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 3) / 4))), System.Convert.ToInt32((rect_Card.Top + ((rect_Card.Height * 3) / 4))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 4))), System.Convert.ToInt32((rect_Card.Top + ((rect_Card.Height * 3) / 4))));
                gp_Card.Close();
                canvas.DrawPath(gp_Card, _greenPaint);
                gp_Card = new SKPath();
                gp_Card.AddRect(SKRect.Create(rect_Card.Left, rect_Card.Top, rect_Card.Width / 8, rect_Card.Height / 20));
                tmp_Matrix        = SKMatrix.MakeRotationDegrees(23, rect_Card.Left, rect_Card.Top);
                tmp_Matrix.TransX = (rect_Card.Width * 20) / 30;
                tmp_Matrix.TransY = rect_Card.Height / 5.4f;
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, _greenPaint);
                break;

            case EnumCompleteCategories.Spare:
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 6), pt_Center.Y - ((rect_Card.Width * 4) / 12), (rect_Card.Width * 4) / 6, (rect_Card.Width * 4) / 6));
                reg_Temp = MiscHelpers.GetNewRegion(SKRect.Create(rect_Card.Left + (rect_Card.Width / 6), (pt_Center.Y - ((rect_Card.Width * 4) / 12)) + ((((rect_Card.Width * 4) / 6) * 5) / 6), (rect_Card.Width * 4) / 6, (rect_Card.Width * 4) / 6));
                reg_Temp.SetPath(gp_Card);
                canvas.DrawRegion(reg_Temp, _greenPaint);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + ((rect_Card.Width * 2) / 6), pt_Center.Y - ((rect_Card.Width * 2) / 12), (rect_Card.Width * 2) / 6, (rect_Card.Width * 2) / 6));
                canvas.DrawPath(gp_Card, _whitePaint);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 3) + (rect_Card.Width / 12), pt_Center.Y - (rect_Card.Width / 12), rect_Card.Width / 6, rect_Card.Width / 6));
                canvas.DrawPath(gp_Card, _blackPaint);
                break;

            case EnumCompleteCategories.EndOfLimit:
                textPaint              = MiscHelpers.GetTextPaint(SKColors.Gray, rect_Card.Height / 3);
                textBorder             = MiscHelpers.GetStrokePaint(SKColors.Black, 1); // for speed limit, 1 is fine
                textPaint.FakeBoldText = true;
                canvas.DrawBorderText("50", TextExtensions.EnumLayoutOptions.Center, TextExtensions.EnumLayoutOptions.Center, textPaint, textBorder, rect_Card);
                tempPen = MiscHelpers.GetStrokePaint(SKColors.Green, rect_Card.Width / 10);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 8), (rect_Card.Top + (rect_Card.Height / 2)) - ((rect_Card.Width * 3) / 8), (rect_Card.Width * 3) / 4, (rect_Card.Width * 3) / 4));
                canvas.DrawPath(gp_Card, tempPen);
                gp_Card = new SKPath();
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - ((rect_Card.Width * 3) / 8))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2) + ((rect_Card.Width * 3) / 8))), true);
                tmp_Matrix = SKMatrix.MakeRotationDegrees(45, pt_Center.X, pt_Center.Y);
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, tempPen);
                break;

            case EnumCompleteCategories.Roll:
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 6), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Width / 6), rect_Card.Width / 3, rect_Card.Width / 3));
                canvas.DrawPath(gp_Card, _grayPaint);
                tmp_Matrix = SKMatrix.MakeTranslation(0, (rect_Card.Width * 5) / 13);
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, _greenPaint);
                tmp_Matrix = SKMatrix.MakeTranslation(0, (-rect_Card.Width * 10) / 13);
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, _grayPaint);
                break;

            case EnumCompleteCategories.DrivingAce:
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 10), (rect_Card.Top + (rect_Card.Height / 2)) - ((rect_Card.Width * 4) / 10), (rect_Card.Width * 8) / 10, (rect_Card.Width * 8) / 10));
                tempPen = MiscHelpers.GetStrokePaint(SKColors.Blue, rect_Card.Width / 20);
                canvas.DrawPath(gp_Card, tempPen);
                tmp_Matrix = SKMatrix.MakeRotationDegrees(120, pt_Center.X, pt_Center.Y);
                gp_Card    = new SKPath();
                gp_Card.AddLine(System.Convert.ToInt32(((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 25))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2) + ((rect_Card.Width * 4) / 10))), System.Convert.ToInt32(((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 15))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), true);
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2) + (rect_Card.Width / 15))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2) + (rect_Card.Width / 25))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2) + ((rect_Card.Width * 4) / 10))));
                gp_Card.Close();
                canvas.DrawPath(gp_Card, _safefyPaint);
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, _safefyPaint);
                gp_Card.Transform(tmp_Matrix);
                canvas.DrawPath(gp_Card, _safefyPaint);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 8), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Width / 8), rect_Card.Width / 4, rect_Card.Width / 4));
                canvas.DrawPath(gp_Card, _whitePaint);
                canvas.DrawPath(gp_Card, tempPen);
                break;

            case EnumCompleteCategories.ExtraTank:
                gp_Card = new SKPath();
                pts     = new SKPoint[3];
                pts[0]  = new SKPoint(rect_Card.Left + (rect_Card.Width / 4), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 8));
                pts[1]  = new SKPoint(rect_Card.Left + (rect_Card.Width / 6), rect_Card.Top + (rect_Card.Height / 2));
                pts[2]  = new SKPoint(rect_Card.Left + (rect_Card.Width / 4), rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 8));
                var top1 = pts[0];
                gp_Card.MoveTo(pts[0]);
                gp_Card.QuadTo(pts[1], pts[2]);
                pts[0] = new SKPoint(rect_Card.Left + ((rect_Card.Width * 3) / 4), rect_Card.Top + (rect_Card.Height / 2) + (rect_Card.Height / 8));
                pts[1] = new SKPoint(rect_Card.Left + ((rect_Card.Width * 5) / 6), rect_Card.Top + (rect_Card.Height / 2));
                pts[2] = new SKPoint(rect_Card.Left + ((rect_Card.Width * 3) / 4), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 8));
                var bottom2 = pts[0];
                gp_Card.MoveTo(pts[0]);
                gp_Card.QuadTo(pts[1], pts[2]);
                var tempRect = new SKRect(top1.X, top1.Y, bottom2.X, bottom2.Y);
                gp_Card.Close();
                canvas.DrawPath(gp_Card, _safefyPaint);
                gp_Card = new SKPath();
                gp_Card.AddRect(SKRect.Create(rect_Card.Left + ((rect_Card.Width * 2) / 5), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 8) - (rect_Card.Height / 20), rect_Card.Width / 5, rect_Card.Height / 30));
                canvas.DrawPath(gp_Card, _safefyPaint);
                canvas.DrawRect(tempRect, _safefyPaint);
                break;

            case EnumCompleteCategories.PunctureProof:
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 6), pt_Center.Y - ((rect_Card.Width * 4) / 12), (rect_Card.Width * 4) / 6, (rect_Card.Width * 4) / 6));
                reg_Temp = MiscHelpers.GetNewRegion(SKRect.Create(rect_Card.Left + (rect_Card.Width / 6), (pt_Center.Y - ((rect_Card.Width * 4) / 12)) + ((((rect_Card.Width * 4) / 6) * 5) / 6), (rect_Card.Width * 4) / 6, (rect_Card.Width * 4) / 6));
                reg_Temp.SetPath(gp_Card);
                canvas.DrawRegion(reg_Temp, _safefyPaint);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + ((rect_Card.Width * 2) / 6), pt_Center.Y - ((rect_Card.Width * 2) / 12), (rect_Card.Width * 2) / 6, (rect_Card.Width * 2) / 6));
                canvas.DrawPath(gp_Card, _whitePaint);
                gp_Card = new SKPath();
                gp_Card.AddOval(SKRect.Create(rect_Card.Left + (rect_Card.Width / 3) + (rect_Card.Width / 12), pt_Center.Y - (rect_Card.Width / 12), rect_Card.Width / 6, rect_Card.Width / 6));
                canvas.DrawPath(gp_Card, _blackPaint);
                tmp_Matrix = SKMatrix.MakeTranslation(rect_Card.Width / 12, 0);
                gp_Card    = new SKPath();
                gp_Card.AddLine(rect_Card.Left, rect_Card.Top + (rect_Card.Height * 4 / 5) + (rect_Card.Width / 24), rect_Card.Left + (rect_Card.Width / 24), rect_Card.Top + (rect_Card.Height * 4 / 5 - (rect_Card.Width / 24)), true);
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 24))), System.Convert.ToInt32(((rect_Card.Top + ((rect_Card.Height * 4) / 5)) - (rect_Card.Width / 24))), System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 12))), System.Convert.ToInt32((rect_Card.Top + ((rect_Card.Height * 4) / 5) + (rect_Card.Width / 24))));
                for (var int_Count = 1; int_Count <= 10; int_Count++)
                {
                    gp_Card.Transform(tmp_Matrix);
                    canvas.DrawPath(gp_Card, _safefyPaint);
                }
                break;

            case EnumCompleteCategories.RightOfWay:
                tempPen = MiscHelpers.GetStrokePaint(SKColors.Blue, rect_Card.Width / 50);
                gp_Card = new SKPath();
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 10))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 5))), System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 9) / 10))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), true);
                canvas.DrawPath(gp_Card, tempPen);
                gp_Card = new SKPath();
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 10))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 10))), System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 9) / 10))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 10))), true);
                canvas.DrawPath(gp_Card, tempPen);
                gp_Card = new SKPath();
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 10))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), System.Convert.ToInt32((rect_Card.Left + ((rect_Card.Width * 9) / 10))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 5))), true);
                canvas.DrawPath(gp_Card, tempPen);
                gp_Card = new SKPath();
                canvas.DrawPath(gp_Card, _whitePaint);
                gp_Card = new SKPath();
                pts     = new SKPoint[3];
                pts[0]  = new SKPoint((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 6), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 5));
                pts[1]  = new SKPoint(rect_Card.Left + (rect_Card.Width / 2), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 4));
                pts[2]  = new SKPoint(rect_Card.Left + (rect_Card.Width / 2) + (rect_Card.Width / 6), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 5));
                gp_Card.MoveTo(pts[0]);
                gp_Card.QuadTo(pts[1], pts[2]);
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2) + (rect_Card.Width / 6))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))), System.Convert.ToInt32(((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 6))), System.Convert.ToInt32((rect_Card.Top + (rect_Card.Height / 2))));
                gp_Card.Close();
                canvas.DrawPath(gp_Card, _safefyPaint);
                gp_Card = new SKPath();
                pts     = new SKPoint[3];
                pts[0]  = new SKPoint((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 12), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 8));
                pts[1]  = new SKPoint(rect_Card.Left + (rect_Card.Width / 2), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 6));
                pts[2]  = new SKPoint(rect_Card.Left + (rect_Card.Width / 2) + (rect_Card.Width / 12), (rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 8));
                gp_Card.MoveTo(pts[0]);
                gp_Card.QuadTo(pts[1], pts[2]);
                gp_Card.AddLine(System.Convert.ToInt32((rect_Card.Left + (rect_Card.Width / 2) + (rect_Card.Width / 12))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 20))), System.Convert.ToInt32(((rect_Card.Left + (rect_Card.Width / 2)) - (rect_Card.Width / 12))), System.Convert.ToInt32(((rect_Card.Top + (rect_Card.Height / 2)) - (rect_Card.Height / 20))));
                gp_Card.Close();
                canvas.DrawPath(gp_Card, _whitePaint);
                canvas.DrawRect(SKRect.Create(rect_Card.Left + (rect_Card.Width / 4), rect_Card.Top + (rect_Card.Height / 2), rect_Card.Width / 2, rect_Card.Height / 10), _blackPaint);
                break;

            case EnumCompleteCategories.Distance25:
                DrawDistanceCard(canvas, "25", rect_Card);
                break;

            case EnumCompleteCategories.Distance50:
                DrawDistanceCard(canvas, "50", rect_Card);
                break;

            case EnumCompleteCategories.Distance75:
                DrawDistanceCard(canvas, "75", rect_Card);
                break;

            case EnumCompleteCategories.Distance100:
                DrawDistanceCard(canvas, "100", rect_Card);
                break;

            case EnumCompleteCategories.Distance200:
                DrawDistanceCard(canvas, "200", rect_Card);
                break;

            default:
                throw new BasicBlankException("Nothing Found");
            }
        }