public static void DrawLargerDiamond(this SKCanvas thisCanvas, SKRect thisRect, SKPaint solidPaint, SKPaint?borderPaint) { TempPosition temps = GetTempRect(thisRect); SKPoint firstPoint; SKPoint secondPoint; SKPoint thirdPoint; SKPoint fourthPoint; firstPoint = GetActualPoint(200, 2, temps); secondPoint = GetActualPoint(398, 200, temps); thirdPoint = GetActualPoint(200, 398, temps); fourthPoint = GetActualPoint(2, 200, temps); SKPoint[] pts = new[] { firstPoint, secondPoint, thirdPoint, fourthPoint }; SKPath thisPath = new SKPath(); thisPath.AddLines(pts, true); thisCanvas.DrawPath(thisPath, solidPaint); if (borderPaint != null) { thisCanvas.DrawPath(thisPath, borderPaint); } }
public static void DrawCardSuit(this SKCanvas thisCanvas, EnumSuitList suitCategory, SKRect thisRect, SKPaint solidPaint, SKPaint?borderPaint) { TempPosition temps = GetTempRect(thisRect); if (solidPaint == null) { throw new BasicBlankException("All Cards Must Have Solid Brushes"); } if (borderPaint != null && suitCategory == EnumSuitList.Clubs) { throw new BasicBlankException("Clubs can't have stroke paint currently"); } if (borderPaint != null && suitCategory == EnumSuitList.Spades) { throw new BasicBlankException("Spades can't have stroke paint currently"); } switch (suitCategory) { case EnumSuitList.Clubs: { SKPath thisPath = new SKPath(); //used proportions here. seemed to work great. var firstRect = GetActualRectangle(125, 0, 150, 150, temps); thisPath.AddOval(firstRect, SKPathDirection.Clockwise); var secondRect = GetActualRectangle(0, 150, 150, 150, temps); thisPath.AddOval(secondRect, SKPathDirection.Clockwise); var thirdRect = GetActualRectangle(250, 150, 150, 150, temps); thisPath.AddOval(thirdRect, SKPathDirection.Clockwise); SKPoint point1; SKPoint point2; point1 = GetActualPoint(185, 150, temps); point2 = GetActualPoint(150, 200, temps); thisPath.MoveTo(point1); point1 = GetActualPoint(175, 180, temps); thisPath.QuadTo(point1, point2); point2 = GetActualPoint(150, 250, temps); thisPath.LineTo(point2); point1 = GetActualPoint(175, 270, temps); point2 = GetActualPoint(175, 280, temps); thisPath.QuadTo(point1, point2); point2 = GetActualPoint(150, 400, temps); thisPath.LineTo(point2); var tempLine = GetActualPoint(250, 400, temps); thisPath.LineTo(tempLine); point1 = GetActualPoint(225, 350, temps); point2 = GetActualPoint(225, 280, temps); thisPath.QuadTo(point1, point2); point1 = GetActualPoint(225, 270, temps); point2 = GetActualPoint(250, 250, temps); thisPath.QuadTo(point1, point2); point2 = GetActualPoint(250, 200, temps); thisPath.LineTo(point2); point1 = GetActualPoint(230, 180, temps); point2 = GetActualPoint(220, 150, temps); thisPath.QuadTo(point1, point2); thisPath.Close(); thisCanvas.DrawPath(thisPath, solidPaint); break; } case EnumSuitList.Diamonds: { SKPoint[] pts = new SKPoint[4]; pts[0] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y); pts[1] = new SKPoint(thisRect.Location.X + (thisRect.Width * 3 / 4), thisRect.Location.Y + (thisRect.Height / 2)); pts[2] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y + thisRect.Height); pts[3] = new SKPoint(thisRect.Location.X + (thisRect.Width / 4), thisRect.Location.Y + (thisRect.Height / 2)); SKPath ThisPath = new SKPath(); ThisPath.AddLines(pts, true); thisCanvas.DrawPath(ThisPath, solidPaint); if (borderPaint == null == false) { thisCanvas.DrawPath(ThisPath, borderPaint); } break; } case EnumSuitList.Hearts: { int avg; avg = System.Convert.ToInt32((thisRect.Width + thisRect.Height) / 2); int radius; radius = System.Convert.ToInt32(avg / (double)2); var topleftcorner = new SKPoint(thisRect.Location.X, thisRect.Location.Y); var topleftsquare = SKRect.Create(topleftcorner.X, topleftcorner.Y, radius, radius); var toprightsquare = SKRect.Create(topleftcorner.X + radius, topleftcorner.Y, radius, radius); var thisPath = new SKPath(); thisPath.ArcTo(topleftsquare, 135, 225, false); thisPath.ArcTo(toprightsquare, 180, 225, false); thisPath.LineTo(radius + thisRect.Location.X, avg + thisRect.Location.Y); thisPath.Close(); thisCanvas.DrawPath(thisPath, solidPaint); if (borderPaint == null == false) { thisCanvas.DrawPath(thisPath, borderPaint); } break; } case EnumSuitList.Spades: { var firstRect = GetActualRectangle(0, 100, 200, 200, temps); thisCanvas.DrawOval(firstRect, solidPaint); var secondRect = GetActualRectangle(200, 100, 200, 200, temps); thisCanvas.DrawOval(secondRect, solidPaint); var nextRect = GetActualRectangle(175, 175, 50, 200, temps); thisCanvas.DrawRect(nextRect, solidPaint); var tempRect = GetActualRectangle(0, 0, 400, 175, temps); thisCanvas.DrawTriangle(tempRect, solidPaint, null !); break; } default: throw new BasicBlankException("Must choose one of the 4 suits to draw"); } }