CAShapeLayer GetMaskShape (ViewMaskerType maskType, Xamarin.Forms.Size size) { var layer = new CAShapeLayer (); layer.FillColor = UIColor.White.CGColor; layer.StrokeColor = UIColor.White.CGColor; layer.LineWidth = 0; UIBezierPath path = null; var bounds = new CGRect (0, 0, size.Width, size.Height); switch (maskType) { case ViewMaskerType.Circle: path = UIBezierPath.FromRoundedRect (bounds, (nfloat)Math.Max (size.Width, size.Height)); break; case ViewMaskerType.Triangle: var point1 = new CGPoint (0, size.Height); var point2 = new CGPoint (size.Width, size.Height); var point3 = new CGPoint (size.Width / 2, 0); path = new UIBezierPath (); path.MoveTo (point1); path.AddLineTo (point2); path.AddLineTo (point3); path.AddLineTo (point1); path.ClosePath (); path.Fill (); break; case ViewMaskerType.Square: var smallRectangle = UIBezierPath.FromRect (bounds.Inset (50, 50)); path = UIBezierPath.FromRoundedRect (bounds, 20); break; default: throw new ArgumentOutOfRangeException (); } layer.Path = path.CGPath; return layer; }
public CalloutAnnotation(int count, CGRect rect, nfloat lineWidth, UIColor color) { Path = UIBezierPath.FromOval(rect); Path.LineWidth = lineWidth; var center = new CGPoint (rect.GetMidX(), rect.GetMidY()); Center = center; nfloat startAngle = (nfloat)(Math.PI * 0.75); nfloat endAngle = (nfloat)(Math.PI * 0.60); Clip = UIBezierPath.FromArc(center, center.X + lineWidth, startAngle, endAngle, true); Clip.AddLineTo(center); Clip.ClosePath(); Clip.LineWidth = lineWidth; Tail = new UIBezierPath (); Tail.MoveTo(new CGPoint (center.X - 11, center.Y + 9)); Tail.AddLineTo(new CGPoint (center.X - 11, center.Y + 18)); Tail.AddLineTo(new CGPoint (center.X - 3, center.Y + 13)); Tail.LineWidth = lineWidth; Rect = rect; Color = color; Count = count; }
public override void Draw (CGRect rect) { TintColor.SetColor (); CGRect bounds = Bounds; float x = (float)bounds.Right - LineWidth; for (int n = 0; n < Count; n++) { x -= LineMargin; if ((n + 1) % LineGroupCount == 0) { UIBezierPath path = new UIBezierPath (); path.MoveTo ( new CGPoint (x + 0.5f * LineWidth, bounds.Top + 0.5f * LineWidth)); path.AddLineTo ( new CGPoint (x + 0.5f * LineWidth + LineGroupCount * LineMargin, bounds.Bottom - 0.5f * LineWidth)); path.Stroke (); } else { CGRect lineRect = bounds; lineRect.X = x; lineRect.Width = LineWidth; UIGraphics.RectFill (lineRect); } } }
public override void LineTo(Point point, bool isStroked, bool isSmoothJoin) { #if XAMARIN_IOS_UNIFIED || XAMARIN_IOS bezierPath.AddLineTo(point); #elif XAMARIN_ANDROID var physicalPoint = LogicalToPhysicalNoRounding(point); bezierPath.LineTo((float)physicalPoint.X, (float)physicalPoint.Y); #endif _points.Add(point); }
public static void DrawArrowIcon(UIColor strokeColor) { //// Group { //// Oval Drawing var ovalPath = UIBezierPath.FromOval(new CGRect(2.0f, 2.0f, 40.0f, 40.0f)); strokeColor.SetStroke(); ovalPath.LineWidth = 1.0f; ovalPath.Stroke(); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(18.77f, 11.03f)); bezierPath.AddLineTo(new CGPoint(29.74f, 22.0f)); bezierPath.AddLineTo(new CGPoint(18.77f, 32.97f)); bezierPath.LineJoinStyle = CGLineJoin.Bevel; strokeColor.SetStroke(); bezierPath.LineWidth = 1.0f; bezierPath.Stroke(); } }
public override void LineTo(Point point, bool isStroked, bool isSmoothJoin) { #if __IOS__ bezierPath.AddLineTo(point); #elif __MACOS__ bezierPath.LineTo(point); #elif __ANDROID__ var physicalPoint = LogicalToPhysicalNoRounding(point); bezierPath.LineTo((float)physicalPoint.X, (float)physicalPoint.Y); #endif _points.Add(point); }
public override void LineTo(Point point, bool isStroked, bool isSmoothJoin) { #if __IOS__ bezierPath.AddLineTo(point); #elif __MACOS__ bezierPath.LineTo(point); #elif __ANDROID__ bezierPath.LineTo((float)point.X, (float)point.Y); #elif __SKIA__ bezierPath.Geometry.LineTo((float)point.X, (float)point.Y); #endif _points.Add(point); }
public override void Draw (CGRect rect) { rect = rect.Inset (4, 4); rect = new CGRect ((rect.Size.Width - rect.Size.Height) / 2 + 4, 8, rect.Size.Height, rect.Size.Height); UIBezierPath path = UIBezierPath.FromOval (rect); UIColor.Black.SetStroke (); UIColor.White.SetFill (); path.LineWidth = 2; path.Fill (); path.Stroke (); UIBezierPath rightEye, leftEye, mouth = new UIBezierPath (); if (MovingRight) { rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30)); mouth.AddLineTo (new CGPoint (rect.GetMidX () + 13, rect.Y + 30)); } else { rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 5, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30)); mouth.AddLineTo (new CGPoint (rect.GetMidX () - 13, rect.Y + 30)); } rightEye.LineWidth = 2; rightEye.Stroke (); leftEye.LineWidth = 2; leftEye.Stroke (); mouth.LineWidth = 2; mouth.Stroke (); }
//// Drawing Methods public static void DrawRefreshIcon(UIColor strokeColor) { //// Group 2 { //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(22.65f, 2.0f)); bezierPath.AddCurveToPoint(new CGPoint(36.33f, 7.67f), new CGPoint(27.6f, 2.0f), new CGPoint(32.55f, 3.89f)); bezierPath.AddCurveToPoint(new CGPoint(38.13f, 32.97f), new CGPoint(43.23f, 14.57f), new CGPoint(43.83f, 25.39f)); bezierPath.AddLineTo(new CGPoint(34.26f, 36.84f)); strokeColor.SetStroke(); bezierPath.LineWidth = 1.0f; bezierPath.Stroke(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new CGPoint(21.35f, 42.0f)); bezier2Path.AddCurveToPoint(new CGPoint(7.67f, 36.33f), new CGPoint(16.4f, 42.0f), new CGPoint(11.45f, 40.11f)); bezier2Path.AddCurveToPoint(new CGPoint(5.87f, 11.03f), new CGPoint(0.77f, 29.43f), new CGPoint(0.17f, 18.61f)); bezier2Path.AddLineTo(new CGPoint(9.74f, 7.16f)); strokeColor.SetStroke(); bezier2Path.LineWidth = 1.0f; bezier2Path.Stroke(); //// Bezier 3 Drawing UIBezierPath bezier3Path = new UIBezierPath(); bezier3Path.MoveTo(new CGPoint(34.26f, 29.74f)); bezier3Path.AddLineTo(new CGPoint(34.26f, 36.84f)); bezier3Path.AddLineTo(new CGPoint(41.35f, 36.84f)); bezier3Path.LineJoinStyle = CGLineJoin.Bevel; strokeColor.SetStroke(); bezier3Path.LineWidth = 1.0f; bezier3Path.Stroke(); //// Bezier 4 Drawing UIBezierPath bezier4Path = new UIBezierPath(); bezier4Path.MoveTo(new CGPoint(9.74f, 14.26f)); bezier4Path.AddLineTo(new CGPoint(9.74f, 7.16f)); bezier4Path.AddLineTo(new CGPoint(2.65f, 7.16f)); bezier4Path.LineJoinStyle = CGLineJoin.Bevel; strokeColor.SetStroke(); bezier4Path.LineWidth = 1.0f; bezier4Path.Stroke(); } }
public override void Draw(CGRect frame) { // General Declarations var context = UIGraphics.GetCurrentContext(); // Color Declarations var color4 = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var color5 = UIColor.FromRGBA(0.793f, 0.793f, 0.793f, 1.000f); // Shadow Declarations var shadow = new NSShadow(); shadow.ShadowColor = UIColor.Black.ColorWithAlpha(0.28f); shadow.ShadowOffset = new CGSize(3.1f, 3.1f); shadow.ShadowBlurRadius = 5.0f; // Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect( new CGRect(frame.GetMinX() + 10.5f, frame.GetMinY() + 7.5f, frame.Width - 20.0f, 76.0f), 4.0f); context.SaveState(); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, shadow.ShadowColor.CGColor); color4.SetFill(); rectanglePath.Fill(); context.RestoreState(); color5.SetStroke(); rectanglePath.LineWidth = 1.0f; rectanglePath.Stroke(); // Bezier 2 Drawing var bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new CGPoint(frame.GetMinX() + 0.02386f*frame.Width, frame.GetMinY() + 0.50543f*frame.Height)); bezier2Path.AddLineTo(new CGPoint(frame.GetMinX() + 0.97841f*frame.Width, frame.GetMinY() + 0.50543f*frame.Height)); context.SaveState(); context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, shadow.ShadowColor.CGColor); color4.SetFill(); bezier2Path.Fill(); context.RestoreState(); color5.SetStroke(); bezier2Path.LineWidth = 1.0f; bezier2Path.Stroke(); }
public override void Draw (CGRect rect) { base.Draw (rect); using (var context = UIGraphics.GetCurrentContext ()) { UIBezierPath mainAxis = UIBezierPath.FromRoundedRect ( new CGRect (xAxisMargin, 0.0f, 2.0f, rect.Height), 2.0f); UIColor.FromRGB ( 203, 203, 203).SetFill(); mainAxis.Fill(); nfloat sepInterval = (nfloat)Math.Floor ((rect.Width - xAxisMargin - xTextMargin)/ 5); for (int i = 1; i < 6; i++) { var separatorAxis = new UIBezierPath(); separatorAxis.MoveTo (new CGPoint (xAxisMargin + sepInterval * i, 0)); separatorAxis.AddLineTo (new CGPoint ( xAxisMargin + sepInterval * i, rect.Height - yAxisMargin)); UIColor.FromRGB ( 203, 203, 203).SetStroke(); separatorAxis.LineWidth = 1.0f; separatorAxis.SetLineDash ( new nfloat[] {1.0f,1.0f}, 1); separatorAxis.Stroke (); var textLayer = new CATextLayer (); textLayer.ContentsScale = UIScreen.MainScreen.Scale; CGFont font = CGFont.CreateWithFontName (LabelFont.Name); if (font != null) { textLayer.SetFont (font); font.Dispose (); } textLayer.FontSize = LabelFont.PointSize; textLayer.AnchorPoint = new CGPoint ( 0.5f, 0.0f); textLayer.AlignmentMode = CATextLayer.AlignmentCenter; textLayer.BackgroundColor = UIColor.Clear.CGColor; textLayer.ForegroundColor = LabelColor.CGColor; CGSize size = ((NSString)"0000 h").StringSize (LabelFont); textLayer.String = "00 h"; textLayer.Bounds = new CGRect (0, 0, size.Width, size.Height); textLayer.Position = new CGPoint ( xAxisMargin + sepInterval * i, rect.Height - yAxisMargin + 5.0f); Layer.AddSublayer (textLayer); xAxisText [i - 1] = textLayer; } } }
public static UIBezierPath ToUIKit(this IEnumerable<Point> points, IViewport viewport) { var pathGeometry = new UIBezierPath (); points = points.ToList(); if (points.Any()) { var first = points.FirstOrDefault (); var start = viewport.WorldToScreen (first); pathGeometry.MoveTo(ToUIKit (start)); for (int i = 1; i < points.Count (); i++) { var point = points.ElementAt (i); var p = viewport.WorldToScreen (point); pathGeometry.AddLineTo (new CGPoint ((float)p.X, (float)p.Y)); } } return pathGeometry; }
public override void Draw(CGRect frame) { var context = UIGraphics.GetCurrentContext(); var expression = 377.0f - percentage; // coverView Drawing var coverViewPath = UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 5.0f, frame.GetMinY() + 4.0f, frame.Width - 10.0f, frame.Height - 10.0f)); UIColor.FromRGB(21, 169, 254).SetFill(); coverViewPath.Fill(); // completedView Drawing context.SaveState(); context.SaveState(); context.TranslateCTM(frame.GetMaxX() - 65.0f, frame.GetMinY() + 64.0f); context.RotateCTM(-90.0f*NMath.PI/180.0f); var completedViewRect = new CGRect(-60.0f, -60.0f, 120.0f, 120.0f); var completedViewPath = new UIBezierPath(); completedViewPath.AddArc(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()), completedViewRect.Width/2.0f, -360.0f*NMath.PI/180, -(expression - 17.0f)*NMath.PI/180.0f, true); completedViewPath.AddLineTo(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY())); completedViewPath.ClosePath(); UIColor.FromRGB(247, 247, 247).SetFill(); completedViewPath.Fill(); context.RestoreState(); // backgroundView Drawing var backgroundViewPath = UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 12.0f, frame.GetMinY() + 11.0f, frame.Width - 24.0f, frame.Height - 24.0f)); UIColor.FromRGB(21, 169, 254).SetFill(); backgroundViewPath.Fill(); }
private void UpdateOverlay() { if (OverlayView == null) return; foreach (var subview in this.OverlayView.Subviews) { subview.RemoveFromSuperview(); } if (_borderVisible) { UIView borderView = new UIView(ScrollView.Frame.Inset(-1.0f, -1.0f)); borderView.Layer.BorderColor = UIColor.White.ColorWithAlpha(0.5f).CGColor; borderView.Layer.BorderWidth = 1.0f; borderView.BackgroundColor = UIColor.Clear; borderView.AutoresizingMask = ScrollView.AutoresizingMask; if (_cropHoleType == CropHoleType.Circle) borderView.Layer.CornerRadius = borderView.Frame.Height / 2; OverlayView.AddSubview(borderView); } CAShapeLayer maskWithHole = new CAShapeLayer(); CGRect biggerRect = OverlayView.Bounds; CGRect smallerRect = ScrollView.Frame; UIBezierPath maskPath = new UIBezierPath(); maskPath.MoveTo(new CGPoint(biggerRect.GetMinX(), biggerRect.GetMinY())); maskPath.AddLineTo(new CGPoint(biggerRect.GetMinX(), biggerRect.GetMaxY())); maskPath.AddLineTo(new CGPoint(biggerRect.GetMaxX(), biggerRect.GetMaxY())); maskPath.AddLineTo(new CGPoint(biggerRect.GetMaxX(), biggerRect.GetMinY())); maskPath.AddLineTo(new CGPoint(biggerRect.GetMinX(), biggerRect.GetMinY())); switch (_cropHoleType) { case CropHoleType.Square: { maskPath.MoveTo(new CGPoint(smallerRect.GetMinX(), smallerRect.GetMinY())); maskPath.AddLineTo(new CGPoint(smallerRect.GetMinX(), smallerRect.GetMaxY())); maskPath.AddLineTo(new CGPoint(smallerRect.GetMaxX(), smallerRect.GetMaxY())); maskPath.AddLineTo(new CGPoint(smallerRect.GetMaxX(), smallerRect.GetMinY())); maskPath.AddLineTo(new CGPoint(smallerRect.GetMinX(), smallerRect.GetMinY())); } break; case CropHoleType.Circle: { maskPath.MoveTo(new CGPoint(smallerRect.GetMaxX(), smallerRect.GetMidY())); maskPath.AddArc( center: ScrollView.Center, radius: smallerRect.Height / 2, startAngle: DegreesToRadians(0), endAngle: DegreesToRadians(360), clockWise: true); } break; } maskWithHole.Frame = this.Bounds; maskWithHole.Path = maskPath.CGPath; maskWithHole.FillRule = CAShapeLayer.FillRuleEvenOdd; OverlayView.Layer.Mask = maskWithHole; }
UIBezierPath GetPath() { if (_markers.Count <= 0) return null; UIBezierPath path = new UIBezierPath (); CGPoint p1 = _markers [0].Frame.Location; path.MoveTo (p1); for (int i = 1; i < _markers.Count; i++) { CGPoint p = _markers [i].Frame.Location; path.AddLineTo (p); } path.ClosePath (); return path; }
public void UpdateGameState () { TTTMove[] moves = Game.Moves.ToArray (); int moveCount = moves.Length; UIImageView[] moveViews = new UIImageView[moveImageViews.Count]; moveImageViews.CopyTo (moveViews); for (int i = 0; i < moveViews.Length; i++) { UIImageView moveView = moveViews [i]; if (i < moveCount) { TTTMove move = moves [i]; setMove (move, moveView); setVisible (true, moveView); } else { setVisible (false, moveViews [i]); moveImageViewReuseQueue.Add (moveView); moveImageViews.Remove (moveView); } } for (int moveIndex = moveImageViews.Count; moveIndex < moveCount; moveIndex++) { TTTMove move = moves [moveIndex]; UIImageView moveView = moveImageView (); UIView.PerformWithoutAnimation (delegate { setMove (move, moveView); setVisible (false, moveView); }); setVisible (true, moveView); } TTTMovePlayer winningPlayer; TTTMoveXPosition startXPosition, endXPosition; TTTMoveYPosition startYPosition, endYPosition; bool hasWinner = Game.GetWinningPlayer (out winningPlayer, out startXPosition, out startYPosition, out endXPosition, out endYPosition); if (hasWinner) { UIBezierPath path = new UIBezierPath (); path.LineWidth = LineWidth; path.MoveTo (pointForPosition (startXPosition, startYPosition)); path.AddLineTo (pointForPosition (endXPosition, endYPosition)); lineView.Path = path; lineView.Color = ColorForPlayer (this, winningPlayer); AddSubview (lineView); } lineView.Alpha = hasWinner ? 1f : 0f; }
// To intermix custom drawing with the drawing performed by an associated print formatter, // this method is called for each print formatter associated with a given page. // // We do this to intermix/overlay our custom drawing onto the recipe presentation. // We draw the upper portion of the recipe presentation by hand (image, title, desc), // and the bottom portion is drawn via the UIMarkupTextPrintFormatter. public override void DrawPrintFormatterForPage (UIPrintFormatter printFormatter, nint page) { base.DrawPrintFormatterForPage (printFormatter, page); // To keep our custom drawing in sync with the printFormatter, base our drawing // on the formatters rect. CGRect rect = printFormatter.RectangleForPage (page); // Use a bezier path to draw the borders. // We may potentially choose not to draw either the top or bottom line // of the border depending on whether our recipe extended from the previous // page, or carries onto the subsequent page. UIBezierPath border = new UIBezierPath (); if (page == printFormatter.StartPage) { // For border drawing, get the rect that includes the formatter area plus the header area. // Move the formatter's rect up the size of the custom drawn recipe presentation // and essentially grow the rect's height by this amount. rect.Height += RecipeInfoHeight; rect.Y -= RecipeInfoHeight; border.MoveTo (rect.Location); border.AddLineTo (new CGPoint (rect.Right, rect.Top)); Recipe recipe = recipeFormatterMap[printFormatter]; // Run custom code to draw upper portion of the recipe presentation (image, title, desc) DrawRecipe (recipe, rect); } // Draw the left border border.MoveTo (rect.Location); border.AddLineTo (new CGPoint (rect.Left, rect.Bottom)); // Draw the right border border.MoveTo (new CGPoint (rect.Right, rect.Top)); border.AddLineTo (new CGPoint (rect.Right, rect.Bottom)); if (page == printFormatter.StartPage + printFormatter.PageCount - 1) border.AddLineTo (new CGPoint (rect.Left, rect.Bottom)); // Set the UIColor to be used by the current graphics context, and then stroke // stroke the current path that is defined by the border bezier path. UIColor.Black.SetColor (); border.Stroke (); }
public override void Draw(CGRect rect) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var fillColor = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var strokeColor3 = UIColor.FromRGBA(0.716f, 0.716f, 0.716f, 1.000f); var shadowTint2 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); var strokeColor4 = UIColor.FromRGBA(0.807f, 0.807f, 0.807f, 1.000f); var fillColor4 = UIColor.FromRGBA(0.969f, 0.969f, 0.969f, 1.000f); var fillColor6 = UIColor.FromRGBA(0.314f, 0.824f, 0.761f, 1.000f); var strokeColor5 = UIColor.FromRGBA(0.855f, 0.855f, 0.855f, 1.000f); //// Shadow Declarations var shadow3 = new NSShadow(); shadow3.ShadowColor = shadowTint2.ColorWithAlpha(shadowTint2.CGColor.Alpha * 0.13f); shadow3.ShadowOffset = new CGSize(1450.1f, 2.1f); shadow3.ShadowBlurRadius = 4.0f; //// Group 5 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 5 var clip5Path = UIBezierPath.FromRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 248.55f, 686.9f, 265.6f)); clip5Path.AddClip(); //// Rectangle 6 Drawing var rectangle6Path = UIBezierPath.FromRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 248.55f, 686.9f, 265.6f)); strokeColor4.SetStroke(); rectangle6Path.LineWidth = 2.0f; rectangle6Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(rect.GetMinX() + 687.41f, rect.GetMinY() + 349.29f)); bezierPath.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 353.29f)); bezierPath.LineCapStyle = CGLineCap.Square; strokeColor3.SetStroke(); bezierPath.LineWidth = 1.0f; bezierPath.Stroke(); //// Group { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip var clipPath = UIBezierPath.FromRect(new CGRect(rect.GetMinX() - 13.0f, rect.GetMinY() - 17.0f, 725.0f, 556.0f)); clipPath.AddClip(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 2.0f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 1444.0f, rect.GetMinY() - 2.0f), new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() - 0.21f), new CGPoint(rect.GetMinX() - 1446.2f, rect.GetMinY() - 2.0f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 765.08f, rect.GetMinY() - 2.0f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() + 2.0f), new CGPoint(rect.GetMinX() - 762.87f, rect.GetMinY() - 2.0f), new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() - 0.21f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() + 509.16f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 765.08f, rect.GetMinY() + 513.16f), new CGPoint(rect.GetMinX() - 761.09f, rect.GetMinY() + 511.37f), new CGPoint(rect.GetMinX() - 762.88f, rect.GetMinY() + 513.16f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 1444.0f, rect.GetMinY() + 513.16f)); bezier2Path.AddCurveToPoint(new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 509.16f), new CGPoint(rect.GetMinX() - 1446.21f, rect.GetMinY() + 513.16f), new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 511.37f)); bezier2Path.AddLineTo(new CGPoint(rect.GetMinX() - 1448.0f, rect.GetMinY() + 2.0f)); bezier2Path.ClosePath(); bezier2Path.UsesEvenOddFillRule = true; context.SaveState(); context.SetShadow(shadow3.ShadowOffset, shadow3.ShadowBlurRadius, shadow3.ShadowColor.CGColor); fillColor.SetFill(); bezier2Path.Fill(); context.RestoreState(); context.EndTransparencyLayer(); context.RestoreState(); } //// Group 2 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 3 UIBezierPath clip3Path = new UIBezierPath(); clip3Path.MoveTo(new CGPoint(rect.GetMinX() - 15.49f, rect.GetMinY() - 22.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 712.41f, rect.GetMinY() - 22.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 712.41f, rect.GetMinY() + 533.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() - 15.49f, rect.GetMinY() + 533.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() - 15.49f, rect.GetMinY() - 22.5f)); clip3Path.ClosePath(); clip3Path.MoveTo(new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 2.0f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() - 1.5f), new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 0.07f), new CGPoint(rect.GetMinX() + 7.07f, rect.GetMinY() - 1.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() - 1.5f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 2.0f), new CGPoint(rect.GetMinX() + 689.85f, rect.GetMinY() - 1.5f), new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 0.07f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 509.16f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() + 512.66f), new CGPoint(rect.GetMinX() + 691.41f, rect.GetMinY() + 511.09f), new CGPoint(rect.GetMinX() + 689.85f, rect.GetMinY() + 512.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() + 512.66f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 509.16f), new CGPoint(rect.GetMinX() + 7.07f, rect.GetMinY() + 512.66f), new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 511.09f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.51f, rect.GetMinY() + 2.0f)); clip3Path.ClosePath(); clip3Path.MoveTo(new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 2.0f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 509.16f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 511.65f), new CGPoint(rect.GetMinX() + 6.52f, rect.GetMinY() + 513.66f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() + 513.66f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() + 509.16f), new CGPoint(rect.GetMinX() + 690.4f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() + 511.64f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() + 2.0f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 687.92f, rect.GetMinY() - 2.5f), new CGPoint(rect.GetMinX() + 692.41f, rect.GetMinY() - 0.49f), new CGPoint(rect.GetMinX() + 690.4f, rect.GetMinY() - 2.5f)); clip3Path.AddLineTo(new CGPoint(rect.GetMinX() + 9.0f, rect.GetMinY() - 2.5f)); clip3Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() + 2.0f), new CGPoint(rect.GetMinX() + 6.52f, rect.GetMinY() - 2.5f), new CGPoint(rect.GetMinX() + 4.51f, rect.GetMinY() - 0.48f)); clip3Path.ClosePath(); clip3Path.UsesEvenOddFillRule = true; clip3Path.AddClip(); //// Group 3 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 2 var clip2Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 5.0f, rect.GetMinY() - 1.98f, 686.9f, 515.15f), 4.0f); clip2Path.AddClip(); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 5.0f, rect.GetMinY() - 1.98f, 686.9f, 515.15f), 4.0f); fillColor.SetFill(); rectangle2Path.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } context.EndTransparencyLayer(); context.RestoreState(); } //// Group 4 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 4 var clip4Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 3.02f, 686.9f, 515.15f), 4.0f); clip4Path.AddClip(); //// Rectangle 4 Drawing var rectangle4Path = UIBezierPath.FromRoundedRect(new CGRect(rect.GetMinX() + 4.0f, rect.GetMinY() + 3.02f, 686.9f, 515.15f), 4.0f); strokeColor4.SetStroke(); rectangle4Path.LineWidth = 2.0f; rectangle4Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier 4 Drawing UIBezierPath bezier4Path = new UIBezierPath(); bezier4Path.MoveTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.57f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 690.01f, rect.GetMinY() + 249.06f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.56f), new CGPoint(rect.GetMinX() + 690.01f, rect.GetMinY() + 249.06f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 249.06f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.56f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.73f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.56f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 248.57f)); bezier4Path.ClosePath(); bezier4Path.MoveTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.57f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 249.06f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.56f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.73f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 249.06f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 261.48f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 501.24f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 690.01f, rect.GetMinY() + 513.66f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 514.16f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 513.66f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 514.16f), new CGPoint(rect.GetMinX() + 689.51f, rect.GetMinY() + 513.99f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.66f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 249.06f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 501.24f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 261.48f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.01f, rect.GetMinY() + 249.06f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.56f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 248.57f)); bezier4Path.ClosePath(); bezier4Path.MoveTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.66f)); bezier4Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 514.16f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.99f), new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 514.16f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.01f, rect.GetMinY() + 513.66f)); bezier4Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.5f, rect.GetMinY() + 513.66f)); bezier4Path.ClosePath(); fillColor4.SetFill(); bezier4Path.Fill(); //// Bezier 5 Drawing UIBezierPath bezier5Path = new UIBezierPath(); bezier5Path.MoveTo(new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 513.16f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 690.91f, rect.GetMinY() + 513.16f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 690.91f, rect.GetMinY() + 589.34f)); bezier5Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 686.91f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 690.91f, rect.GetMinY() + 591.55f), new CGPoint(rect.GetMinX() + 689.13f, rect.GetMinY() + 593.34f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 350.63f, rect.GetMinY() + 593.34f)); bezier5Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 342.63f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 348.42f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 344.84f, rect.GetMinY() + 593.34f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 8.01f, rect.GetMinY() + 593.34f)); bezier5Path.AddCurveToPoint(new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 589.34f), new CGPoint(rect.GetMinX() + 5.8f, rect.GetMinY() + 593.34f), new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 591.55f)); bezier5Path.AddLineTo(new CGPoint(rect.GetMinX() + 4.01f, rect.GetMinY() + 513.16f)); bezier5Path.ClosePath(); bezier5Path.UsesEvenOddFillRule = true; fillColor6.SetFill(); bezier5Path.Fill(); //// Bezier 6 Drawing UIBezierPath bezier6Path = new UIBezierPath(); bezier6Path.MoveTo(new CGPoint(rect.GetMinX() + 345.0f, rect.GetMinY() + 110.0f)); bezier6Path.AddLineTo(new CGPoint(rect.GetMinX() + 345.46f, rect.GetMinY() + 4.0f)); bezier6Path.LineCapStyle = CGLineCap.Square; strokeColor5.SetStroke(); bezier6Path.LineWidth = 2.0f; bezier6Path.Stroke(); //// Bezier 7 Drawing UIBezierPath bezier7Path = new UIBezierPath(); bezier7Path.MoveTo(new CGPoint(rect.GetMinX() + 689.01f, rect.GetMinY() + 399.9f)); bezier7Path.AddLineTo(new CGPoint(rect.GetMinX() + 5.01f, rect.GetMinY() + 399.9f)); bezier7Path.LineCapStyle = CGLineCap.Square; strokeColor5.SetStroke(); bezier7Path.LineWidth = 2.0f; bezier7Path.Stroke(); //// Bezier 8 Drawing UIBezierPath bezier8Path = new UIBezierPath(); bezier8Path.MoveTo(new CGPoint(rect.GetMinX() + 688.91f, rect.GetMinY() + 110.25f)); bezier8Path.AddLineTo(new CGPoint(rect.GetMinX() + 6.01f, rect.GetMinY() + 110.25f)); bezier8Path.LineCapStyle = CGLineCap.Square; strokeColor5.SetStroke(); bezier8Path.LineWidth = 2.0f; bezier8Path.Stroke(); }
private static UIBezierPath CreatePathFigure(LineString linearRing, IViewport viewport) { var pathFigure = new UIBezierPath(); var start = linearRing.Vertices[0]; var startPos = viewport.WorldToScreen(start); pathFigure.MoveTo(ToUIKit(startPos)); for(int i = 1; i < linearRing.Vertices.Count; i++) { var pos = linearRing.Vertices[i]; var screenPos = viewport.WorldToScreen(pos); pathFigure.AddLineTo(ToUIKit(screenPos)); } pathFigure.ClosePath(); return pathFigure; }
UIBezierPath CreateCirclePath(CGPoint center, float radius, int sampleCount) { var smoothedPath = new UIBezierPath (); CGPoint startPoint = PointOnCircle (center, radius, -90); smoothedPath.MoveTo (startPoint); float delta = 360 / sampleCount; float angleInDegrees = -90; for (int i = 1; i < sampleCount; i++) { angleInDegrees += delta; var point = PointOnCircle (center, radius, angleInDegrees); smoothedPath.AddLineTo (point); } smoothedPath.AddLineTo (startPoint); return smoothedPath; }
private void DrawCanvas(CGRect frame, string beerName) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var fillColor = UIColor.FromRGBA(0.500f, 0.500f, 0.500f, 1.000f); var shadowTint = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); var fillColor2 = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var strokeColor = UIColor.FromRGBA(0.531f, 0.531f, 0.531f, 1.000f); var textForeground2 = UIColor.FromRGBA(0.408f, 0.408f, 0.408f, 1.000f); //// Shadow Declarations var shadow2 = new NSShadow(); shadow2.ShadowColor = shadowTint.ColorWithAlpha(shadowTint.CGColor.Alpha * 0.3f); shadow2.ShadowOffset = new CGSize(930.1f, -0.1f); shadow2.ShadowBlurRadius = 10.0f; //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect(new CGRect(-921.0f, 9.0f, 395.0f, 418.0f), 8.0f); context.SaveState(); context.SetShadow(shadow2.ShadowOffset, shadow2.ShadowBlurRadius, shadow2.ShadowColor.CGColor); fillColor.SetFill(); rectanglePath.Fill(); context.RestoreState(); //// Group { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 2 UIBezierPath clip2Path = new UIBezierPath(); clip2Path.MoveTo(new CGPoint(-11.5f, -11.5f)); clip2Path.AddLineTo(new CGPoint(424.5f, -11.5f)); clip2Path.AddLineTo(new CGPoint(424.5f, 447.5f)); clip2Path.AddLineTo(new CGPoint(-11.5f, 447.5f)); clip2Path.AddLineTo(new CGPoint(-11.5f, -11.5f)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(9.5f, 17.0f)); clip2Path.AddCurveToPoint(new CGPoint(17.0f, 9.5f), new CGPoint(9.5f, 12.86f), new CGPoint(12.86f, 9.5f)); clip2Path.AddLineTo(new CGPoint(396.0f, 9.5f)); clip2Path.AddCurveToPoint(new CGPoint(403.5f, 17.0f), new CGPoint(400.14f, 9.5f), new CGPoint(403.5f, 12.86f)); clip2Path.AddLineTo(new CGPoint(403.5f, 419.0f)); clip2Path.AddCurveToPoint(new CGPoint(396.0f, 426.5f), new CGPoint(403.5f, 423.14f), new CGPoint(400.14f, 426.5f)); clip2Path.AddLineTo(new CGPoint(17.0f, 426.5f)); clip2Path.AddCurveToPoint(new CGPoint(9.5f, 419.0f), new CGPoint(12.86f, 426.5f), new CGPoint(9.5f, 423.14f)); clip2Path.AddLineTo(new CGPoint(9.5f, 17.0f)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(8.5f, 17.0f)); clip2Path.AddLineTo(new CGPoint(8.5f, 419.0f)); clip2Path.AddCurveToPoint(new CGPoint(17.0f, 427.5f), new CGPoint(8.5f, 423.69f), new CGPoint(12.31f, 427.5f)); clip2Path.AddLineTo(new CGPoint(396.0f, 427.5f)); clip2Path.AddCurveToPoint(new CGPoint(404.5f, 419.0f), new CGPoint(400.69f, 427.5f), new CGPoint(404.5f, 423.69f)); clip2Path.AddLineTo(new CGPoint(404.5f, 17.0f)); clip2Path.AddCurveToPoint(new CGPoint(396.0f, 8.5f), new CGPoint(404.5f, 12.31f), new CGPoint(400.69f, 8.5f)); clip2Path.AddLineTo(new CGPoint(17.0f, 8.5f)); clip2Path.AddCurveToPoint(new CGPoint(8.5f, 17.0f), new CGPoint(12.31f, 8.5f), new CGPoint(8.5f, 12.31f)); clip2Path.ClosePath(); clip2Path.UsesEvenOddFillRule = true; clip2Path.AddClip(); //// Group 2 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip var clipPath = UIBezierPath.FromRoundedRect(new CGRect(9.0f, 9.0f, 395.0f, 418.0f), 8.0f); clipPath.AddClip(); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRoundedRect(new CGRect(9.0f, 9.0f, 395.0f, 418.0f), 8.0f); fillColor2.SetFill(); rectangle2Path.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } context.EndTransparencyLayer(); context.RestoreState(); } //// background { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 3 var clip3Path = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX(), frame.GetMinY() + 9.0f, 395.0f, 418.0f), 8.0f); clip3Path.AddClip(); //// Rectangle 4 Drawing var rectangle4Path = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX(), frame.GetMinY() + 9.0f, 395.0f, 418.0f), 8.0f); strokeColor.SetStroke(); rectangle4Path.LineWidth = 2.0f; rectangle4Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// title Drawing CGRect titleRect = new CGRect(frame.GetMinX() + 0.38f, frame.GetMinY() + 19.0f, 394.62f, 41.0f); textForeground2.SetFill(); var titleStyle = new NSMutableParagraphStyle (); titleStyle.Alignment = UITextAlignment.Center; var titleFontAttributes = new UIStringAttributes () {Font = UIFont.FromName("Avenir-Medium", 24.0f), ForegroundColor = textForeground2, ParagraphStyle = titleStyle}; var titleTextHeight = new NSString(beerName).GetBoundingRect(new CGSize(titleRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, titleFontAttributes, null).Height; context.SaveState(); context.ClipToRect(titleRect); new NSString(beerName).DrawString(new CGRect(titleRect.GetMinX(), titleRect.GetMinY() + (titleRect.Height - titleTextHeight) / 2.0f, titleRect.Width, titleTextHeight), UIFont.FromName("Avenir-Medium", 24.0f), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); }
void DrawCanvas(CGRect frame2) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var fillColor = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var strokeColor = UIColor.FromRGBA(0.807f, 0.807f, 0.807f, 1.000f); var strokeColor2 = UIColor.FromRGBA(0.851f, 0.851f, 0.851f, 1.000f); //// Frames CGRect frame = new CGRect(1.0f, 0.0f, 771.0f, 356.0f); //// Subframes CGRect group3 = new CGRect(frame.GetMinX(), frame.GetMinY(), frame.Width, frame.Height); CGRect group5 = new CGRect(frame.GetMinX() + 3.0f, frame.GetMinY() + 3.0f, frame.Width - 7.0f, frame.Height - 7.0f); //// Group 2 { //// Group 3 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 2 UIBezierPath clip2Path = new UIBezierPath(); clip2Path.MoveTo(new CGPoint(group3.GetMinX() + 0.00130f * group3.Width, group3.GetMinY() + 0.00000f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 1.00130f * group3.Width, group3.GetMinY() + 0.00000f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 1.00130f * group3.Width, group3.GetMinY() + 1.00000f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.00130f * group3.Width, group3.GetMinY() + 1.00000f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.00130f * group3.Width, group3.GetMinY() + 0.00000f * group3.Height)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(group3.GetMinX() + 0.02853f * group3.Width, group3.GetMinY() + 0.06901f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.03307f * group3.Width, group3.GetMinY() + 0.05915f * group3.Height), new CGPoint(group3.GetMinX() + 0.02853f * group3.Width, group3.GetMinY() + 0.06356f * group3.Height), new CGPoint(group3.GetMinX() + 0.03056f * group3.Width, group3.GetMinY() + 0.05915f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.96953f * group3.Width, group3.GetMinY() + 0.05915f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.97406f * group3.Width, group3.GetMinY() + 0.06901f * group3.Height), new CGPoint(group3.GetMinX() + 0.97203f * group3.Width, group3.GetMinY() + 0.05915f * group3.Height), new CGPoint(group3.GetMinX() + 0.97406f * group3.Width, group3.GetMinY() + 0.06356f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.97406f * group3.Width, group3.GetMinY() + 0.93099f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.96953f * group3.Width, group3.GetMinY() + 0.94085f * group3.Height), new CGPoint(group3.GetMinX() + 0.97406f * group3.Width, group3.GetMinY() + 0.93644f * group3.Height), new CGPoint(group3.GetMinX() + 0.97204f * group3.Width, group3.GetMinY() + 0.94085f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.03307f * group3.Width, group3.GetMinY() + 0.94085f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.02853f * group3.Width, group3.GetMinY() + 0.93099f * group3.Height), new CGPoint(group3.GetMinX() + 0.03056f * group3.Width, group3.GetMinY() + 0.94085f * group3.Height), new CGPoint(group3.GetMinX() + 0.02853f * group3.Width, group3.GetMinY() + 0.93644f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.02853f * group3.Width, group3.GetMinY() + 0.06901f * group3.Height)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(group3.GetMinX() + 0.02724f * group3.Width, group3.GetMinY() + 0.06901f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.02724f * group3.Width, group3.GetMinY() + 0.93099f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.03307f * group3.Width, group3.GetMinY() + 0.94366f * group3.Height), new CGPoint(group3.GetMinX() + 0.02724f * group3.Width, group3.GetMinY() + 0.93800f * group3.Height), new CGPoint(group3.GetMinX() + 0.02984f * group3.Width, group3.GetMinY() + 0.94366f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.96953f * group3.Width, group3.GetMinY() + 0.94366f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.97536f * group3.Width, group3.GetMinY() + 0.93099f * group3.Height), new CGPoint(group3.GetMinX() + 0.97275f * group3.Width, group3.GetMinY() + 0.94366f * group3.Height), new CGPoint(group3.GetMinX() + 0.97536f * group3.Width, group3.GetMinY() + 0.93799f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.97536f * group3.Width, group3.GetMinY() + 0.06901f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.96953f * group3.Width, group3.GetMinY() + 0.05634f * group3.Height), new CGPoint(group3.GetMinX() + 0.97536f * group3.Width, group3.GetMinY() + 0.06200f * group3.Height), new CGPoint(group3.GetMinX() + 0.97275f * group3.Width, group3.GetMinY() + 0.05634f * group3.Height)); clip2Path.AddLineTo(new CGPoint(group3.GetMinX() + 0.03307f * group3.Width, group3.GetMinY() + 0.05634f * group3.Height)); clip2Path.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.02724f * group3.Width, group3.GetMinY() + 0.06901f * group3.Height), new CGPoint(group3.GetMinX() + 0.02984f * group3.Width, group3.GetMinY() + 0.05634f * group3.Height), new CGPoint(group3.GetMinX() + 0.02724f * group3.Width, group3.GetMinY() + 0.06201f * group3.Height)); clip2Path.ClosePath(); clip2Path.UsesEvenOddFillRule = true; clip2Path.AddClip(); //// Group 4 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip UIBezierPath clipPath = new UIBezierPath(); clipPath.MoveTo(new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.00425f * group3.Height)); clipPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.00583f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height), new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + -0.00198f * group3.Height), new CGPoint(group3.GetMinX() + 0.00296f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height)); clipPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.94229f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height)); clipPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + 0.00425f * group3.Height), new CGPoint(group3.GetMinX() + 0.94515f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height), new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + -0.00199f * group3.Height)); clipPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + 0.86654f * group3.Height)); clipPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.94229f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height), new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + 0.87276f * group3.Height), new CGPoint(group3.GetMinX() + 0.94516f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height)); clipPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.00583f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height)); clipPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.86654f * group3.Height), new CGPoint(group3.GetMinX() + 0.00297f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height), new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.87278f * group3.Height)); clipPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.00425f * group3.Height)); clipPath.ClosePath(); clipPath.UsesEvenOddFillRule = true; clipPath.AddClip(); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.00425f * group3.Height)); bezierPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.00583f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height), new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + -0.00198f * group3.Height), new CGPoint(group3.GetMinX() + 0.00296f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height)); bezierPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.94229f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height)); bezierPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + 0.00425f * group3.Height), new CGPoint(group3.GetMinX() + 0.94515f * group3.Width, group3.GetMinY() + -0.00702f * group3.Height), new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + -0.00199f * group3.Height)); bezierPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + 0.86654f * group3.Height)); bezierPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.94229f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height), new CGPoint(group3.GetMinX() + 0.94747f * group3.Width, group3.GetMinY() + 0.87276f * group3.Height), new CGPoint(group3.GetMinX() + 0.94516f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height)); bezierPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.00583f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height)); bezierPath.AddCurveToPoint(new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.86654f * group3.Height), new CGPoint(group3.GetMinX() + 0.00297f * group3.Width, group3.GetMinY() + 0.87781f * group3.Height), new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.87278f * group3.Height)); bezierPath.AddLineTo(new CGPoint(group3.GetMinX() + 0.00065f * group3.Width, group3.GetMinY() + 0.00425f * group3.Height)); bezierPath.ClosePath(); fillColor.SetFill(); bezierPath.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } context.EndTransparencyLayer(); context.RestoreState(); } //// Group 5 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 3 UIBezierPath clip3Path = new UIBezierPath(); clip3Path.MoveTo(new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.01273f * group5.Height)); clip3Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 0.00678f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height), new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.00570f * group5.Height), new CGPoint(group5.GetMinX() + 0.00375f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height)); clip3Path.AddLineTo(new CGPoint(group5.GetMinX() + 0.99584f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height)); clip3Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.01273f * group5.Height), new CGPoint(group5.GetMinX() + 0.99886f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height), new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.00569f * group5.Height)); clip3Path.AddLineTo(new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.98727f * group5.Height)); clip3Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 0.99584f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height), new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.99430f * group5.Height), new CGPoint(group5.GetMinX() + 0.99887f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height)); clip3Path.AddLineTo(new CGPoint(group5.GetMinX() + 0.00678f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height)); clip3Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.98727f * group5.Height), new CGPoint(group5.GetMinX() + 0.00376f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height), new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.99431f * group5.Height)); clip3Path.AddLineTo(new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.01273f * group5.Height)); clip3Path.ClosePath(); clip3Path.UsesEvenOddFillRule = true; clip3Path.AddClip(); //// Bezier 4 Drawing UIBezierPath bezier4Path = new UIBezierPath(); bezier4Path.MoveTo(new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.01273f * group5.Height)); bezier4Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 0.00678f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height), new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.00570f * group5.Height), new CGPoint(group5.GetMinX() + 0.00375f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height)); bezier4Path.AddLineTo(new CGPoint(group5.GetMinX() + 0.99584f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height)); bezier4Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.01273f * group5.Height), new CGPoint(group5.GetMinX() + 0.99886f * group5.Width, group5.GetMinY() + 0.00000f * group5.Height), new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.00569f * group5.Height)); bezier4Path.AddLineTo(new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.98727f * group5.Height)); bezier4Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 0.99584f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height), new CGPoint(group5.GetMinX() + 1.00131f * group5.Width, group5.GetMinY() + 0.99430f * group5.Height), new CGPoint(group5.GetMinX() + 0.99887f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height)); bezier4Path.AddLineTo(new CGPoint(group5.GetMinX() + 0.00678f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height)); bezier4Path.AddCurveToPoint(new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.98727f * group5.Height), new CGPoint(group5.GetMinX() + 0.00376f * group5.Width, group5.GetMinY() + 1.00000f * group5.Height), new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.99431f * group5.Height)); bezier4Path.AddLineTo(new CGPoint(group5.GetMinX() + 0.00131f * group5.Width, group5.GetMinY() + 0.01273f * group5.Height)); bezier4Path.ClosePath(); strokeColor2.SetStroke(); bezier4Path.LineWidth = 2.0f; bezier4Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier 6 Drawing UIBezierPath bezier6Path = new UIBezierPath(); bezier6Path.MoveTo(new CGPoint(frame.GetMinX() + 0.04789f * frame.Width, frame.GetMinY() + 0.43141f * frame.Height)); bezier6Path.AddLineTo(new CGPoint(frame.GetMinX() + 0.90281f * frame.Width, frame.GetMinY() + 0.43141f * frame.Height)); bezier6Path.LineCapStyle = CGLineCap.Square; strokeColor.SetStroke(); bezier6Path.LineWidth = 1.0f; bezier6Path.Stroke(); } }
public override void Draw (CGRect rect) { base.Draw (rect); // ------------- START PAINTCODE ---------------- //// General Declarations using (var colorSpace = CGColorSpace.CreateDeviceRGB ()) { using (var context = UIGraphics.GetCurrentContext ()) { //// Color Declarations UIColor gold = UIColor.FromRGBA (1.00f, 0.95f, 0.57f, 1.00f); UIColor brown = UIColor.FromRGBA (0.79f, 0.75f, 0.18f, 1.00f); UIColor lightBrown = UIColor.FromRGBA (0.69f, 0.57f, 0.23f, 1.00f); UIColor darkishBlue = UIColor.FromRGBA (0.20f, 0.39f, 0.98f, 1.00f); UIColor bottomColorDown = UIColor.FromRGBA (0.21f, 0.21f, 0.21f, 1.00f); //// Gradient Declarations var newGradientColors = new CGColor [] { UIColor.Black.CGColor, UIColor.White.CGColor }; var newGradientLocations = new nfloat [] { 0, 1 }; var newGradient = new CGGradient (colorSpace, newGradientColors, newGradientLocations); var calendarGradientColors = new CGColor [] { UIColor.DarkGray.CGColor, UIColor.FromRGBA (0.72f, 0.72f, 0.72f, 1.00f).CGColor, UIColor.White.CGColor }; var calendarGradientLocations = new nfloat [] { 0, 0.26f, 0.26f }; var calendarGradient = new CGGradient (colorSpace, calendarGradientColors, calendarGradientLocations); //// Shadow Declarations var shadow = UIColor.DarkGray.CGColor; var shadowOffset = new CGSize (2, 2); var shadowBlurRadius = 2; //// Abstracted Graphic Attributes var monthContent = "MAR"; var dayContent = "24"; var dayFont = UIFont.FromName ("Helvetica-Bold", 24); var textContent = "News Headline"; //// Oval 11 Drawing var oval11Path = UIBezierPath.FromOval (new CGRect (256.5f, 46.5f, 13, 14)); lightBrown.SetFill (); oval11Path.Fill (); UIColor.Black.SetStroke (); oval11Path.LineWidth = 1; oval11Path.Stroke (); //// Oval 12 Drawing var oval12Path = UIBezierPath.FromOval (new CGRect (280.5f, 46.5f, 13, 14)); lightBrown.SetFill (); oval12Path.Fill (); UIColor.Black.SetStroke (); oval12Path.LineWidth = 1; oval12Path.Stroke (); //// Rounded Rectangle Drawing var roundedRectanglePath = UIBezierPath.FromRoundedRect (new CGRect (8.5f, 60.5f, 37, 36), 4); context.SaveState (); context.SetShadow (shadowOffset, shadowBlurRadius, shadow); context.BeginTransparencyLayer (null); roundedRectanglePath.AddClip (); context.DrawLinearGradient (calendarGradient, new CGPoint (27, 96.5f), new CGPoint (27, 60.5f), 0); context.EndTransparencyLayer (); context.RestoreState (); UIColor.DarkGray.SetStroke (); roundedRectanglePath.LineWidth = 1; roundedRectanglePath.Stroke (); //// Rounded Rectangle 3 Drawing UIBezierPath roundedRectangle3Path = new UIBezierPath (); roundedRectangle3Path.MoveTo (new CGPoint (9, 91.2f)); roundedRectangle3Path.AddCurveToPoint (new CGPoint (12.56f, 95), new CGPoint (9, 93.3f), new CGPoint (10.32f, 95)); roundedRectangle3Path.AddLineTo (new CGPoint (40.94f, 95)); roundedRectangle3Path.AddCurveToPoint (new CGPoint (45, 91.2f), new CGPoint (43.18f, 95), new CGPoint (45, 93.3f)); roundedRectangle3Path.AddLineTo (new CGPoint (45, 87)); roundedRectangle3Path.AddCurveToPoint (new CGPoint (43.42f, 85.5f), new CGPoint (45, 84.9f), new CGPoint (45.66f, 85.5f)); roundedRectangle3Path.AddLineTo (new CGPoint (10.94f, 85.5f)); roundedRectangle3Path.AddCurveToPoint (new CGPoint (9, 87), new CGPoint (8.7f, 85.5f), new CGPoint (9, 84.9f)); roundedRectangle3Path.AddLineTo (new CGPoint (9, 91.2f)); roundedRectangle3Path.ClosePath (); UIColor.Red.SetFill (); roundedRectangle3Path.Fill (); //// Month Drawing var monthRect = new CGRect (10, 84, 34, 15); UIColor.White.SetFill (); new NSString (monthContent).DrawString ( monthRect, UIFont.FromName ("Helvetica-Bold", 9), UILineBreakMode.WordWrap, UITextAlignment.Center ); //// Day Drawing var dayRect = new CGRect (0, 58, 54, 31); UIColor.Black.SetFill (); new NSString (dayContent).DrawString (dayRect, dayFont, UILineBreakMode.WordWrap, UITextAlignment.Center); //// Text Drawing var textRect = new CGRect (54, 60, 75, 38); UIColor.Black.SetFill (); new NSString (textContent).DrawString ( textRect, UIFont.FromName ("Helvetica", 16), UILineBreakMode.WordWrap, UITextAlignment.Left ); //// Star Drawing UIBezierPath starPath = new UIBezierPath (); starPath.MoveTo (new CGPoint (31, 14.5f)); starPath.AddLineTo (new CGPoint (26.24f, 21.45f)); starPath.AddLineTo (new CGPoint (18.16f, 23.83f)); starPath.AddLineTo (new CGPoint (23.3f, 30.5f)); starPath.AddLineTo (new CGPoint (23.06f, 38.92f)); starPath.AddLineTo (new CGPoint (31, 36.1f)); starPath.AddLineTo (new CGPoint (38.94f, 38.92f)); starPath.AddLineTo (new CGPoint (38.7f, 30.5f)); starPath.AddLineTo (new CGPoint (43.84f, 23.83f)); starPath.AddLineTo (new CGPoint (35.76f, 21.45f)); starPath.ClosePath (); gold.SetFill (); starPath.Fill (); brown.SetStroke (); starPath.LineWidth = 1; starPath.Stroke (); //// Blue blob Drawing UIBezierPath blueBlobPath = new UIBezierPath (); blueBlobPath.MoveTo (new CGPoint (256.5f, 16.5f)); blueBlobPath.AddCurveToPoint (new CGPoint (240.5f, 41.5f), new CGPoint (235.5f, 37.5f), new CGPoint (217.53f, 41.55f)); blueBlobPath.AddCurveToPoint (new CGPoint (265.5f, 30.5f), new CGPoint (263.47f, 41.45f), new CGPoint (265.5f, 30.5f)); blueBlobPath.AddCurveToPoint (new CGPoint (256.5f, 16.5f), new CGPoint (265.5f, 30.5f), new CGPoint (277.5f, -4.5f)); blueBlobPath.ClosePath (); blueBlobPath.MiterLimit = 2; blueBlobPath.LineJoinStyle = CGLineJoin.Round; darkishBlue.SetFill (); blueBlobPath.Fill (); bottomColorDown.SetStroke (); blueBlobPath.LineWidth = 1; blueBlobPath.Stroke (); //// Button Drawing var buttonPath = UIBezierPath.FromRoundedRect (new CGRect (54.5f, 10.5f, 163, 31), 4); context.SaveState (); buttonPath.AddClip (); context.DrawRadialGradient (newGradient, new CGPoint (100.39f, 55.13f), 7.84f, new CGPoint (136, 26), 86.67f, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation); context.RestoreState (); UIColor.Black.SetStroke (); buttonPath.LineWidth = 1; buttonPath.Stroke (); //// Smiley face Drawing var smileyFacePath = UIBezierPath.FromOval (new CGRect (159.5f, 49.5f, 47, 47)); gold.SetFill (); smileyFacePath.Fill (); UIColor.Black.SetStroke (); smileyFacePath.LineWidth = 1; smileyFacePath.Stroke (); //// Oval 2 Drawing var oval2Path = UIBezierPath.FromOval (new CGRect (169.5f, 64.5f, 8, 8)); UIColor.Black.SetFill (); oval2Path.Fill (); UIColor.Black.SetStroke (); oval2Path.LineWidth = 1; oval2Path.Stroke (); //// Oval 3 Drawing var oval3Path = UIBezierPath.FromOval (new CGRect (188.5f, 64.5f, 8, 8)); UIColor.Black.SetFill (); oval3Path.Fill (); UIColor.Black.SetStroke (); oval3Path.LineWidth = 1; oval3Path.Stroke (); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath (); bezier2Path.MoveTo (new CGPoint (172.5f, 80.5f)); bezier2Path.AddCurveToPoint (new CGPoint (185.5f, 85.5f), new CGPoint (177.75f, 85), new CGPoint (182.04f, 86.03f)); bezier2Path.AddCurveToPoint (new CGPoint (194.5f, 79.5f), new CGPoint (191.27f, 84.62f), new CGPoint (194.5f, 79.5f)); UIColor.Black.SetStroke (); bezier2Path.LineWidth = 2; bezier2Path.Stroke (); //// Oval 5 Drawing var oval5Path = UIBezierPath.FromOval (new CGRect (256.5f, 52.5f, 36, 33)); lightBrown.SetFill (); oval5Path.Fill (); UIColor.Black.SetStroke (); oval5Path.LineWidth = 1; oval5Path.Stroke (); //// Oval 6 Drawing var oval6Path = UIBezierPath.FromOval (new CGRect (262.5f, 59.5f, 10, 19)); UIColor.White.SetFill (); oval6Path.Fill (); UIColor.Black.SetStroke (); oval6Path.LineWidth = 1; oval6Path.Stroke (); //// Oval 7 Drawing var oval7Path = UIBezierPath.FromOval (new CGRect (275.5f, 59.5f, 10, 19)); UIColor.White.SetFill (); oval7Path.Fill (); UIColor.Black.SetStroke (); oval7Path.LineWidth = 1; oval7Path.Stroke (); //// Oval 9 Drawing var oval9Path = UIBezierPath.FromOval (new CGRect (264.5f, 68.5f, 6, 5)); UIColor.Black.SetFill (); oval9Path.Fill (); UIColor.Black.SetStroke (); oval9Path.LineWidth = 1; oval9Path.Stroke (); //// Oval 10 Drawing var oval10Path = UIBezierPath.FromOval (new CGRect (277.5f, 68.5f, 6, 5)); UIColor.Black.SetFill (); oval10Path.Fill (); UIColor.Black.SetStroke (); oval10Path.LineWidth = 1; oval10Path.Stroke (); //// Oval 4 Drawing var oval4Path = UIBezierPath.FromOval (new CGRect (250.5f, 70.5f, 47, 24)); lightBrown.SetFill (); oval4Path.Fill (); UIColor.Black.SetStroke (); oval4Path.LineWidth = 1; oval4Path.Stroke (); //// Oval 8 Drawing var oval8Path = UIBezierPath.FromOval (new CGRect (267.5f, 77.5f, 9, 4)); UIColor.Black.SetFill (); oval8Path.Fill (); UIColor.Black.SetStroke (); oval8Path.LineWidth = 1; oval8Path.Stroke (); //// Bezier 5 Drawing UIBezierPath bezier5Path = new UIBezierPath (); bezier5Path.MoveTo (new CGPoint (270.5f, 81.5f)); bezier5Path.AddCurveToPoint (new CGPoint (267.5f, 88.5f), new CGPoint (269.5f, 85.5f), new CGPoint (267.5f, 88.5f)); UIColor.Black.SetStroke (); bezier5Path.LineWidth = 1; bezier5Path.Stroke (); //// Bezier 6 Drawing UIBezierPath bezier6Path = new UIBezierPath (); bezier6Path.MoveTo (new CGPoint (272.5f, 81.5f)); bezier6Path.AddLineTo (new CGPoint (274.5f, 87.5f)); UIColor.Black.SetStroke (); bezier6Path.LineWidth = 1; bezier6Path.Stroke (); } } // ------------- END PAINTCODE ---------------- }
public override void Draw(CGRect rect) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var fillColor = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f); var strokeColor = UIColor.FromRGBA(0.807f, 0.807f, 0.807f, 1.000f); var strokeColor2 = UIColor.FromRGBA(0.851f, 0.851f, 0.851f, 1.000f); //// Frames CGRect frame = new CGRect(0.0f, 0.0f, 772.0f, 356.0f); //// Group 2 { //// Group 3 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 2 UIBezierPath clip2Path = new UIBezierPath(); clip2Path.MoveTo(new CGPoint(frame.GetMinX() - 41.0f, frame.GetMinY() - 45.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() + 730.0f, frame.GetMinY() - 45.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() + 730.0f, frame.GetMinY() + 310.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() - 41.0f, frame.GetMinY() + 310.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() - 41.0f, frame.GetMinY() - 45.0f)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(frame.GetMinX() - 20.0f, frame.GetMinY() - 20.5f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() - 24.0f), new CGPoint(frame.GetMinX() - 20.0f, frame.GetMinY() - 22.44f), new CGPoint(frame.GetMinX() - 18.44f, frame.GetMinY() - 24.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() - 24.0f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 709.0f, frame.GetMinY() - 20.5f), new CGPoint(frame.GetMinX() + 707.44f, frame.GetMinY() - 24.0f), new CGPoint(frame.GetMinX() + 709.0f, frame.GetMinY() - 22.44f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() + 709.0f, frame.GetMinY() + 285.5f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() + 289.0f), new CGPoint(frame.GetMinX() + 709.0f, frame.GetMinY() + 287.44f), new CGPoint(frame.GetMinX() + 707.44f, frame.GetMinY() + 289.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() + 289.0f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 20.0f, frame.GetMinY() + 285.5f), new CGPoint(frame.GetMinX() - 18.44f, frame.GetMinY() + 289.0f), new CGPoint(frame.GetMinX() - 20.0f, frame.GetMinY() + 287.44f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() - 20.0f, frame.GetMinY() - 20.5f)); clip2Path.ClosePath(); clip2Path.MoveTo(new CGPoint(frame.GetMinX() - 21.0f, frame.GetMinY() - 20.5f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() - 21.0f, frame.GetMinY() + 285.5f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() + 290.0f), new CGPoint(frame.GetMinX() - 21.0f, frame.GetMinY() + 287.99f), new CGPoint(frame.GetMinX() - 18.99f, frame.GetMinY() + 290.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() + 290.0f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 710.0f, frame.GetMinY() + 285.5f), new CGPoint(frame.GetMinX() + 707.99f, frame.GetMinY() + 290.0f), new CGPoint(frame.GetMinX() + 710.0f, frame.GetMinY() + 287.99f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() + 710.0f, frame.GetMinY() - 20.5f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() - 25.0f), new CGPoint(frame.GetMinX() + 710.0f, frame.GetMinY() - 22.99f), new CGPoint(frame.GetMinX() + 707.99f, frame.GetMinY() - 25.0f)); clip2Path.AddLineTo(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() - 25.0f)); clip2Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 21.0f, frame.GetMinY() - 20.5f), new CGPoint(frame.GetMinX() - 18.99f, frame.GetMinY() - 25.0f), new CGPoint(frame.GetMinX() - 21.0f, frame.GetMinY() - 22.99f)); clip2Path.ClosePath(); clip2Path.UsesEvenOddFillRule = true; clip2Path.AddClip(); //// Group 4 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip UIBezierPath clipPath = new UIBezierPath(); clipPath.MoveTo(new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() - 20.5f)); clipPath.AddCurveToPoint(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() - 24.5f), new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() - 22.71f), new CGPoint(frame.GetMinX() - 18.72f, frame.GetMinY() - 24.5f)); clipPath.AddLineTo(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() - 24.5f)); clipPath.AddCurveToPoint(new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() - 20.5f), new CGPoint(frame.GetMinX() + 707.71f, frame.GetMinY() - 24.5f), new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() - 22.71f)); clipPath.AddLineTo(new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() + 285.5f)); clipPath.AddCurveToPoint(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() + 289.5f), new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() + 287.71f), new CGPoint(frame.GetMinX() + 707.72f, frame.GetMinY() + 289.5f)); clipPath.AddLineTo(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() + 289.5f)); clipPath.AddCurveToPoint(new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() + 285.5f), new CGPoint(frame.GetMinX() - 18.71f, frame.GetMinY() + 289.5f), new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() + 287.71f)); clipPath.AddLineTo(new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() - 20.5f)); clipPath.ClosePath(); clipPath.UsesEvenOddFillRule = true; clipPath.AddClip(); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() - 20.5f)); bezierPath.AddCurveToPoint(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() - 24.5f), new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() - 22.71f), new CGPoint(frame.GetMinX() - 18.72f, frame.GetMinY() - 24.5f)); bezierPath.AddLineTo(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() - 24.5f)); bezierPath.AddCurveToPoint(new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() - 20.5f), new CGPoint(frame.GetMinX() + 707.71f, frame.GetMinY() - 24.5f), new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() - 22.71f)); bezierPath.AddLineTo(new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() + 285.5f)); bezierPath.AddCurveToPoint(new CGPoint(frame.GetMinX() + 705.51f, frame.GetMinY() + 289.5f), new CGPoint(frame.GetMinX() + 709.5f, frame.GetMinY() + 287.71f), new CGPoint(frame.GetMinX() + 707.72f, frame.GetMinY() + 289.5f)); bezierPath.AddLineTo(new CGPoint(frame.GetMinX() - 16.51f, frame.GetMinY() + 289.5f)); bezierPath.AddCurveToPoint(new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() + 285.5f), new CGPoint(frame.GetMinX() - 18.71f, frame.GetMinY() + 289.5f), new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() + 287.71f)); bezierPath.AddLineTo(new CGPoint(frame.GetMinX() - 20.5f, frame.GetMinY() - 20.5f)); bezierPath.ClosePath(); fillColor.SetFill(); bezierPath.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } context.EndTransparencyLayer(); context.RestoreState(); } //// Group 5 { context.SaveState(); context.BeginTransparencyLayer(); //// Clip Clip 3 UIBezierPath clip3Path = new UIBezierPath(); clip3Path.MoveTo(new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() - 11.14f)); clip3Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 9.35f, frame.GetMinY() - 15.5f), new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() - 13.55f), new CGPoint(frame.GetMinX() - 11.65f, frame.GetMinY() - 15.5f)); clip3Path.AddLineTo(new CGPoint(frame.GetMinX() + 740.35f, frame.GetMinY() - 15.5f)); clip3Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() - 11.14f), new CGPoint(frame.GetMinX() + 742.64f, frame.GetMinY() - 15.5f), new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() - 13.56f)); clip3Path.AddLineTo(new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() + 322.14f)); clip3Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 740.35f, frame.GetMinY() + 326.5f), new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() + 324.55f), new CGPoint(frame.GetMinX() + 742.65f, frame.GetMinY() + 326.5f)); clip3Path.AddLineTo(new CGPoint(frame.GetMinX() - 9.35f, frame.GetMinY() + 326.5f)); clip3Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() + 322.14f), new CGPoint(frame.GetMinX() - 11.64f, frame.GetMinY() + 326.5f), new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() + 324.56f)); clip3Path.AddLineTo(new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() - 11.14f)); clip3Path.ClosePath(); clip3Path.UsesEvenOddFillRule = true; clip3Path.AddClip(); //// Bezier 4 Drawing UIBezierPath bezier4Path = new UIBezierPath(); bezier4Path.MoveTo(new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() - 11.14f)); bezier4Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 9.35f, frame.GetMinY() - 15.5f), new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() - 13.55f), new CGPoint(frame.GetMinX() - 11.65f, frame.GetMinY() - 15.5f)); bezier4Path.AddLineTo(new CGPoint(frame.GetMinX() + 740.35f, frame.GetMinY() - 15.5f)); bezier4Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() - 11.14f), new CGPoint(frame.GetMinX() + 742.64f, frame.GetMinY() - 15.5f), new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() - 13.56f)); bezier4Path.AddLineTo(new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() + 322.14f)); bezier4Path.AddCurveToPoint(new CGPoint(frame.GetMinX() + 740.35f, frame.GetMinY() + 326.5f), new CGPoint(frame.GetMinX() + 744.5f, frame.GetMinY() + 324.55f), new CGPoint(frame.GetMinX() + 742.65f, frame.GetMinY() + 326.5f)); bezier4Path.AddLineTo(new CGPoint(frame.GetMinX() - 9.35f, frame.GetMinY() + 326.5f)); bezier4Path.AddCurveToPoint(new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() + 322.14f), new CGPoint(frame.GetMinX() - 11.64f, frame.GetMinY() + 326.5f), new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() + 324.56f)); bezier4Path.AddLineTo(new CGPoint(frame.GetMinX() - 13.5f, frame.GetMinY() - 11.14f)); bezier4Path.ClosePath(); strokeColor2.SetStroke(); bezier4Path.LineWidth = 2.0f; bezier4Path.Stroke(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier 6 Drawing UIBezierPath bezier6Path = new UIBezierPath(); bezier6Path.MoveTo(new CGPoint(frame.GetMinX() + 36.0f, frame.GetMinY() + 155.6f)); bezier6Path.AddLineTo(new CGPoint(frame.GetMinX() + 696.0f, frame.GetMinY() + 155.6f)); bezier6Path.LineCapStyle = CGLineCap.Square; strokeColor.SetStroke(); bezier6Path.LineWidth = 1.0f; bezier6Path.Stroke(); } }
public static UIImage ToTransformedCorners(UIImage source, double topLeftCornerSize, double topRightCornerSize, double bottomLeftCornerSize, double bottomRightCornerSize, CornerTransformType cornersTransformType, double cropWidthRatio, double cropHeightRatio) { double sourceWidth = source.Size.Width; double sourceHeight = source.Size.Height; double desiredWidth = sourceWidth; double desiredHeight = sourceHeight; double desiredRatio = cropWidthRatio / cropHeightRatio; double currentRatio = sourceWidth / sourceHeight; if (currentRatio > desiredRatio) desiredWidth = (cropWidthRatio * sourceHeight / cropHeightRatio); else if (currentRatio < desiredRatio) desiredHeight = (cropHeightRatio * sourceWidth / cropWidthRatio); topLeftCornerSize = topLeftCornerSize * (desiredWidth + desiredHeight) / 2 / 100; topRightCornerSize = topRightCornerSize * (desiredWidth + desiredHeight) / 2 / 100; bottomLeftCornerSize = bottomLeftCornerSize * (desiredWidth + desiredHeight) / 2 / 100; bottomRightCornerSize = bottomRightCornerSize * (desiredWidth + desiredHeight) / 2 / 100; float cropX = (float)((sourceWidth - desiredWidth) / 2); float cropY = (float)((sourceHeight - desiredHeight) / 2); UIGraphics.BeginImageContextWithOptions(new CGSize(desiredWidth, desiredHeight), false, (nfloat)0.0); try { using (var context = UIGraphics.GetCurrentContext()) { context.BeginPath(); using (var path = new UIBezierPath()) { // TopLeft if (cornersTransformType.HasFlag(CornerTransformType.TopLeftCut)) { path.MoveTo(new CGPoint(0, topLeftCornerSize)); path.AddLineTo(new CGPoint(topLeftCornerSize, 0)); } else if (cornersTransformType.HasFlag(CornerTransformType.TopLeftRounded)) { path.MoveTo(new CGPoint(0, topLeftCornerSize)); path.AddQuadCurveToPoint(new CGPoint(topLeftCornerSize, 0), new CGPoint(0, 0)); } else { path.MoveTo(new CGPoint(0, 0)); } // TopRight if (cornersTransformType.HasFlag(CornerTransformType.TopRightCut)) { path.AddLineTo(new CGPoint(desiredWidth - topRightCornerSize, 0)); path.AddLineTo(new CGPoint(desiredWidth, topRightCornerSize)); } else if (cornersTransformType.HasFlag(CornerTransformType.TopRightRounded)) { path.AddLineTo(new CGPoint(desiredWidth - topRightCornerSize, 0)); path.AddQuadCurveToPoint(new CGPoint(desiredWidth, topRightCornerSize), new CGPoint(desiredWidth, 0)); } else { path.AddLineTo(new CGPoint(desiredWidth ,0)); } // BottomRight if (cornersTransformType.HasFlag(CornerTransformType.BottomRightCut)) { path.AddLineTo(new CGPoint(desiredWidth, desiredHeight - bottomRightCornerSize)); path.AddLineTo(new CGPoint(desiredWidth - bottomRightCornerSize, desiredHeight)); } else if (cornersTransformType.HasFlag(CornerTransformType.BottomRightRounded)) { path.AddLineTo(new CGPoint(desiredWidth, desiredHeight - bottomRightCornerSize)); path.AddQuadCurveToPoint(new CGPoint(desiredWidth - bottomRightCornerSize, desiredHeight), new CGPoint(desiredWidth, desiredHeight)); } else { path.AddLineTo(new CGPoint(desiredWidth, desiredHeight)); } // BottomLeft if (cornersTransformType.HasFlag(CornerTransformType.BottomLeftCut)) { path.AddLineTo(new CGPoint(bottomLeftCornerSize, desiredHeight)); path.AddLineTo(new CGPoint(0, desiredHeight - bottomLeftCornerSize)); } else if (cornersTransformType.HasFlag(CornerTransformType.BottomLeftRounded)) { path.AddLineTo(new CGPoint(bottomLeftCornerSize, desiredHeight)); path.AddQuadCurveToPoint(new CGPoint(0, desiredHeight - bottomLeftCornerSize), new CGPoint(0, desiredHeight)); } else { path.AddLineTo(new CGPoint(0, desiredHeight)); } path.ClosePath(); context.AddPath(path.CGPath); context.Clip(); } var drawRect = new CGRect(-cropX, -cropY, sourceWidth, sourceHeight); source.Draw(drawRect); var modifiedImage = UIGraphics.GetImageFromCurrentImageContext(); return modifiedImage; } } finally { UIGraphics.EndImageContext(); } }
public override void Draw (CGRect rect) { UIView head = ((WalkingDead)Superview).head; var path = new UIBezierPath { LineCapStyle = CGLineCap.Round }; CGRect headFrame = head.Frame; if (!MovingRight) { rect.X -= 20; path.MoveTo (new CGPoint (rect.GetMidX () + 20, headFrame.GetMaxY () + 10)); path.AddLineTo (new CGPoint (rect.GetMidX () + 20 + rect.Size.Width / 6, headFrame.GetMaxY () + 10)); path.AddLineTo (new CGPoint (rect.GetMidX () + 20 + rect.Size.Width / 6 + 10, headFrame.GetMaxY () + 10 + 20)); } else { path.MoveTo (new CGPoint (rect.GetMidX () - 20, headFrame.GetMaxY () + 10)); path.AddLineTo (new CGPoint (rect.GetMidX () - 20 - rect.Size.Width / 6, headFrame.GetMaxY () + 10)); path.AddLineTo (new CGPoint (rect.GetMidX () - 20 - rect.Size.Width / 6 - 10, headFrame.GetMaxY () + 10 + 20)); } UIColor.Black.SetStroke (); path.LineWidth = 12; path.Stroke (); UIColor.White.SetStroke (); path.LineWidth = 8; path.Stroke (); }
// Graph drawing private Tuple<double, double> DrawGraph(UIView view, List<double> values, SensorTypes type) { var bounds = GraphBounds (values, (type == SensorTypes.Chlorine || type == SensorTypes.Ph)); var points = GraphPoints (values, bounds, view); var numberOfPoints = points.Count; if (numberOfPoints == 0) return bounds; var path = new UIBezierPath (); path.MoveTo (points[0]); for (var i = 1; i < numberOfPoints; i++) { path.AddLineTo (points[i]); } var layer = new CAShapeLayer (); layer.Path = path.CGPath; layer.StrokeColor = UIColor.White.CGColor; layer.LineWidth = 2; layer.FillColor = UIColor.Clear.CGColor; view.Layer.Sublayers = null; view.Layer.AddSublayer (layer); return bounds; }
//Allow the user to import an array of points to be used to draw a signature in the view, with new //lines indicated by a CGPoint.Empty in the array. public void LoadPoints(CGPoint[] loadedPoints) { if (loadedPoints == null || loadedPoints.Count () == 0) return; var startIndex = 0; var emptyIndex = loadedPoints.ToList ().IndexOf (CGPoint.Empty); if (emptyIndex == -1) emptyIndex = loadedPoints.Count (); //Clear any existing paths or points. paths = new List<UIBezierPath> (); points = new List<CGPoint[]> (); do { //Create a new path and set the line options currentPath = UIBezierPath.Create (); currentPath.LineWidth = StrokeWidth; currentPath.LineJoinStyle = CGLineJoin.Round; currentPoints = new List<CGPoint> (); //Move to the first point and add that point to the current_points array. currentPath.MoveTo (loadedPoints [startIndex]); currentPoints.Add (loadedPoints [startIndex]); //Iterate through the array until an empty point (or the end of the array) is reached, //adding each point to the current_path and to the current_points array. for (var i = startIndex + 1; i < emptyIndex; i++) { currentPath.AddLineTo (loadedPoints [i]); currentPoints.Add (loadedPoints [i]); } //Add the current_path and current_points list to their respective Lists before //starting on the next line to be drawn. paths.Add (currentPath); points.Add (currentPoints.ToArray ()); //Obtain the indices for the next line to be drawn. startIndex = emptyIndex + 1; if (startIndex < loadedPoints.Count () - 1) { emptyIndex = loadedPoints.ToList ().IndexOf (CGPoint.Empty, startIndex); if (emptyIndex == -1) emptyIndex = loadedPoints.Count (); } else emptyIndex = startIndex; } while (startIndex < emptyIndex); //Obtain the image for the imported signature and display it in the image view. LoadNewImage(); //Display the clear button. btnClear.Hidden = false; SetNeedsDisplay (); }
//// Drawing Methods public static void DrawTimer(CGRect frame, float percentage) { var context = UIGraphics.GetCurrentContext(); var expression = 360.0f - percentage; var coverViewPath = UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 5.0f, frame.GetMinY() + 4.0f, 230.0f, 230.0f)); DemoStyleKit.Purple.SetFill(); coverViewPath.Fill(); context.SaveState(); context.TranslateCTM(frame.GetMinX() + 120.0f, frame.GetMinY() + 119.0f); context.RotateCTM(-90.0f * NMath.PI / 180.0f); var completedViewRect = new CGRect(-115.0f, -115.0f, 230.0f, 230.0f); var completedViewPath = new UIBezierPath(); completedViewPath.AddArc(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()), completedViewRect.Width / 2.0f, (nfloat)(-360.0f * NMath.PI/180), (nfloat)(-expression * NMath.PI/180.0f), true); completedViewPath.AddLineTo(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY())); completedViewPath.ClosePath(); DemoStyleKit.Green.SetFill(); completedViewPath.Fill(); context.RestoreState(); var backgroundViewPath = UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 10.0f, frame.GetMinY() + 9.0f, 220.0f, 220.0f)); DemoStyleKit.Purple.SetFill(); backgroundViewPath.Fill(); }
void DrawCanvas(CGRect frame) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var color = UIColor.FromRGBA(0.851f, 0.851f, 0.851f, 1.000f); var fillColor3 = UIColor.FromRGBA(0.333f, 0.333f, 0.333f, 1.000f); var fillColor4 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); var fillColor5 = UIColor.FromRGBA(0.867f, 0.867f, 0.863f, 1.000f); var fillColor6 = UIColor.FromRGBA(0.671f, 0.671f, 0.671f, 1.000f); var fillColor7 = UIColor.FromRGBA(0.467f, 0.467f, 0.467f, 1.000f); var fillColor8 = UIColor.FromRGBA(0.918f, 0.478f, 0.149f, 1.000f); var fillColor9 = UIColor.FromRGBA(0.529f, 0.529f, 0.529f, 1.000f); var fillColor10 = UIColor.FromRGBA(0.271f, 0.271f, 0.271f, 1.000f); var color2 = UIColor.FromRGBA(0.941f, 0.941f, 0.941f, 1.000f); var color5 = UIColor.FromRGBA(0.275f, 0.275f, 0.275f, 1.000f); //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX(), frame.GetMinY() + NMath.Floor((frame.Height) * 0.00000f + 0.5f), frame.Width - 0.5f, frame.Height - NMath.Floor((frame.Height) * 0.00000f + 0.5f)), 4.0f); color2.SetFill(); rectanglePath.Fill(); color.SetStroke(); rectanglePath.LineWidth = 1.0f; rectanglePath.Stroke(); //// Group 2 { context.SaveState(); context.TranslateCTM(frame.GetMinX() + 0.43716f * frame.Width, frame.GetMinY() + 0.12195f * frame.Height); context.ScaleCTM(0.4f, 0.4f); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRect(new CGRect(0.0f, 36.0f, 112.0f, 36.0f)); fillColor3.SetFill(); rectangle2Path.Fill(); //// Rectangle 3 Drawing var rectangle3Path = UIBezierPath.FromRect(new CGRect(0.0f, 72.0f, 112.0f, 8.0f)); fillColor4.SetFill(); rectangle3Path.Fill(); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(0.0f, 80.0f)); bezierPath.AddCurveToPoint(new CGPoint(8.0f, 88.0f), new CGPoint(0.0f, 84.42f), new CGPoint(3.58f, 88.0f)); bezierPath.AddLineTo(new CGPoint(104.0f, 88.0f)); bezierPath.AddCurveToPoint(new CGPoint(112.0f, 80.0f), new CGPoint(108.42f, 88.0f), new CGPoint(112.0f, 84.42f)); bezierPath.AddLineTo(new CGPoint(0.0f, 80.0f)); bezierPath.AddLineTo(new CGPoint(0.0f, 80.0f)); bezierPath.ClosePath(); bezierPath.UsesEvenOddFillRule = true; fillColor5.SetFill(); bezierPath.Fill(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new CGPoint(56.3f, 88.0f)); bezier2Path.AddLineTo(new CGPoint(104.0f, 88.0f)); bezier2Path.AddCurveToPoint(new CGPoint(112.0f, 80.0f), new CGPoint(108.42f, 88.0f), new CGPoint(112.0f, 84.42f)); bezier2Path.AddLineTo(new CGPoint(48.3f, 80.0f)); bezier2Path.AddLineTo(new CGPoint(56.3f, 88.0f)); bezier2Path.AddLineTo(new CGPoint(56.3f, 88.0f)); bezier2Path.ClosePath(); bezier2Path.UsesEvenOddFillRule = true; fillColor6.SetFill(); bezier2Path.Fill(); //// Rectangle 4 Drawing var rectangle4Path = UIBezierPath.FromRect(new CGRect(0.0f, 28.0f, 112.0f, 8.0f)); fillColor4.SetFill(); rectangle4Path.Fill(); //// Bezier 3 Drawing UIBezierPath bezier3Path = new UIBezierPath(); bezier3Path.MoveTo(new CGPoint(104.0f, 8.0f)); bezier3Path.AddLineTo(new CGPoint(76.0f, 8.0f)); bezier3Path.AddLineTo(new CGPoint(68.0f, 0.0f)); bezier3Path.AddLineTo(new CGPoint(44.0f, 0.0f)); bezier3Path.AddLineTo(new CGPoint(36.0f, 8.0f)); bezier3Path.AddLineTo(new CGPoint(8.0f, 8.0f)); bezier3Path.AddCurveToPoint(new CGPoint(0.0f, 16.0f), new CGPoint(3.6f, 8.0f), new CGPoint(0.0f, 11.6f)); bezier3Path.AddLineTo(new CGPoint(0.0f, 28.0f)); bezier3Path.AddLineTo(new CGPoint(112.0f, 28.0f)); bezier3Path.AddLineTo(new CGPoint(112.0f, 16.0f)); bezier3Path.AddCurveToPoint(new CGPoint(104.0f, 8.0f), new CGPoint(112.0f, 11.58f), new CGPoint(108.42f, 8.0f)); bezier3Path.AddLineTo(new CGPoint(104.0f, 8.0f)); bezier3Path.ClosePath(); bezier3Path.UsesEvenOddFillRule = true; fillColor5.SetFill(); bezier3Path.Fill(); //// Oval Drawing var ovalPath = UIBezierPath.FromOval(new CGRect(28.0f, 20.0f, 56.0f, 56.0f)); fillColor7.SetFill(); ovalPath.Fill(); //// Oval 2 Drawing var oval2Path = UIBezierPath.FromOval(new CGRect(32.0f, 24.0f, 48.0f, 48.0f)); fillColor4.SetFill(); oval2Path.Fill(); //// Oval 3 Drawing var oval3Path = UIBezierPath.FromOval(new CGRect(8.0f, 16.0f, 8.0f, 8.0f)); fillColor8.SetFill(); oval3Path.Fill(); //// Group 3 { context.SaveState(); context.SetAlpha(0.4f); context.BeginTransparencyLayer(); //// Bezier 4 Drawing UIBezierPath bezier4Path = new UIBezierPath(); bezier4Path.MoveTo(new CGPoint(104.0f, 24.0f)); bezier4Path.AddLineTo(new CGPoint(96.0f, 24.0f)); bezier4Path.AddLineTo(new CGPoint(104.0f, 16.0f)); bezier4Path.AddLineTo(new CGPoint(104.0f, 24.0f)); bezier4Path.ClosePath(); bezier4Path.UsesEvenOddFillRule = true; fillColor3.SetFill(); bezier4Path.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier 5 Drawing UIBezierPath bezier5Path = new UIBezierPath(); bezier5Path.MoveTo(new CGPoint(96.0f, 24.0f)); bezier5Path.AddLineTo(new CGPoint(96.0f, 16.0f)); bezier5Path.AddLineTo(new CGPoint(104.0f, 16.0f)); bezier5Path.AddLineTo(new CGPoint(96.0f, 24.0f)); bezier5Path.ClosePath(); bezier5Path.UsesEvenOddFillRule = true; fillColor9.SetFill(); bezier5Path.Fill(); //// Oval 4 Drawing var oval4Path = UIBezierPath.FromOval(new CGRect(40.0f, 32.0f, 32.0f, 32.0f)); fillColor3.SetFill(); oval4Path.Fill(); //// Bezier 6 Drawing UIBezierPath bezier6Path = new UIBezierPath(); bezier6Path.MoveTo(new CGPoint(60.0f, 36.0f)); bezier6Path.AddCurveToPoint(new CGPoint(44.0f, 52.0f), new CGPoint(51.16f, 36.0f), new CGPoint(44.0f, 43.16f)); bezier6Path.AddCurveToPoint(new CGPoint(46.88f, 61.12f), new CGPoint(44.0f, 55.4f), new CGPoint(45.07f, 58.53f)); bezier6Path.AddCurveToPoint(new CGPoint(56.0f, 64.0f), new CGPoint(49.47f, 62.93f), new CGPoint(52.6f, 64.0f)); bezier6Path.AddCurveToPoint(new CGPoint(72.0f, 48.0f), new CGPoint(64.84f, 64.0f), new CGPoint(72.0f, 56.84f)); bezier6Path.AddCurveToPoint(new CGPoint(69.12f, 38.88f), new CGPoint(72.0f, 44.6f), new CGPoint(70.93f, 41.47f)); bezier6Path.AddCurveToPoint(new CGPoint(60.0f, 36.0f), new CGPoint(66.53f, 37.07f), new CGPoint(63.4f, 36.0f)); bezier6Path.AddLineTo(new CGPoint(60.0f, 36.0f)); bezier6Path.ClosePath(); bezier6Path.UsesEvenOddFillRule = true; fillColor7.SetFill(); bezier6Path.Fill(); //// Oval 5 Drawing var oval5Path = UIBezierPath.FromOval(new CGRect(48.0f, 40.0f, 12.0f, 12.0f)); fillColor6.SetFill(); oval5Path.Fill(); //// Oval 6 Drawing var oval6Path = UIBezierPath.FromOval(new CGRect(60.0f, 48.0f, 8.0f, 8.0f)); fillColor5.SetFill(); oval6Path.Fill(); //// Group 4 { context.SaveState(); context.SetAlpha(0.4f); context.BeginTransparencyLayer(); //// Bezier 7 Drawing UIBezierPath bezier7Path = new UIBezierPath(); bezier7Path.MoveTo(new CGPoint(41.65f, 72.0f)); bezier7Path.AddCurveToPoint(new CGPoint(35.96f, 67.54f), new CGPoint(39.57f, 70.75f), new CGPoint(37.65f, 69.26f)); bezier7Path.AddLineTo(new CGPoint(35.9f, 67.6f)); bezier7Path.AddLineTo(new CGPoint(40.3f, 72.0f)); bezier7Path.AddLineTo(new CGPoint(41.65f, 72.0f)); bezier7Path.AddLineTo(new CGPoint(41.65f, 72.0f)); bezier7Path.ClosePath(); bezier7Path.UsesEvenOddFillRule = true; fillColor3.SetFill(); bezier7Path.Fill(); context.EndTransparencyLayer(); context.RestoreState(); } //// Bezier 8 Drawing UIBezierPath bezier8Path = new UIBezierPath(); bezier8Path.MoveTo(new CGPoint(81.26f, 36.0f)); bezier8Path.AddCurveToPoint(new CGPoint(84.0f, 48.0f), new CGPoint(83.0f, 39.64f), new CGPoint(84.0f, 43.7f)); bezier8Path.AddCurveToPoint(new CGPoint(70.36f, 72.0f), new CGPoint(84.0f, 58.2f), new CGPoint(78.52f, 67.1f)); bezier8Path.AddLineTo(new CGPoint(112.0f, 72.0f)); bezier8Path.AddLineTo(new CGPoint(112.0f, 64.5f)); bezier8Path.AddLineTo(new CGPoint(83.5f, 36.0f)); bezier8Path.AddLineTo(new CGPoint(81.26f, 36.0f)); bezier8Path.AddLineTo(new CGPoint(81.26f, 36.0f)); bezier8Path.ClosePath(); bezier8Path.UsesEvenOddFillRule = true; fillColor10.SetFill(); bezier8Path.Fill(); context.RestoreState(); } //// Text Drawing CGRect textRect = new CGRect(frame.GetMinX() + 7.0f, frame.GetMinY() + NMath.Floor((frame.Height - 8.0f) * 0.67568f + 0.5f), frame.Width - 14.0f, frame.Height - 8.0f - NMath.Floor((frame.Height - 8.0f) * 0.67568f + 0.5f)); { var textContent = "Picture Search"; color5.SetFill(); var textStyle = new NSMutableParagraphStyle(); textStyle.Alignment = UITextAlignment.Center; var textFontAttributes = new UIStringAttributes() { Font = UIFont.FromName("Avenir-Medium", UIFont.ButtonFontSize), ForegroundColor = color5, ParagraphStyle = textStyle }; var textTextHeight = new NSString(textContent).GetBoundingRect(new CGSize(textRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, textFontAttributes, null).Height; context.SaveState(); context.ClipToRect(textRect); new NSString(textContent).DrawString(new CGRect(textRect.GetMinX(), textRect.GetMinY() + (textRect.Height - textTextHeight) / 2.0f, textRect.Width, textTextHeight), UIFont.FromName("Avenir-Medium", UIFont.ButtonFontSize), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); } }
public static void DrawEmotionStatView(CGRect frame, float angerPercentage, float contemptPercentage, float disgustPercentage, float fearPercentage, float happinessPercentage, float neutralPercentage, float sadnessPercentage, float surprisePercentage, float height) { //// General Declarations var colorSpace = CGColorSpace.CreateDeviceRGB(); var context = UIGraphics.GetCurrentContext(); //// Color Declarations var anger1 = UIColor.FromRGBA(1.000f, 0.369f, 0.227f, 1.000f); var anger2 = UIColor.FromRGBA(1.000f, 0.165f, 0.408f, 1.000f); var neutral1 = UIColor.FromRGBA(0.859f, 0.867f, 0.871f, 1.000f); var neutral2 = UIColor.FromRGBA(0.537f, 0.549f, 0.565f, 1.000f); var happy1 = UIColor.FromRGBA(1.000f, 0.859f, 0.298f, 1.000f); var happy2 = UIColor.FromRGBA(1.000f, 0.804f, 0.008f, 1.000f); var surprise1 = UIColor.FromRGBA(0.102f, 0.839f, 0.992f, 1.000f); var surprise2 = UIColor.FromRGBA(0.114f, 0.384f, 0.941f, 1.000f); var sadness1 = UIColor.FromRGBA(0.290f, 0.290f, 0.290f, 1.000f); var sadness2 = UIColor.FromRGBA(0.169f, 0.169f, 0.169f, 1.000f); var disgust1 = UIColor.FromRGBA(0.529f, 0.988f, 0.439f, 1.000f); var disgust2 = UIColor.FromRGBA(0.043f, 0.827f, 0.094f, 1.000f); var fear1 = UIColor.FromRGBA(0.776f, 0.267f, 0.988f, 1.000f); var fear2 = UIColor.FromRGBA(0.345f, 0.337f, 0.839f, 1.000f); var contempt1 = UIColor.FromRGBA(1.000f, 0.584f, 0.000f, 1.000f); var contempt2 = UIColor.FromRGBA(0.721f, 0.421f, 0.000f, 1.000f); //// Gradient Declarations var angerGradientColors = new CGColor [] {anger1.CGColor, anger2.CGColor}; var angerGradientLocations = new nfloat [] {0.0f, 1.0f}; var angerGradient = new CGGradient(colorSpace, angerGradientColors, angerGradientLocations); var neutralGradientColors = new CGColor [] {neutral1.CGColor, neutral2.CGColor}; var neutralGradientLocations = new nfloat [] {0.0f, 1.0f}; var neutralGradient = new CGGradient(colorSpace, neutralGradientColors, neutralGradientLocations); var happyGradientColors = new CGColor [] {happy1.CGColor, happy2.CGColor}; var happyGradientLocations = new nfloat [] {0.0f, 1.0f}; var happyGradient = new CGGradient(colorSpace, happyGradientColors, happyGradientLocations); var surpriseGradientColors = new CGColor [] {surprise1.CGColor, surprise2.CGColor}; var surpriseGradientLocations = new nfloat [] {0.0f, 1.0f}; var surpriseGradient = new CGGradient(colorSpace, surpriseGradientColors, surpriseGradientLocations); var sadnessGradientColors = new CGColor [] {sadness1.CGColor, sadness2.CGColor}; var sadnessGradientLocations = new nfloat [] {0.0f, 1.0f}; var sadnessGradient = new CGGradient(colorSpace, sadnessGradientColors, sadnessGradientLocations); var disgustGradientColors = new CGColor [] {disgust1.CGColor, disgust2.CGColor}; var disgustGradientLocations = new nfloat [] {0.0f, 1.0f}; var disgustGradient = new CGGradient(colorSpace, disgustGradientColors, disgustGradientLocations); var fearGradientColors = new CGColor [] {fear1.CGColor, fear2.CGColor}; var fearGradientLocations = new nfloat [] {0.0f, 1.0f}; var fearGradient = new CGGradient(colorSpace, fearGradientColors, fearGradientLocations); var contemptGradientColors = new CGColor [] {contempt1.CGColor, contempt2.CGColor}; var contemptGradientLocations = new nfloat [] {0.0f, 1.0f}; var contemptGradient = new CGGradient(colorSpace, contemptGradientColors, contemptGradientLocations); //// Variable Declarations var angerY = height - height / 100.0f * angerPercentage - 25.0f + angerPercentage * 0.25f; var contemptY = height - height / 100.0f * contemptPercentage - 25.0f + contemptPercentage * 0.25f; var disgustY = height - height / 100.0f * disgustPercentage - 25.0f + disgustPercentage * 0.25f; var fearY = height - height / 100.0f * fearPercentage - 25.0f + fearPercentage * 0.25f; var happinessY = height - height / 100.0f * happinessPercentage - 25.0f + happinessPercentage * 0.25f; var neutralY = height - height / 100.0f * neutralPercentage - 25.0f + neutralPercentage * 0.25f; var sadnessY = height - height / 100.0f * sadnessPercentage - 25.0f + sadnessPercentage * 0.25f; var surpriseY = height - height / 100.0f * surprisePercentage - 25.0f + surprisePercentage * 0.25f; //// Bezier Drawing context.SaveState(); context.TranslateCTM(0.0f, angerY); UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new CGPoint(50.0f, 28.5f)); bezierPath.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezierPath.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezierPath.AddLineTo(new CGPoint(0.22f, 301.75f)); bezierPath.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezierPath.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezierPath.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezierPath.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezierPath.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezierPath.ClosePath(); context.SaveState(); bezierPath.AddClip(); CGRect bezierBounds = bezierPath.CGPath.PathBoundingBox; context.DrawLinearGradient(angerGradient, new CGPoint(bezierBounds.GetMidX(), bezierBounds.GetMinY()), new CGPoint(bezierBounds.GetMidX(), bezierBounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); //// Bezier 2 Drawing context.SaveState(); context.TranslateCTM(51.0f, sadnessY); UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new CGPoint(50.0f, 28.5f)); bezier2Path.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezier2Path.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezier2Path.AddLineTo(new CGPoint(0.22f, 301.75f)); bezier2Path.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezier2Path.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezier2Path.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezier2Path.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezier2Path.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezier2Path.ClosePath(); context.SaveState(); bezier2Path.AddClip(); CGRect bezier2Bounds = bezier2Path.CGPath.PathBoundingBox; context.DrawLinearGradient(sadnessGradient, new CGPoint(bezier2Bounds.GetMidX(), bezier2Bounds.GetMinY()), new CGPoint(bezier2Bounds.GetMidX(), bezier2Bounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); //// Bezier 3 Drawing context.SaveState(); context.TranslateCTM(102.0f, disgustY); UIBezierPath bezier3Path = new UIBezierPath(); bezier3Path.MoveTo(new CGPoint(50.0f, 28.5f)); bezier3Path.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezier3Path.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezier3Path.AddLineTo(new CGPoint(0.22f, 301.75f)); bezier3Path.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezier3Path.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezier3Path.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezier3Path.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezier3Path.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezier3Path.ClosePath(); context.SaveState(); bezier3Path.AddClip(); CGRect bezier3Bounds = bezier3Path.CGPath.PathBoundingBox; context.DrawLinearGradient(disgustGradient, new CGPoint(bezier3Bounds.GetMidX(), bezier3Bounds.GetMinY()), new CGPoint(bezier3Bounds.GetMidX(), bezier3Bounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); //// Bezier 4 Drawing context.SaveState(); context.TranslateCTM(153.0f, fearY); UIBezierPath bezier4Path = new UIBezierPath(); bezier4Path.MoveTo(new CGPoint(50.0f, 28.5f)); bezier4Path.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezier4Path.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezier4Path.AddLineTo(new CGPoint(0.22f, 301.75f)); bezier4Path.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezier4Path.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezier4Path.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezier4Path.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezier4Path.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezier4Path.ClosePath(); context.SaveState(); bezier4Path.AddClip(); CGRect bezier4Bounds = bezier4Path.CGPath.PathBoundingBox; context.DrawLinearGradient(fearGradient, new CGPoint(bezier4Bounds.GetMidX(), bezier4Bounds.GetMinY()), new CGPoint(bezier4Bounds.GetMidX(), bezier4Bounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); //// Bezier 5 Drawing context.SaveState(); context.TranslateCTM(204.0f, happinessY); UIBezierPath bezier5Path = new UIBezierPath(); bezier5Path.MoveTo(new CGPoint(50.0f, 28.5f)); bezier5Path.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezier5Path.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezier5Path.AddLineTo(new CGPoint(0.22f, 301.75f)); bezier5Path.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezier5Path.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezier5Path.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezier5Path.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezier5Path.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezier5Path.ClosePath(); context.SaveState(); bezier5Path.AddClip(); CGRect bezier5Bounds = bezier5Path.CGPath.PathBoundingBox; context.DrawLinearGradient(happyGradient, new CGPoint(bezier5Bounds.GetMidX(), bezier5Bounds.GetMinY()), new CGPoint(bezier5Bounds.GetMidX(), bezier5Bounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); //// Bezier 6 Drawing context.SaveState(); context.TranslateCTM(255.0f, neutralY); UIBezierPath bezier6Path = new UIBezierPath(); bezier6Path.MoveTo(new CGPoint(50.0f, 28.5f)); bezier6Path.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezier6Path.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezier6Path.AddLineTo(new CGPoint(0.22f, 301.75f)); bezier6Path.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezier6Path.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezier6Path.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezier6Path.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezier6Path.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezier6Path.ClosePath(); context.SaveState(); bezier6Path.AddClip(); CGRect bezier6Bounds = bezier6Path.CGPath.PathBoundingBox; context.DrawLinearGradient(neutralGradient, new CGPoint(bezier6Bounds.GetMidX(), bezier6Bounds.GetMinY()), new CGPoint(bezier6Bounds.GetMidX(), bezier6Bounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); //// Bezier 7 Drawing context.SaveState(); context.TranslateCTM(306.0f, surpriseY); UIBezierPath bezier7Path = new UIBezierPath(); bezier7Path.MoveTo(new CGPoint(50.0f, 28.5f)); bezier7Path.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezier7Path.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezier7Path.AddLineTo(new CGPoint(0.22f, 301.75f)); bezier7Path.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezier7Path.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezier7Path.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezier7Path.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezier7Path.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezier7Path.ClosePath(); context.SaveState(); bezier7Path.AddClip(); CGRect bezier7Bounds = bezier7Path.CGPath.PathBoundingBox; context.DrawLinearGradient(surpriseGradient, new CGPoint(bezier7Bounds.GetMidX(), bezier7Bounds.GetMinY()), new CGPoint(bezier7Bounds.GetMidX(), bezier7Bounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); //// Bezier 8 Drawing context.SaveState(); context.TranslateCTM(357.0f, contemptY); UIBezierPath bezier8Path = new UIBezierPath(); bezier8Path.MoveTo(new CGPoint(50.0f, 28.5f)); bezier8Path.AddCurveToPoint(new CGPoint(49.97f, 30.0f), new CGPoint(50.0f, 29.0f), new CGPoint(49.99f, 29.5f)); bezier8Path.AddCurveToPoint(new CGPoint(50.0f, 301.75f), new CGPoint(50.0f, 30.0f), new CGPoint(50.0f, 301.75f)); bezier8Path.AddLineTo(new CGPoint(0.22f, 301.75f)); bezier8Path.AddCurveToPoint(new CGPoint(0.22f, 32.29f), new CGPoint(0.22f, 301.75f), new CGPoint(0.22f, 58.53f)); bezier8Path.AddCurveToPoint(new CGPoint(0.0f, 28.5f), new CGPoint(0.07f, 31.05f), new CGPoint(-0.0f, 29.78f)); bezier8Path.AddCurveToPoint(new CGPoint(9.9f, 5.79f), new CGPoint(0.0f, 19.23f), new CGPoint(3.88f, 10.99f)); bezier8Path.AddCurveToPoint(new CGPoint(25.0f, 0.0f), new CGPoint(14.09f, 2.16f), new CGPoint(19.33f, -0.0f)); bezier8Path.AddCurveToPoint(new CGPoint(50.0f, 28.5f), new CGPoint(38.81f, 0.0f), new CGPoint(50.0f, 12.76f)); bezier8Path.ClosePath(); context.SaveState(); bezier8Path.AddClip(); CGRect bezier8Bounds = bezier8Path.CGPath.PathBoundingBox; context.DrawLinearGradient(contemptGradient, new CGPoint(bezier8Bounds.GetMidX(), bezier8Bounds.GetMinY()), new CGPoint(bezier8Bounds.GetMidX(), bezier8Bounds.GetMaxY()), 0); context.RestoreState(); context.RestoreState(); }
public override void Draw (CGRect rect) { base.Draw (rect); var drawPath = new UIBezierPath (); drawPath.LineCapStyle = CGLineCap.Round; foreach (var line in Lines) { drawPath.MoveTo (line.Start); drawPath.AddLineTo (line.End); } drawPath.LineWidth = LineWidth; Color.SetColor (); drawPath.Stroke (); }
public override void Draw (CGRect rect) { base.Draw (rect); var posX = (rect.Width - radius) / 2; var posY = (rect.Height - radius) / 2; using (var context = UIGraphics.GetCurrentContext ()) { UIBezierPath ovalPath; UIBezierPath bezierPath; if (isActive) { if (isRunning) { // Oval Drawing ovalPath = UIBezierPath.FromOval (new CGRect (posX, posY, radius, radius)); redColor.SetFill(); ovalPath.Fill(); // Rectangle Drawing var rectanglePath = UIBezierPath.FromRect (new CGRect (posX + 12.0f, posY + 12.0f, 8.0f, 8.0f)); UIColor.White.SetFill(); rectanglePath.Fill(); } else { // Oval Drawing ovalPath = UIBezierPath.FromOval (new CGRect (posX, posY, radius, radius)); greenColor.SetFill (); ovalPath.Fill (); // Bezier Drawing bezierPath = new UIBezierPath (); bezierPath.MoveTo (new CGPoint (posX + 13.0f, posY + 8.0f)); bezierPath.AddLineTo (new CGPoint (posX + 20.0f, posY + 16.47f)); bezierPath.AddLineTo (new CGPoint (posX + 13.0f, posY + 24.0f)); UIColor.White.SetStroke (); bezierPath.LineWidth = 1.0f; bezierPath.Stroke (); } } else { // Oval Drawing UIColor.White.SetStroke (); ovalPath = UIBezierPath.FromOval (new CGRect (posX, posY, radius, radius)); ovalPath.LineWidth = 1.0f; ovalPath.Stroke (); context.AddPath (ovalPath.CGPath); // Bezier Drawing bezierPath = new UIBezierPath (); bezierPath.MoveTo (new CGPoint (posX + 13.0f, posY + 8.0f)); bezierPath.AddLineTo (new CGPoint (posX + 20.0f, posY + 16.47f)); bezierPath.AddLineTo (new CGPoint (posX + 13.0f, posY + 24.0f)); bezierPath.LineWidth = 1.0f; bezierPath.Stroke (); context.AddPath (bezierPath.CGPath); } } }