public override void TouchesBegan (NSSet touches, UIEvent evt) { IndexCount++; var path = new UIBezierPath { LineWidth = PenWidth }; var touch = (UITouch)touches.AnyObject; PreviousPoint = touch.PreviousLocationInView (this); var newPoint = touch.LocationInView (this); path.MoveTo (newPoint); InvokeOnMainThread (SetNeedsDisplay); CurrentPath = path; var line = new VESLine { Path = CurrentPath, Color = CurrentLineColor, Index = IndexCount }; Lines.Add (line); }
public override void DrawRect (System.Drawing.RectangleF area, UIViewPrintFormatter formatter) { base.DrawRect (area, formatter); CGContext context = UIGraphics.GetCurrentContext (); UIColor shadow; shadow = UIColor.Clear; UIColor chevronColor = this.Color; SizeF shadowOffset = new SizeF (0.1F, 1.1F); Single shadowBlurRadius = 0F; RectangleF frame = new RectangleF (this.Bounds.X, this.Bounds.Y, this.Bounds.Width, this.Bounds.Height); UIBezierPath chevronPath = new UIBezierPath (); chevronPath.MoveTo (new PointF (frame.GetMinX () + 0.22000F * frame.Width, frame.GetMinY () + 0.01667F * frame.Height)); chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.98000F * frame.Width, frame.GetMinY() + 0.48333F * frame.Height)); chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.22000F * frame.Width, frame.GetMinY() + 0.98333F * frame.Height)); chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.02000F * frame.Width, frame.GetMinY() + 0.81667F * frame.Height)); chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.54000F * frame.Width, frame.GetMinY() + 0.48333F * frame.Height)); chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.02000F * frame.Width, frame.GetMinY() + 0.15000F * frame.Height)); chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.22000F * frame.Width, frame.GetMinY() + 0.01667F * frame.Height)); chevronPath.ClosePath (); context.SaveState (); context.SetShadowWithColor (shadowOffset, shadowBlurRadius, shadow.CGColor); chevronColor.SetFill (); chevronPath.Fill (); context.RestoreState (); }
public override void Draw(RectangleF rect) { TintColor.SetColor (); RectangleF bounds = Bounds; float x = bounds.Right - LineWidth; for (int n = 0; n < Count; n++) { x -= LineMargin; if ((n + 1) % LineGroupCount == 0) { UIBezierPath path = new UIBezierPath (); path.MoveTo ( new PointF (x + 0.5f * LineWidth, bounds.Top + 0.5f * LineWidth)); path.AddLineTo ( new PointF (x + 0.5f * LineWidth + LineGroupCount * LineMargin, bounds.Bottom - 0.5f * LineWidth)); path.Stroke (); } else { RectangleF lineRect = bounds; lineRect.X = x; lineRect.Width = LineWidth; UIGraphics.RectFill (lineRect); } } }
public static UIImage MakeBackArrow() { bool retina = (UIScreen.MainScreen.Scale > 1.0); if (retina) { UIGraphics.BeginImageContext (new System.Drawing.SizeF (44, 44)); //BEGIN PAINTCODE RETINA //// Color Declarations UIColor gradient2Color = UIColor.FromRGBA(0.018f, 0.324f, 0.969f, 1.000f); //// Bezier 5 Drawing UIBezierPath bezier5Path = new UIBezierPath(); bezier5Path.MoveTo(new PointF(14.5f, 16.31f)); bezier5Path.AddLineTo(new PointF(39.5f, 16.31f)); bezier5Path.AddLineTo(new PointF(39.5f, 26.69f)); bezier5Path.AddLineTo(new PointF(14.5f, 26.69f)); bezier5Path.AddLineTo(new PointF(14.5f, 41.5f)); bezier5Path.AddLineTo(new PointF(2.5f, 20.32f)); bezier5Path.AddLineTo(new PointF(14.5f, 1.5f)); bezier5Path.AddLineTo(new PointF(14.5f, 16.31f)); bezier5Path.ClosePath(); gradient2Color.SetFill(); bezier5Path.Fill(); gradient2Color.SetStroke(); bezier5Path.LineWidth = 1; bezier5Path.Stroke(); //END PAINTCODE RETINA } else { UIGraphics.BeginImageContext (new System.Drawing.SizeF (22, 22)); //start paintcode NON RETINA //// Color Declarations UIColor gradient2Color = UIColor.FromRGBA(0.018f, 0.324f, 0.969f, 1.000f); //// Bezier 5 Drawing UIBezierPath bezier5Path = new UIBezierPath(); bezier5Path.MoveTo(new PointF(7.99f, 8.91f)); bezier5Path.AddLineTo(new PointF(21.5f, 8.91f)); bezier5Path.AddLineTo(new PointF(21.5f, 14.09f)); bezier5Path.AddLineTo(new PointF(7.99f, 14.09f)); bezier5Path.AddLineTo(new PointF(7.5f, 20.5f)); bezier5Path.AddLineTo(new PointF(1.5f, 10.91f)); bezier5Path.AddLineTo(new PointF(7.99f, 1.5f)); bezier5Path.AddLineTo(new PointF(7.99f, 8.91f)); bezier5Path.ClosePath(); gradient2Color.SetFill(); bezier5Path.Fill(); gradient2Color.SetStroke(); bezier5Path.LineWidth = 1; bezier5Path.Stroke(); //END PAINTCODE NON RETINA } var converted = UIGraphics.GetImageFromCurrentImageContext (); UIGraphics.EndImageContext (); return converted; }
public override void Draw (RectangleF rect) { rect = RectangleF.Inflate (rect, 4, 4); rect = new RectangleF ((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 PointF (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30)); mouth.AddLineTo (new PointF (rect.GetMidX () + 13, rect.Y + 30)); } else { rightEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30)); mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30)); } rightEye.LineWidth = 2; rightEye.Stroke (); leftEye.LineWidth = 2; leftEye.Stroke (); mouth.LineWidth = 2; mouth.Stroke (); }
public SmoothedBIView (NSCoder aDecoder) { // this.SetMultipleTouchEnabled(false); MultipleTouchEnabled = false; // path = UIBezierPath.BezierPath(); Path = new UIBezierPath (); // path.SetLineWidth(2.0); Path.LineWidth = 3.0f; }
public SmoothedBIView (RectangleF frame) : base (frame) { // this.SetMultipleTouchEnabled(false); MultipleTouchEnabled = false; // path = UIBezierPath.BezierPath(); Path = new UIBezierPath (); // path.SetLineWidth(2.0); Path.LineWidth = 4.0f; this.BackgroundColor = UIColor.FromWhiteAlpha(1f,0f); }
async Task animateView(UIView view) { var size = view.Frame.Size; var grow = new SizeF(size.Width * 1.7f, size.Height * 1.7f); var shrink = new SizeF(size.Width * .4f, size.Height * .4f); TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(); //Set the animation path var pathAnimation = CAKeyFrameAnimation.GetFromKeyPath("position"); pathAnimation.CalculationMode = CAAnimation.AnimationPaced; pathAnimation.FillMode = CAFillMode.Forwards; pathAnimation.RemovedOnCompletion = false; pathAnimation.Duration = .5; UIBezierPath path = new UIBezierPath(); path.MoveTo(view.Center); path.AddQuadCurveToPoint(new PointF(290, 34), new PointF(view.Center.X, View.Center.Y)); pathAnimation.Path = path.CGPath; //Set size change var growAnimation = CABasicAnimation.FromKeyPath("bounds.size"); growAnimation.To = NSValue.FromSizeF(grow); growAnimation.FillMode = CAFillMode.Forwards; growAnimation.Duration = .1; growAnimation.RemovedOnCompletion = false; var shrinkAnimation = CABasicAnimation.FromKeyPath("bounds.size"); shrinkAnimation.To = NSValue.FromSizeF(shrink); shrinkAnimation.FillMode = CAFillMode.Forwards; shrinkAnimation.Duration = .4; shrinkAnimation.RemovedOnCompletion = false; shrinkAnimation.BeginTime = .1; CAAnimationGroup animations = new CAAnimationGroup(); animations.FillMode = CAFillMode.Forwards; animations.RemovedOnCompletion = false; animations.Animations = new CAAnimation[] { pathAnimation, growAnimation, shrinkAnimation, }; animations.Duration = .5; animations.AnimationStopped += (sender, e) => { tcs.TrySetResult(true); }; view.Layer.AddAnimation(animations, "movetocart"); NSTimer.CreateScheduledTimer(.5, () => view.RemoveFromSuperview()); await tcs.Task; }
public UISignatureView(RectangleF rect) : base(rect) { this.MultipleTouchEnabled = false; this.BackgroundColor = UIColor.White; this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin; path = new UIBezierPath(); path.LineWidth = this.StrokeWidth; SetSize (); SetShadow (); CreateUIElements (); SubscribeToNotifications (); }
static void paintCodeNonRetina() { //// Color Declarations UIColor color = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); UIColor color2 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 0.000f); //// Group { //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new PointF(15.05f, 2.27f)); bezierPath.AddLineTo(new PointF(7.17f, 12.34f)); bezierPath.AddCurveToPoint(new PointF(11.5f, 4.39f), new PointF(7.17f, 12.34f), new PointF(9.53f, 6.9f)); bezierPath.AddCurveToPoint(new PointF(15.05f, 2.27f), new PointF(13.47f, 1.87f), new PointF(15.05f, 2.27f)); color.SetFill(); bezierPath.Fill(); UIColor.Black.SetStroke(); bezierPath.LineWidth = 1; bezierPath.Stroke(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new PointF(7.56f, 12.87f)); bezier2Path.AddCurveToPoint(new PointF(17.8f, 5.98f), new PointF(7.56f, 12.87f), new PointF(17.82f, 5.8f)); bezier2Path.AddCurveToPoint(new PointF(16.62f, 8.1f), new PointF(17.78f, 6.15f), new PointF(18.68f, 5.93f)); bezier2Path.AddCurveToPoint(new PointF(7.56f, 12.87f), new PointF(14.56f, 10.26f), new PointF(7.56f, 12.87f)); bezier2Path.ClosePath(); color.SetFill(); bezier2Path.Fill(); UIColor.Black.SetStroke(); bezier2Path.LineWidth = 1; bezier2Path.Stroke(); //// Oval 2 Drawing var oval2Path = UIBezierPath.FromOval(new RectangleF(5.5f, 12.5f, 4, 5)); color2.SetFill(); oval2Path.Fill(); UIColor.Black.SetStroke(); oval2Path.LineWidth = 2; oval2Path.Stroke(); //// Oval Drawing var ovalPath = UIBezierPath.FromOval(new RectangleF(3.5f, 9.5f, 4, 5)); color2.SetFill(); ovalPath.Fill(); UIColor.Black.SetStroke(); ovalPath.LineWidth = 2; ovalPath.Stroke(); } }
static void paintCodeRetina() { //// Color Declarations UIColor color2 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new PointF(22.72f, 5.43f)); bezierPath.AddCurveToPoint(new PointF(23.37f, 6.19f), new PointF(22.95f, 5.67f), new PointF(23.17f, 5.93f)); bezierPath.AddCurveToPoint(new PointF(27.47f, 4.67f), new PointF(24.63f, 5.42f), new PointF(26.03f, 4.91f)); bezierPath.AddCurveToPoint(new PointF(37.28f, 7.43f), new PointF(30.92f, 4.09f), new PointF(34.61f, 5.01f)); bezierPath.AddCurveToPoint(new PointF(37.28f, 21.57f), new PointF(41.57f, 11.33f), new PointF(41.57f, 17.67f)); bezierPath.AddCurveToPoint(new PointF(27.49f, 24.33f), new PointF(34.62f, 23.99f), new PointF(30.93f, 24.91f)); bezierPath.AddCurveToPoint(new PointF(24.72f, 29.3f), new PointF(27.39f, 26.14f), new PointF(26.47f, 27.92f)); bezierPath.AddCurveToPoint(new PointF(11.28f, 29.3f), new PointF(21.01f, 32.23f), new PointF(14.99f, 32.23f)); bezierPath.AddCurveToPoint(new PointF(9.86f, 20.13f), new PointF(8.13f, 26.82f), new PointF(7.66f, 23.01f)); bezierPath.AddCurveToPoint(new PointF(9.28f, 19.57f), new PointF(9.66f, 19.95f), new PointF(9.47f, 19.77f)); bezierPath.AddCurveToPoint(new PointF(9.28f, 5.43f), new PointF(5.57f, 15.67f), new PointF(5.57f, 9.33f)); bezierPath.AddCurveToPoint(new PointF(22.72f, 5.43f), new PointF(12.99f, 1.52f), new PointF(19.01f, 1.52f)); bezierPath.ClosePath(); UIColor.White.SetFill(); bezierPath.Fill(); UIColor.Black.SetStroke(); bezierPath.LineWidth = 1; bezierPath.Stroke(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new PointF(3.5f, 40.5f)); bezier2Path.AddCurveToPoint(new PointF(9.5f, 33.5f), new PointF(9.5f, 33.5f), new PointF(9.5f, 33.5f)); color2.SetFill(); bezier2Path.Fill(); UIColor.Black.SetStroke(); bezier2Path.LineWidth = 2.5f; bezier2Path.Stroke(); //// Bezier 3 Drawing UIBezierPath bezier3Path = new UIBezierPath(); bezier3Path.MoveTo(new PointF(6.5f, 32.5f)); bezier3Path.AddLineTo(new PointF(11.5f, 37.5f)); bezier3Path.AddLineTo(new PointF(10.5f, 32.5f)); bezier3Path.AddLineTo(new PointF(6.5f, 32.5f)); bezier3Path.ClosePath(); color2.SetFill(); bezier3Path.Fill(); UIColor.Black.SetStroke(); bezier3Path.LineWidth = 1; bezier3Path.Stroke(); }
static void paintCodeRetina() { //// Color Declarations UIColor color = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); UIColor color2 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 0.000f); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new PointF(33.51f, 2.63f)); bezierPath.AddLineTo(new PointF(13.55f, 26.55f)); bezierPath.AddCurveToPoint(new PointF(24.53f, 7.67f), new PointF(13.55f, 26.55f), new PointF(19.54f, 13.65f)); bezierPath.AddCurveToPoint(new PointF(33.51f, 2.63f), new PointF(29.52f, 1.69f), new PointF(33.51f, 2.63f)); color.SetFill(); bezierPath.Fill(); UIColor.Black.SetStroke(); bezierPath.LineWidth = 1; bezierPath.Stroke(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new PointF(14.55f, 27.81f)); bezier2Path.AddCurveToPoint(new PointF(40.5f, 11.44f), new PointF(14.55f, 27.81f), new PointF(40.56f, 11.03f)); bezier2Path.AddCurveToPoint(new PointF(37.51f, 16.48f), new PointF(40.45f, 11.85f), new PointF(42.73f, 11.33f)); bezier2Path.AddCurveToPoint(new PointF(14.55f, 27.81f), new PointF(32.28f, 21.62f), new PointF(14.55f, 27.81f)); bezier2Path.ClosePath(); color.SetFill(); bezier2Path.Fill(); UIColor.Black.SetStroke(); bezier2Path.LineWidth = 1; bezier2Path.Stroke(); //// Oval 2 Drawing var oval2Path = UIBezierPath.FromOval(new RectangleF(9.5f, 27.5f, 9, 12)); color2.SetFill(); oval2Path.Fill(); UIColor.Black.SetStroke(); oval2Path.LineWidth = 2; oval2Path.Stroke(); //// Oval Drawing var ovalPath = UIBezierPath.FromOval(new RectangleF(3.5f, 19.5f, 10, 12)); color2.SetFill(); ovalPath.Fill(); UIColor.Black.SetStroke(); ovalPath.LineWidth = 2; ovalPath.Stroke(); }
static void paintCodeRetina() { //// Color Declarations UIColor color = UIColor.FromRGBA(0.000f, 0.219f, 0.657f, 1.000f); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new PointF(1.5f, 1.5f)); bezierPath.AddCurveToPoint(new PointF(40.5f, 41.5f), new PointF(40.5f, 41.5f), new PointF(40.5f, 41.5f)); color.SetStroke(); bezierPath.LineWidth = 4; bezierPath.Stroke(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new PointF(40.5f, 1.5f)); bezier2Path.AddLineTo(new PointF(1.5f, 42.5f)); color.SetStroke(); bezier2Path.LineWidth = 4; bezier2Path.Stroke(); }
void DrawCrayon(CGContext context, Crayon crayon) { // I <3 Paintcode //// Color Declarations var gradientColor = UIColor.FromRGBA(crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 1.00f); var gradientColor2 = UIColor.FromRGBA(crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 0.69f); var gradientColor3 = UIColor.FromRGBA(crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 0.37f); //// Gradient Declarations var gradientColors = new CGColor [] { gradientColor.CGColor, gradientColor2.CGColor, gradientColor3.CGColor, gradientColor2.CGColor, gradientColor.CGColor }; var gradientLocations = new float [] { 0, 0.37f, 0.66f, 1, 1 }; var gradient = new CGGradient(colorSpace, gradientColors, gradientLocations); //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect(new RectangleF(0.5f, 20.5f, 25, 100), UIRectCorner.TopLeft | UIRectCorner.TopRight, new SizeF(8, 8)); context.SaveState(); rectanglePath.AddClip(); context.DrawLinearGradient(gradient, new PointF(0.5f, 70.5f), new PointF(25.5f, 70.5f), 0); context.RestoreState(); //// Bezier Drawing UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new PointF(3.5f, 24.5f)); bezierPath.AddCurveToPoint(new PointF(12, 0.09f), new PointF(6.5f, 17.57f), new PointF(9.79f, -4.27f)); bezierPath.AddCurveToPoint(new PointF(22.5f, 24.5f), new PointF(16.3f, 8.57f), new PointF(22.5f, 24.5f)); context.SaveState(); bezierPath.AddClip(); context.DrawLinearGradient(gradient, new PointF(3.5f, 12.01f), new PointF(22.5f, 12.01f), 0); context.RestoreState(); }
private void NewElement_SizeChanged(object sender, EventArgs e) { if (_backgroundLayer != null) { _backgroundLayer.RemoveFromSuperLayer(); } if (_foregroundLayer != null) { _foregroundLayer.RemoveFromSuperLayer(); } var view = Element as HoursProgressView; var currentProgressWidth = (view.Current - view.Min) / (view.Max - view.Min); var backgroundPath = new UIBezierPath(); backgroundPath.MoveTo(new CoreGraphics.CGPoint(0, view.Height / 2)); backgroundPath.AddLineTo(new CoreGraphics.CGPoint(view.Width, view.Height / 2)); backgroundPath.LineWidth = 5; _backgroundLayer = new CAShapeLayer(); _backgroundLayer.Path = backgroundPath.CGPath; _backgroundLayer.StrokeColor = view.BarColor.ToCGColor(); Layer.AddSublayer(_backgroundLayer); var foregroundPath = new UIBezierPath(); foregroundPath.MoveTo(new CoreGraphics.CGPoint(0, view.Height / 2)); foregroundPath.AddLineTo(new CoreGraphics.CGPoint(view.Width * currentProgressWidth, view.Height / 2)); foregroundPath.LineWidth = 5; _foregroundLayer = new CAShapeLayer(); _foregroundLayer.Path = foregroundPath.CGPath; _foregroundLayer.StrokeColor = view.FillColor.ToCGColor(); Layer.AddSublayer(_foregroundLayer); }
public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt) { //Create a new path and set the options. currentPath = UIBezierPath.Create(); currentPath.LineWidth = StrokeWidth; currentPath.LineJoinStyle = CGLineJoin.Round; currentPoints.Clear(); UITouch touch = touches.AnyObject as UITouch; //Obtain the location of the touch, move the path to that position and add it to the //current_points array. CGPoint touchLocation = touch.LocationInView(this); currentPath.MoveTo(touchLocation); currentPoints.Add(touchLocation); resetBounds(touchLocation); btnClear.Hidden = false; }
public override void Draw(CGRect frame) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX() + 14.0f, frame.GetMinY() + 2.0f, NMath.Floor((frame.Width - 14.0f) * 0.20776f + 0.5f), 21.0f), UIRectCorner.TopLeft | UIRectCorner.TopRight, new SizeF(4.0f, 4.0f)); rectanglePath.ClosePath(); Helpers.Colours.Green.SetFill(); rectanglePath.Fill(); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRect(new CGRect(frame.GetMinX(), frame.GetMinY() + 23.0f, 375.0f, 1.0f)); Helpers.Colours.Green.SetFill(); rectangle2Path.Fill(); //// Text Drawing CGRect textRect = new CGRect(frame.GetMinX() + NMath.Floor(frame.Width * 0.03733f + 0.5f), frame.GetMinY() + 3.0f, NMath.Floor(frame.Width * 0.23733f + 0.5f) - NMath.Floor(frame.Width * 0.03733f + 0.5f), 21.0f); UIColor.White.SetFill(); var textStyle = new NSMutableParagraphStyle(); textStyle.Alignment = UITextAlignment.Center; var textFontAttributes = new UIStringAttributes() { Font = UIFont.FromName("Avenir-Medium", UIFont.SmallSystemFontSize), ForegroundColor = UIColor.White, ParagraphStyle = textStyle }; var textTextHeight = new NSString(header).GetBoundingRect(new CGSize(textRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, textFontAttributes, null).Height; context.SaveState(); context.ClipToRect(textRect); new NSString(header).DrawString(new CGRect(textRect.GetMinX(), textRect.GetMinY() + (textRect.Height - textTextHeight) / 2.0f, textRect.Width, textTextHeight), UIFont.FromName("Avenir-Medium", UIFont.SmallSystemFontSize), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); }
public override void LayoutSublayers() { Frame = View.Bounds; LineWidth = 2; FillColor = UIColor.Clear.CGColor; LineJoin = JoinRound; LineDashPattern = new [] { NSNumber.FromNInt(2), NSNumber.FromNInt(5), NSNumber.FromNInt(5) }; var path = UIBezierPath.FromRoundedRect(Bounds, 15); Path = path.CGPath; var flash = CABasicAnimation.FromKeyPath("opacity"); flash.SetFrom(NSNumber.FromFloat(0)); flash.SetTo(NSNumber.FromFloat(1)); flash.Duration = 0.75; flash.RepeatCount = 10000; AddAnimation(flash, "flashAnimation"); base.LayoutSublayers(); }
/** Returns a UIBezierPath object for an extra long checkmark which is in contact with the box. * @returns The path of the checkmark. */ public UIBezierPath PathForLongCheckMark() { UIBezierPath checkMarkPath = UIBezierPath.Create(); checkMarkPath.MoveTo(new CGPoint(Size / 3.1578, Size / 2)); checkMarkPath.AddLineTo(new CGPoint(Size / 2.0618, Size / 1.57894)); if (BoxType == BemBoxType.BemBoxTypeSquare) { // If we use a square box, the check mark should be a little bit bigger checkMarkPath.AddLineTo(new CGPoint(new CGPoint(Size / 1.2053, Size / 4.5272))); checkMarkPath.ApplyTransform(CGAffineTransform.MakeScale(new nfloat(1.5), new nfloat(1.5))); checkMarkPath.ApplyTransform(CGAffineTransform.MakeTranslation(-Size / 4, -Size / 4)); } else { checkMarkPath.AddLineTo(new CGPoint(new CGPoint(Size / 1.1553, Size / 5.9272))); } return(checkMarkPath); }
private UIImage CreatePreviewTabBackgroundImage() { // The preview tab should be flat on the bottom, and have rounded corners on top. var size = new SizeF(PreviewTabMinimumWidth, PreviewTabHeight); UIGraphics.BeginImageContextWithOptions(size, false, UIScreen.MainScreen.Scale); var rect = new RectangleF(0f, 0f, PreviewTabMinimumWidth, PreviewTabHeight); var radii = new SizeF(PreviewTabCornerRadius, PreviewTabCornerRadius); var roundedTopCornersRect = UIBezierPath.FromRoundedRect(rect, UIRectCorner.TopLeft | UIRectCorner.TopRight, radii); StyleUtilities.ForegroundColor.SetColor(); roundedTopCornersRect.Fill(); UIImage previewTabBackgroundImage = UIGraphics.GetImageFromCurrentImageContext(); var caps = new UIEdgeInsets(0f, PreviewTabCornerRadius, 0f, PreviewTabCornerRadius); previewTabBackgroundImage = previewTabBackgroundImage.CreateResizableImage(caps); UIGraphics.EndImageContext(); return(previewTabBackgroundImage); }
private void AddCornerRadius(PancakeView pancake) { if (pancake.CornerRadius.HorizontalThickness > 0 || pancake.CornerRadius.VerticalThickness > 0) { var cornerPath = new UIBezierPath(); // Create arcs for the given corner radius. cornerPath.AddArc(new CGPoint((float)Bounds.X + Bounds.Width - pancake.CornerRadius.Top, (float)Bounds.Y + pancake.CornerRadius.Top), (float)pancake.CornerRadius.Top, (float)(Math.PI * 1.5), (float)Math.PI * 2, true); cornerPath.AddArc(new CGPoint((float)Bounds.X + Bounds.Width - pancake.CornerRadius.Right, (float)Bounds.Y + Bounds.Height - pancake.CornerRadius.Right), (float)pancake.CornerRadius.Right, 0, (float)(Math.PI * .5), true); cornerPath.AddArc(new CGPoint((float)Bounds.X + pancake.CornerRadius.Bottom, (float)Bounds.Y + Bounds.Height - pancake.CornerRadius.Bottom), (float)pancake.CornerRadius.Bottom, (float)(Math.PI * .5), (float)Math.PI, true); cornerPath.AddArc(new CGPoint((float)Bounds.X + pancake.CornerRadius.Left, (float)Bounds.Y + pancake.CornerRadius.Left), (float)pancake.CornerRadius.Left, (float)Math.PI, (float)(Math.PI * 1.5), true); var maskLayer = new CAShapeLayer { Frame = Bounds, Path = cornerPath.CGPath }; Layer.Mask = maskLayer; Layer.MasksToBounds = true; } }
private void Initialize() { this.maskLayer.FillRule = CAShapeLayer.FillRuleEvenOdd; this.maskLayer.FillColor = UIColor.Black.CGColor; this.maskLayer.Opacity = 0.6f; this.Layer.AddSublayer(this.maskLayer); this.regionOfInterestOutline.Path = UIBezierPath.FromRect(this.RegionOfInterest).CGPath; this.regionOfInterestOutline.FillColor = UIColor.Clear.CGColor; this.regionOfInterestOutline.StrokeColor = UIColor.Yellow.CGColor; this.Layer.AddSublayer(this.regionOfInterestOutline); var controlRect = new CGRect(0, 0, RegionOfInterestControlDiameter, RegionOfInterestControlDiameter); this.topLeftControl.Path = UIBezierPath.FromOval(controlRect).CGPath; this.topLeftControl.FillColor = UIColor.White.CGColor; this.Layer.AddSublayer(this.topLeftControl); this.topRightControl.Path = UIBezierPath.FromOval(controlRect).CGPath; this.topRightControl.FillColor = UIColor.White.CGColor; this.Layer.AddSublayer(this.topRightControl); this.bottomLeftControl.Path = UIBezierPath.FromOval(controlRect).CGPath; this.bottomLeftControl.FillColor = UIColor.White.CGColor; this.Layer.AddSublayer(this.bottomLeftControl); this.bottomRightControl.Path = UIBezierPath.FromOval(controlRect).CGPath; this.bottomRightControl.FillColor = UIColor.White.CGColor; this.Layer.AddSublayer(this.bottomRightControl); // Add the region of interest gesture recognizer to the region of interest // view so that the region of interest can be resized and moved. If you // would like to have a fixed region of interest that cannot be resized // or moved, do not add the following gesture recognizer. You will simply // need to set the region of interest once. this.ResizeRegionOfInterestGestureRecognizer.Delegate = this; this.AddGestureRecognizer(this.ResizeRegionOfInterestGestureRecognizer); }
public override void Draw(CGRect rect) { base.Draw(rect); if (element.Equals("X.ScaledFrame")) { if (!fControl.has_Shadow) { Layer.ShadowRadius = 0.01f; Layer.ShadowColor = UIColor.White.CGColor; Layer.ShadowOffset = new CGSize(2, 2); Layer.ShadowOpacity = 0.01f; Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath; } else { //Layer.CornerRadius = 15.0f; // Update shadow to match better material design standards of elevation Layer.ShadowRadius = 2.0f; Layer.ShadowColor = UIColor.Gray.CGColor; Layer.ShadowOffset = new CGSize(2, 2); Layer.ShadowOpacity = 0.70f; Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath; Layer.MasksToBounds = false; } } else { //Layer.CornerRadius = 15.0f; // Update shadow to match better material design standards of elevation Layer.ShadowRadius = 2.0f; Layer.ShadowColor = UIColor.Gray.CGColor; Layer.ShadowOffset = new CGSize(2, 2); Layer.ShadowOpacity = 0.70f; Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath; Layer.MasksToBounds = false; } }
void Draw(RectangleF rect) { //// Color Declarations //// Frames var bgFrame = new RectangleF(0, 0, rect.Width, rect.Height); //// Subframes var circleGroup = new RectangleF(bgFrame.GetMinX() + (float)Math.Floor(bgFrame.Width * 0.13437f + 0.5f), bgFrame.GetMinY() + (float)Math.Floor(bgFrame.Height * 0.12500f + 0.5f), (float)Math.Floor(bgFrame.Width * 0.85938f + 0.5f) - (float)Math.Floor(bgFrame.Width * 0.13437f + 0.5f), (float)Math.Floor(bgFrame.Height * 0.84688f + 0.5f) - (float)Math.Floor(bgFrame.Height * 0.12500f + 0.5f)); //// Abstracted Attributes var progressOvalEndAngle = Progress; //// circleGroup { //// outerOval Drawing var outerOvalPath = UIBezierPath.FromOval(new RectangleF(circleGroup.GetMinX() + (float)Math.Floor(circleGroup.Width * 0.00216f) + 0.5f, circleGroup.GetMinY() + (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f), (float)Math.Floor(circleGroup.Width * 0.99784f) - (float)Math.Floor(circleGroup.Width * 0.00216f), (float)Math.Floor(circleGroup.Height * 1.00000f + 0.5f) - (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f))); OuterColor.SetFill(); outerOvalPath.Fill(); //// progressOval Drawing var progressOvalRect = new RectangleF(circleGroup.GetMinX() + (float)Math.Floor(circleGroup.Width * 0.00216f) + 0.5f, circleGroup.GetMinY() + (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f), (float)Math.Floor(circleGroup.Width * 0.99784f) - (float)Math.Floor(circleGroup.Width * 0.00216f), (float)Math.Floor(circleGroup.Height * 1.00000f + 0.5f) - (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f)); var progressOvalPath = new UIBezierPath(); progressOvalPath.AddArc(new PointF(progressOvalRect.GetMidX(), progressOvalRect.GetMidY()), progressOvalRect.Width / 2, (float)(270 * Math.PI / 180), (float)(progressOvalEndAngle * Math.PI / 180), true); progressOvalPath.AddLineTo(new PointF(progressOvalRect.GetMidX(), progressOvalRect.GetMidY())); progressOvalPath.ClosePath(); InnerColor.SetFill(); progressOvalPath.Fill(); //// innerOval Drawing var innerOvalPath = UIBezierPath.FromOval(new RectangleF(circleGroup.GetMinX() + (float)Math.Floor(circleGroup.Width * 0.09052f + 0.5f), circleGroup.GetMinY() + (float)Math.Floor(circleGroup.Height * 0.09091f + 0.5f), (float)Math.Floor(circleGroup.Width * 0.90948f + 0.5f) - (float)Math.Floor(circleGroup.Width * 0.09052f + 0.5f), (float)Math.Floor(circleGroup.Height * 0.91342f + 0.5f) - (float)Math.Floor(circleGroup.Height * 0.09091f + 0.5f))); InsideColor.SetFill(); innerOvalPath.Fill(); } }
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(); } }
private UIBezierPath PathPlus(nfloat rotation) { var radius = Frame.Width * _internalRadiusRatio * 0.5f; var circleCenter = Center.Minus(Frame.Location); var cgPointArray = new[] { circleCenter.CirclePoint(radius, CoreGraphicsExtensions.Pi2 * 0.0f + rotation), circleCenter.CirclePoint(radius, CoreGraphicsExtensions.Pi2 * 1f + rotation), circleCenter.CirclePoint(radius, CoreGraphicsExtensions.Pi2 * 2f + rotation), circleCenter.CirclePoint(radius, CoreGraphicsExtensions.Pi2 * 3f + rotation) }; var uiBezierPath = new UIBezierPath(); // ISSUE: reference to a compiler-generated method uiBezierPath.MoveTo(cgPointArray[0]); // ISSUE: reference to a compiler-generated method uiBezierPath.AddLineTo(cgPointArray[2]); // ISSUE: reference to a compiler-generated method uiBezierPath.MoveTo(cgPointArray[1]); // ISSUE: reference to a compiler-generated method uiBezierPath.AddLineTo(cgPointArray[3]); return(uiBezierPath); }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (Control != null) { var button = (RoundedButton)e.NewElement; button.SizeChanged += (s, args) => { var radius = Math.Min(button.Width, button.Height) / 2.0; button.BorderRadius = (int)(radius); }; // TODO: Not yet working. var shadowPath = UIBezierPath.FromRoundedRect(Bounds, (int)Element.BorderRadius); Layer.ShadowPath = shadowPath.CGPath; Layer.ShadowColor = UIColor.Black.CGColor; Layer.ShadowOffset = new CGSize(width: 0.0, height: 0.5); Layer.ShadowOpacity = 0.2f; Layer.MasksToBounds = false; } }
public override void CreatePath(CornerClip shape, CGRect bounds) { using (var bezierPath = new UIBezierPath()) { var topLeftClipSize = (float)shape.ClipSize.TopLeft; var topRightClipSize = (float)shape.ClipSize.TopRight; var bottomLeftClipSize = (int)shape.ClipSize.BottomLeft; var bottomRightClipSize = (int)shape.ClipSize.BottomRight; bezierPath.MoveTo(new CGPoint(bounds.X + topLeftClipSize, bounds.Y)); bezierPath.AddLineTo(new CGPoint(bounds.Width - topRightClipSize, bounds.Y)); bezierPath.AddLineTo(new CGPoint(bounds.Width, bounds.X + topRightClipSize)); bezierPath.AddLineTo(new CGPoint(bounds.Width, bounds.Height - bottomRightClipSize)); bezierPath.AddLineTo(new CGPoint(bounds.Width - bottomRightClipSize, bounds.Height)); bezierPath.AddLineTo(new CGPoint(bounds.X + bottomLeftClipSize, bounds.Height)); bezierPath.AddLineTo(new CGPoint(bounds.X, bounds.Height - bottomLeftClipSize)); bezierPath.AddLineTo(new CGPoint(bounds.X, bounds.Y + topLeftClipSize)); bezierPath.AddLineTo(new CGPoint(bounds.X + topLeftClipSize, bounds.Y)); bezierPath.ClosePath(); Path = bezierPath.CGPath; } }
public override void Draw(CGRect rect) { base.Draw(rect); using (var context = UIGraphics.GetCurrentContext()) { CGRect contentRect = rect.Inset(Element.CornerRadius, Element.CornerRadius); UIBezierPath roundedPath = UIBezierPath.FromRoundedRect(contentRect, Element.CornerRadius); context.SetFillColor(UIColor.White.CGColor); context.SetShadow(new CGSize(0, 0), Element.CornerRadius, UIColor.Black.ColorWithAlpha(0.5f).CGColor); roundedPath.Fill(); roundedPath.AddClip(); context.SetStrokeColor(UIColor.Black.ColorWithAlpha(0.6f).CGColor); context.SetBlendMode(CGBlendMode.Overlay); context.MoveTo(contentRect.GetMinX(), contentRect.GetMinY() + 0.5f); context.AddLineToPoint(contentRect.GetMinX(), contentRect.GetMinY() + 0.5f); context.StrokePath(); } }
public static UIBezierPath CreateBagelPath(PointF center, float startRadius, float endRadius, float startAngle, float endAngle) { var bagelPath = new UIBezierPath(); var rotationShift = -HalfMathPi; var centerRadius = (startRadius + endRadius) / 2f; var roundingArcWidth = (endRadius - startRadius) / 2f; bagelPath.AddArc(RotatePoint(center, centerRadius, startAngle + rotationShift), roundingArcWidth, -HalfMathPi, -3f * HalfMathPi, true); bagelPath.AddArc(center, startRadius, startAngle + rotationShift, endAngle + rotationShift, true); bagelPath.AddArc(RotatePoint(center, centerRadius, endAngle + rotationShift), roundingArcWidth, HalfMathPi + endAngle, 3f * HalfMathPi + endAngle, false); bagelPath.AddArc(center, endRadius, endAngle + rotationShift, startAngle + rotationShift, false); bagelPath.ClosePath(); return(bagelPath); }
public override void Draw(CGRect rect) { var path = new UIBezierPath(); path.LineWidth = LineWidth; path.LineCapStyle = CGLineCap.Round; var iconFrame = new CGRect( x: (rect.Width - IconSize) / 2.0, y: (rect.Height - IconSize) / 2.0, width: IconSize, height: IconSize ); path.MoveTo(iconFrame.Location); path.AddLineTo(new CGPoint(iconFrame.GetMaxX(), iconFrame.GetMaxY())); path.MoveTo(new CGPoint(iconFrame.GetMaxX(), iconFrame.GetMinY())); path.AddLineTo(new CGPoint(iconFrame.GetMinX(), iconFrame.GetMaxY())); LineColor.SetStroke(); path.Stroke(); }
private void ConfigureHalfCircularProgress() { var frame = new CGRect(0, 301, View.Frame.Width, View.Frame.Height / 2); halfCircularProgress = new iOS.CircularProgress(frame, true); var center = new CGPoint(160, 200); var bezier = new UIBezierPath(); bezier.AddArc(center, halfCircularProgress.Frame.Width / 3, (nfloat)Math.PI, (nfloat)0.0, true); halfCircularProgress.Path = bezier; halfCircularProgress.Colors = new [] { ColorExtension.RgbaColor(0xA6E39DAA).CGColor, ColorExtension.RgbaColor(0xAEC1E3AA).CGColor, ColorExtension.RgbaColor(0xAEC1E3AA).CGColor, ColorExtension.RgbaColor(0xF3C0ABAA).CGColor }; halfCircularProgress.LineWidth = 8.0; halfCircularProgress.ProgressGuideColor = new UIColor((nfloat)0.1, (nfloat)0.1, (nfloat)0.1, (nfloat)0.7); textLabel = new UILabel(new CGRect(halfCircularProgress.Frame.X + 120.0, 170.0, 80, 32)); textLabel.TextAlignment = UITextAlignment.Center; textLabel.TextColor = UIColor.Green; textLabel.Font = UIFont.FromName("HelveticaNeue-UltraLight", 20f); textLabel.Alpha = (System.nfloat) 0.5; textLabel.Text = ""; halfCircularProgress.AddSubview(textLabel); halfCircularProgress.ProgressUpdated += (sender, e) => { BeginInvokeOnMainThread(() => textLabel.Text = string.Format("{0}%", (int)(e.Progress * 100))); }; View.AddSubview(halfCircularProgress); }
public override void Draw(CGRect rect) { base.Draw(rect); var materialFrame = (CustomFrame)Element; if (materialFrame.ShadowOpacity == 0.11f) { Layer.BorderColor = UIColor.LightGray.CGColor; } else if (materialFrame.ShadowOpacity == 0.12f) { Layer.BorderColor = UIColor.White.CGColor; } else { Layer.BorderColor = UIColor.White.CGColor; } if (materialFrame.ShadowOpacity == 0.11f) { Layer.ShadowRadius = materialFrame.Elevation; } else { Layer.ShadowRadius = (materialFrame.Elevation == 1f) ? 6 : materialFrame.Elevation; } if (materialFrame.ShadowOpacity == 0.12f) { Layer.ShadowRadius = 0; } Layer.ShadowColor = UIColor.Gray.CGColor; Layer.ShadowOffset = new CGSize(2, 2); Layer.ShadowOpacity = materialFrame.ShadowOpacity; Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath; Layer.MasksToBounds = false; }
public override void Draw(RectangleF rect) { rect = RectangleF.Inflate(rect, 4, 4); rect = new RectangleF((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 PointF(rect.GetMidX() - 5, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc(new PointF(rect.GetMidX() + 10, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo(new PointF(rect.GetMidX(), rect.Y + 30)); mouth.AddLineTo(new PointF(rect.GetMidX() + 13, rect.Y + 30)); } else { rightEye = UIBezierPath.FromArc(new PointF(rect.GetMidX() - 10, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc(new PointF(rect.GetMidX() - 10, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo(new PointF(rect.GetMidX(), rect.Y + 30)); mouth.MoveTo(new PointF(rect.GetMidX(), rect.Y + 30)); } rightEye.LineWidth = 2; rightEye.Stroke(); leftEye.LineWidth = 2; leftEye.Stroke(); mouth.LineWidth = 2; mouth.Stroke(); }
public void SetupAnimationInLayer(CALayer layer, CGSize size, UIColor tintColor) { nfloat duration = 1.0f; var scaleAnimation = CABasicAnimation.FromKeyPath("transform.scale"); scaleAnimation.Duration = duration; scaleAnimation.From = NSNumber.FromFloat(0.0f); scaleAnimation.To = NSNumber.FromFloat(1.0f); var opacityAnimation = CABasicAnimation.FromKeyPath("opacity"); opacityAnimation.Duration = duration; opacityAnimation.From = NSNumber.FromFloat(1.0f); opacityAnimation.To = NSNumber.FromFloat(0.0f); var animation = new CAAnimationGroup { Animations = new CAAnimation[] { scaleAnimation, opacityAnimation }, Duration = duration, TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut), RepeatCount = float.PositiveInfinity, RemovedOnCompletion = false }; var circle = new CAShapeLayer(); var circlePath = UIBezierPath.FromRoundedRect(new CGRect(0, 0, size.Width, size.Height), UIRectCorner.AllCorners, new CGSize(size.Width / 2, size.Width / 2)); circle.FillColor = tintColor.CGColor; circle.Path = circlePath.CGPath; circle.AddAnimation(animation, "animation"); circle.Frame = new CGRect((layer.Bounds.Size.Width - size.Width) / 2, (layer.Bounds.Size.Height - size.Height) / 2, size.Width, size.Height); layer.AddSublayer(circle); }
/// <summary> /// Begin touches. /// </summary> /// <param name="touches">Touches to use.</param> /// <param name="evt">Event to use.</param> public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt) { if (currentPath != null) { // Obtain the smoothed path and the points array for that path. currentPath = SmoothedPathWithGranularity(0, out currentPoints); // Add the smoothed path and points array to their Lists. paths.Add(currentPath); points.Add(currentPoints.ToArray()); LoadNewImage(); SetNeedsDisplay(); NotifyIsBlankChanged(); currentPath = null; currentPoints.Clear(); } // Create a new path and set the options. currentPath = UIBezierPath.Create(); currentPath.LineWidth = StrokeWidth; currentPath.LineJoinStyle = CGLineJoin.Round; currentPoints.Clear(); UITouch touch = touches.AnyObject as UITouch; // Obtain the location of the touch, move the path to that position and add it to the // current_points array. CGPoint touchLocation = touch.LocationInView(this); currentPath.MoveTo(touchLocation); currentPoints.Add(touchLocation); ResetBounds(touchLocation); }
public static void DrawUIControlWell(CGRect frame, bool inFocus, string title) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var wellColor = UIColor.FromRGBA(0.029f, 0.029f, 0.029f, 0.189f); //// Variable Declarations var textColor = inFocus ? CustomControlsStyleKit.InFocusTextColor : CustomControlsStyleKit.UnFocusedTextColor; //// Background Drawing var backgroundPath = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX() + 1.0f, frame.GetMinY() + 1.0f, NMath.Floor((frame.Width - 1.0f) * 0.99749f + 0.5f), NMath.Floor((frame.Height - 1.0f) * 0.98990f + 0.5f)), 4.0f); wellColor.SetFill(); backgroundPath.Fill(); //// Text Drawing CGRect textRect = new CGRect(frame.GetMinX() + NMath.Floor(frame.Width * 0.03250f + 0.5f), frame.GetMinY() + NMath.Floor(frame.Height * 0.19000f + 0.5f), NMath.Floor(frame.Width * 0.97250f + 0.5f) - NMath.Floor(frame.Width * 0.03250f + 0.5f), NMath.Floor(frame.Height * 0.80000f + 0.5f) - NMath.Floor(frame.Height * 0.19000f + 0.5f)); textColor.SetFill(); var textStyle = new NSMutableParagraphStyle(); textStyle.Alignment = UITextAlignment.Center; var textFontAttributes = new UIStringAttributes() { Font = UIFont.BoldSystemFontOfSize(27.0f), ForegroundColor = textColor, ParagraphStyle = textStyle }; var textTextHeight = new NSString(title).GetBoundingRect(new CGSize(textRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, textFontAttributes, null).Height; context.SaveState(); context.ClipToRect(textRect); new NSString(title).DrawString(new CGRect(textRect.GetMinX(), textRect.GetMinY() + (textRect.Height - textTextHeight) / 2.0f, textRect.Width, textTextHeight), UIFont.BoldSystemFontOfSize(27.0f), UILineBreakMode.WordWrap, UITextAlignment.Center); context.RestoreState(); }
UIBezierPath GetHeartOverlayPath(CGRect originalRect, float scale) { var scaledWidth = (originalRect.Size.Width * scale); var scaledXValue = ((originalRect.Size.Width) - scaledWidth) / 2; var scaledHeight = (originalRect.Size.Height * scale); var scaledYValue = ((originalRect.Size.Height) - scaledHeight) / 2; var scaledRect = new CGRect(x: scaledXValue, y: scaledYValue, width: scaledWidth, height: scaledHeight); UIBezierPath path = new UIBezierPath(); path.MoveTo(new CGPoint(x: originalRect.Size.Width / 2, y: scaledRect.Y + scaledRect.Size.Height)); path.AddCurveToPoint(new CGPoint(x: scaledRect.X, y: scaledRect.Y + (scaledRect.Size.Height / 4)), controlPoint1: new CGPoint(x: scaledRect.X + (scaledRect.Size.Width / 2), y: scaledRect.Y + (scaledRect.Size.Height * 3 / 4)), controlPoint2: new CGPoint(x: scaledRect.X, y: scaledRect.Y + (scaledRect.Size.Height / 2))); path.AddArc(new CGPoint(scaledRect.X + (scaledRect.Size.Width / 4), scaledRect.Y + (scaledRect.Size.Height / 4)), (scaledRect.Size.Width / 4), (nfloat)Math.PI, 0, true); path.AddArc(new CGPoint(scaledRect.X + (scaledRect.Size.Width * 3 / 4), scaledRect.Y + (scaledRect.Size.Height / 4)), (scaledRect.Size.Width / 4), (nfloat)Math.PI, 0, true); path.AddCurveToPoint(new CGPoint(x: originalRect.Size.Width / 2, y: scaledRect.Y + scaledRect.Size.Height), controlPoint1: new CGPoint(x: scaledRect.X + scaledRect.Size.Width, y: scaledRect.Y + (scaledRect.Size.Height / 2)), controlPoint2: new CGPoint(x: scaledRect.X + (scaledRect.Size.Width / 2), y: scaledRect.Y + (scaledRect.Size.Height * 3 / 4))); path.ClosePath(); return(path); }
private void DrawBackground() { CorneredContentView corneredContentView = this.Element as CorneredContentView; string layerName = "backgroundLayer"; // Remove previous background layer if any CALayer prevBackgroundLayer = this._actualView.Layer.Sublayers?.FirstOrDefault(x => x.Name == layerName); prevBackgroundLayer?.RemoveFromSuperLayer(); UIBezierPath cornerPath = null; cornerPath = CreateRoundedRectPath(this.Bounds, corneredContentView.CornerRadius); // The layer used to mask other layers we draw on the background. CAShapeLayer maskLayer = new CAShapeLayer { Frame = Bounds, Path = cornerPath.CGPath }; this._actualView.Layer.Mask = maskLayer; this._actualView.Layer.MasksToBounds = true; // Create a shape layer that draws our background. CAShapeLayer shapeLayer = new CAShapeLayer { Frame = Bounds, Path = cornerPath.CGPath, MasksToBounds = true, FillColor = this._colorToRender.CGColor, Name = layerName }; this.AddLayer(shapeLayer, 0, this._actualView); }
private void SetArrowFrame() { SelectionIndicatorArrowLayer.Frame = FrameForSelectionIndicator(); SelectionIndicatorArrowLayer.Mask = null; CGPoint p1, p2, p3; if (SelectionIndicatorLocation == HMSegmentedControlIndicatorLocation.Down) { p1 = new CGPoint(SelectionIndicatorArrowLayer.Bounds.Size.Width / 2, 0); p2 = new CGPoint(0, SelectionIndicatorArrowLayer.Bounds.Size.Height); p3 = new CGPoint(SelectionIndicatorArrowLayer.Bounds.Size.Width, SelectionIndicatorArrowLayer.Bounds.Size.Height); } else if (SelectionIndicatorLocation == HMSegmentedControlIndicatorLocation.Up) { p1 = new CGPoint(SelectionIndicatorArrowLayer.Bounds.Size.Width / 2, SelectionIndicatorArrowLayer.Bounds.Size.Height); p2 = new CGPoint(SelectionIndicatorArrowLayer.Bounds.Size.Width, 0); p3 = new CGPoint(0, 0); } else { p1 = p2 = p3 = CGPoint.Empty; } var arrowPath = new UIBezierPath(); arrowPath.MoveTo(p1); arrowPath.AddLineTo(p2); arrowPath.AddLineTo(p3); arrowPath.ClosePath(); SelectionIndicatorArrowLayer.Mask = new CAShapeLayer { Frame = SelectionIndicatorArrowLayer.Bounds, Path = arrowPath.CGPath }; }
private CGPath createCurvedPath(CGPoint anchor, CGPoint[] points) { var path = new UIBezierPath(); if (points.Length > 1) { var previousPoint = points[0]; var startOfCurve = previousPoint; path.MoveTo(anchor); for (int i = 1; i < points.Length; i++) { var endOfCurve = points[i]; var nextPoint = i < points.Length - 1 ? points[i + 1] : points[i]; var(controlPointB, controlPointC) = calculateControlPoints(previousPoint, startOfCurve, endOfCurve, nextPoint); path.AddCurveToPoint(endOfCurve, controlPointB, controlPointC); previousPoint = startOfCurve; startOfCurve = endOfCurve; } } return(path.CGPath); }
/// <summary> /// Draws the other. /// </summary> /// <exception cref="System.NotImplementedException"></exception> private void DrawOther() { int height; int width; switch (Element.Aspect) { case Aspect.AspectFill: height = (int)Control.Image.Size.Height; width = (int)Control.Image.Size.Width; height = MakeSquare(height, ref width); break; case Aspect.AspectFit: height = (int)Control.Image.Size.Height; width = (int)Control.Image.Size.Width; height = MakeSquare(height, ref width); break; default: throw new NotImplementedException(); } UIImage image = Control.Image; var clipRect = new CGRect(0, 0, width, height); var scaled = image.Scale(new CGSize(width, height)); UIGraphics.BeginImageContextWithOptions(new CGSize(width, height), false, 0f); UIBezierPath.FromRoundedRect(clipRect, Math.Max(width, height) / 2).AddClip(); scaled.Draw(new CGRect(0, 0, scaled.Size.Width, scaled.Size.Height)); UIImage final = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); Control.Image = final; }
private void HandleDrag(UIPanGestureRecognizer recognizer) { // If it's just began, cache the location of the image if (recognizer.State == UIGestureRecognizerState.Began) { originalImageFrame = (System.Drawing.RectangleF)cadreIV.Frame; } // Move the image if the gesture is valid if (recognizer.State != (UIGestureRecognizerState.Cancelled | UIGestureRecognizerState.Failed | UIGestureRecognizerState.Possible)) { // Move the image by adding the offset to the object's frame PointF offset = (System.Drawing.PointF)recognizer.TranslationInView(cadreIV); RectangleF newFrame = originalImageFrame; var offsetX = offset.X; newFrame.Offset(offset.X, offset.Y); if (newFrame.X > 0 && newFrame.Y > (int)(headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2) && newFrame.X + cadreIV.Frame.Width < View.Frame.Width && newFrame.Y + cadreIV.Frame.Height < (imageView.Frame.Height + imageView.Frame.Y)) { cadreIV.Frame = newFrame; var circleLayer = new CAShapeLayer(); var circlePath = UIBezierPath.FromRect(cadreIV.Frame); circlePath.UsesEvenOddFillRule = true; circleLayer.Path = circlePath.CGPath; var maskPath = UIBezierPath.FromRect(new CGRect(0, (int)headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2, View.Frame.Width, (int)(View.Frame.Height - (headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2 + View.Frame.Width / 8)))); maskPath.AppendPath(circlePath); maskPath.UsesEvenOddFillRule = true; fillLayer.Path = maskPath.CGPath; fillLayer.FillRule = CAShapeLayer.FillRuleEvenOdd; View.Layer.AddSublayer(fillLayer); } } }
UIBezierPath CreateCirclePath(PointF center, float radius, int sampleCount) { var smoothedPath = new UIBezierPath(); PointF 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; }
public static void DrawBlueShirt(RectangleF frame, float shirtAngle, float shirtScaleFactor) { //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations var blueShirtBase = UIColor.FromRGBA(0.173f, 0.435f, 0.702f, 1.000f); var blueShirtBaseRGBA = new float[4]; blueShirtBase.GetRGBA(out blueShirtBaseRGBA[0], out blueShirtBaseRGBA[1], out blueShirtBaseRGBA[2], out blueShirtBaseRGBA[3]); var blueShirtStroke = UIColor.FromRGBA((blueShirtBaseRGBA[0] * 0.7f + 0.3f), (blueShirtBaseRGBA[1] * 0.7f + 0.3f), (blueShirtBaseRGBA[2] * 0.7f + 0.3f), (blueShirtBaseRGBA[3] * 0.7f + 0.3f)); //// Shadow Declarations var blueShirtShadow = blueShirtBase.CGColor; var blueShirtShadowOffset = new SizeF(2.1f, 2.1f); var blueShirtShadowBlurRadius = 3.0f; //// shirtBezier Drawing context.SaveState(); context.TranslateCTM(frame.GetMinX() + 61.94f, frame.GetMinY() + 59.36f); context.RotateCTM(-shirtAngle * (float)Math.PI / 180.0f); context.ScaleCTM(shirtScaleFactor, shirtScaleFactor); UIBezierPath shirtBezierPath = new UIBezierPath(); shirtBezierPath.MoveTo(new PointF(-27.46f, -43.29f)); shirtBezierPath.AddCurveToPoint(new PointF(-11.8f, -30.19f), new PointF(-27.46f, -43.29f), new PointF(-15.62f, -33.38f)); shirtBezierPath.AddLineTo(new PointF(-10.9f, -30.19f)); shirtBezierPath.AddCurveToPoint(new PointF(-10.59f, -29.78f), new PointF(-10.8f, -30.05f), new PointF(-10.7f, -29.92f)); shirtBezierPath.AddCurveToPoint(new PointF(10.42f, -29.78f), new PointF(-4.79f, -22.48f), new PointF(4.62f, -22.48f)); shirtBezierPath.AddCurveToPoint(new PointF(10.74f, -30.19f), new PointF(10.53f, -29.92f), new PointF(10.63f, -30.05f)); shirtBezierPath.AddCurveToPoint(new PointF(11.8f, -30.19f), new PointF(10.74f, -30.19f), new PointF(11.13f, -30.19f)); shirtBezierPath.AddCurveToPoint(new PointF(27.46f, -43.29f), new PointF(15.62f, -33.38f), new PointF(27.46f, -43.29f)); shirtBezierPath.AddLineTo(new PointF(48.92f, -10.09f)); shirtBezierPath.AddLineTo(new PointF(32.09f, 3.99f)); shirtBezierPath.AddCurveToPoint(new PointF(27.12f, -3.69f), new PointF(32.09f, 3.99f), new PointF(30.0f, 0.76f)); shirtBezierPath.AddCurveToPoint(new PointF(27.12f, 43.29f), new PointF(27.12f, 17.36f), new PointF(27.12f, 43.29f)); shirtBezierPath.AddLineTo(new PointF(-27.46f, 43.29f)); shirtBezierPath.AddCurveToPoint(new PointF(-27.46f, -3.18f), new PointF(-27.46f, 43.29f), new PointF(-27.46f, 17.78f)); shirtBezierPath.AddCurveToPoint(new PointF(-32.09f, 3.99f), new PointF(-30.16f, 1.0f), new PointF(-32.09f, 3.99f)); shirtBezierPath.AddLineTo(new PointF(-48.92f, -10.09f)); shirtBezierPath.AddLineTo(new PointF(-27.46f, -43.29f)); shirtBezierPath.ClosePath(); context.SaveState(); context.SetShadowWithColor(blueShirtShadowOffset, blueShirtShadowBlurRadius, blueShirtShadow); blueShirtBase.SetFill(); shirtBezierPath.Fill(); context.RestoreState(); blueShirtStroke.SetStroke(); shirtBezierPath.LineWidth = 8.0f; shirtBezierPath.Stroke(); context.RestoreState(); //// Text Drawing context.SaveState(); context.TranslateCTM(frame.GetMinX() + 62.0f, frame.GetMinY() + 61.95f); context.RotateCTM(-shirtAngle * (float)Math.PI / 180.0f); context.ScaleCTM(shirtScaleFactor, shirtScaleFactor); RectangleF textRect = new RectangleF(-24.7f, -25.61f, 50.0f, 50.0f); var textPath = UIBezierPath.FromRect(textRect); UIColor.Red.SetStroke(); textPath.LineWidth = 1.0f; textPath.Stroke(); { var textContent = "?"; UIColor.White.SetFill(); var textFont = UIFont.FromName("HelveticaNeue-Bold", 36.0f); textRect.Offset(0.0f, (textRect.Height - new NSString(textContent).StringSize(textFont, textRect.Size).Height) / 2.0f); new NSString(textContent).DrawString(textRect, textFont, UILineBreakMode.WordWrap, UITextAlignment.Center); } context.RestoreState(); }
public static void paintCodeDrawQRNONRetina() { //// Color Declarations UIColor color2 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRect(new RectangleF(3.5f, 2.5f, 10, 8)); UIColor.White.SetFill(); rectanglePath.Fill(); UIColor.Black.SetStroke(); rectanglePath.LineWidth = 1; rectanglePath.Stroke(); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRect(new RectangleF(6.5f, 4.5f, 4, 4)); color2.SetFill(); rectangle2Path.Fill(); UIColor.Black.SetStroke(); rectangle2Path.LineWidth = 1; rectangle2Path.Stroke(); //// Rectangle 3 Drawing var rectangle3Path = UIBezierPath.FromRect(new RectangleF(3.5f, 18.5f, 10, 8)); UIColor.White.SetFill(); rectangle3Path.Fill(); UIColor.Black.SetStroke(); rectangle3Path.LineWidth = 1; rectangle3Path.Stroke(); //// Rectangle 4 Drawing var rectangle4Path = UIBezierPath.FromRect(new RectangleF(6.5f, 20.5f, 4, 4)); color2.SetFill(); rectangle4Path.Fill(); UIColor.Black.SetStroke(); rectangle4Path.LineWidth = 1; rectangle4Path.Stroke(); //// Rectangle 5 Drawing var rectangle5Path = UIBezierPath.FromRect(new RectangleF(30.5f, 2.5f, 10, 8)); UIColor.White.SetFill(); rectangle5Path.Fill(); UIColor.Black.SetStroke(); rectangle5Path.LineWidth = 1; rectangle5Path.Stroke(); //// Rectangle 6 Drawing var rectangle6Path = UIBezierPath.FromRect(new RectangleF(33.5f, 4.5f, 4, 4)); color2.SetFill(); rectangle6Path.Fill(); UIColor.Black.SetStroke(); rectangle6Path.LineWidth = 1; rectangle6Path.Stroke(); //// Star Drawing UIBezierPath starPath = new UIBezierPath(); starPath.MoveTo(new PointF(26.5f, 8.5f)); starPath.AddLineTo(new PointF(29.67f, 13.39f)); starPath.AddLineTo(new PointF(35.06f, 15.06f)); starPath.AddLineTo(new PointF(31.64f, 19.76f)); starPath.AddLineTo(new PointF(31.79f, 25.69f)); starPath.AddLineTo(new PointF(26.5f, 23.7f)); starPath.AddLineTo(new PointF(21.21f, 25.69f)); starPath.AddLineTo(new PointF(21.36f, 19.76f)); starPath.AddLineTo(new PointF(17.94f, 15.06f)); starPath.AddLineTo(new PointF(23.33f, 13.39f)); starPath.ClosePath(); UIColor.White.SetFill(); starPath.Fill(); UIColor.Black.SetStroke(); starPath.LineWidth = 2.5f; starPath.Stroke(); //// Star 2 Drawing UIBezierPath star2Path = new UIBezierPath(); star2Path.MoveTo(new PointF(20.5f, 2.5f)); star2Path.AddLineTo(new PointF(21.56f, 4.56f)); star2Path.AddLineTo(new PointF(23.35f, 5.26f)); star2Path.AddLineTo(new PointF(22.21f, 7.24f)); star2Path.AddLineTo(new PointF(22.26f, 9.74f)); star2Path.AddLineTo(new PointF(20.5f, 8.9f)); star2Path.AddLineTo(new PointF(18.74f, 9.74f)); star2Path.AddLineTo(new PointF(18.79f, 7.24f)); star2Path.AddLineTo(new PointF(17.65f, 5.26f)); star2Path.AddLineTo(new PointF(19.44f, 4.56f)); star2Path.ClosePath(); UIColor.White.SetFill(); star2Path.Fill(); UIColor.Black.SetStroke(); star2Path.LineWidth = 2; star2Path.Stroke(); //// Star 3 Drawing UIBezierPath star3Path = new UIBezierPath(); star3Path.MoveTo(new PointF(41.5f, 21.5f)); star3Path.AddLineTo(new PointF(42.91f, 23.56f)); star3Path.AddLineTo(new PointF(45.3f, 24.26f)); star3Path.AddLineTo(new PointF(43.78f, 26.24f)); star3Path.AddLineTo(new PointF(43.85f, 28.74f)); star3Path.AddLineTo(new PointF(41.5f, 27.9f)); star3Path.AddLineTo(new PointF(39.15f, 28.74f)); star3Path.AddLineTo(new PointF(39.22f, 26.24f)); star3Path.AddLineTo(new PointF(37.7f, 24.26f)); star3Path.AddLineTo(new PointF(40.09f, 23.56f)); star3Path.ClosePath(); UIColor.White.SetFill(); star3Path.Fill(); UIColor.Black.SetStroke(); star3Path.LineWidth = 1.5f; star3Path.Stroke(); }
public static void paintCodeDrawQRRETINA() { //// Color Declarations UIColor color2 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRect(new RectangleF(11.5f, 7.5f, 13, 14)); UIColor.White.SetFill(); rectanglePath.Fill(); UIColor.Black.SetStroke(); rectanglePath.LineWidth = 1; rectanglePath.Stroke(); //// Rectangle 2 Drawing var rectangle2Path = UIBezierPath.FromRect(new RectangleF(14.5f, 10.5f, 7, 8)); color2.SetFill(); rectangle2Path.Fill(); UIColor.Black.SetStroke(); rectangle2Path.LineWidth = 1; rectangle2Path.Stroke(); //// Rectangle 3 Drawing var rectangle3Path = UIBezierPath.FromRect(new RectangleF(57.5f, 7.5f, 13, 14)); UIColor.White.SetFill(); rectangle3Path.Fill(); UIColor.Black.SetStroke(); rectangle3Path.LineWidth = 1; rectangle3Path.Stroke(); //// Rectangle 4 Drawing var rectangle4Path = UIBezierPath.FromRect(new RectangleF(60.5f, 10.5f, 7, 8)); color2.SetFill(); rectangle4Path.Fill(); UIColor.Black.SetStroke(); rectangle4Path.LineWidth = 1; rectangle4Path.Stroke(); //// Rectangle 5 Drawing var rectangle5Path = UIBezierPath.FromRect(new RectangleF(11.5f, 36.5f, 13, 14)); UIColor.White.SetFill(); rectangle5Path.Fill(); UIColor.Black.SetStroke(); rectangle5Path.LineWidth = 1; rectangle5Path.Stroke(); //// Rectangle 6 Drawing var rectangle6Path = UIBezierPath.FromRect(new RectangleF(14.5f, 39.5f, 7, 8)); color2.SetFill(); rectangle6Path.Fill(); UIColor.Black.SetStroke(); rectangle6Path.LineWidth = 1; rectangle6Path.Stroke(); //// Star Drawing UIBezierPath starPath = new UIBezierPath(); starPath.MoveTo(new PointF(41.5f, 21.5f)); starPath.AddLineTo(new PointF(45.73f, 27.42f)); starPath.AddLineTo(new PointF(52.91f, 29.45f)); starPath.AddLineTo(new PointF(48.35f, 35.13f)); starPath.AddLineTo(new PointF(48.55f, 42.3f)); starPath.AddLineTo(new PointF(41.5f, 39.9f)); starPath.AddLineTo(new PointF(34.45f, 42.3f)); starPath.AddLineTo(new PointF(34.65f, 35.13f)); starPath.AddLineTo(new PointF(30.09f, 29.45f)); starPath.AddLineTo(new PointF(37.27f, 27.42f)); starPath.ClosePath(); UIColor.White.SetFill(); starPath.Fill(); color2.SetStroke(); starPath.LineWidth = 3.5f; starPath.Stroke(); //// Star 2 Drawing UIBezierPath star2Path = new UIBezierPath(); star2Path.MoveTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.AddLineTo(new PointF(36.5f, 28.5f)); star2Path.ClosePath(); UIColor.White.SetFill(); star2Path.Fill(); UIColor.Black.SetStroke(); star2Path.LineWidth = 1; star2Path.Stroke(); //// Star 3 Drawing UIBezierPath star3Path = new UIBezierPath(); star3Path.MoveTo(new PointF(32.5f, 11)); star3Path.AddLineTo(new PointF(34.62f, 13.83f)); star3Path.AddLineTo(new PointF(38.21f, 14.8f)); star3Path.AddLineTo(new PointF(35.92f, 17.52f)); star3Path.AddLineTo(new PointF(36.03f, 20.95f)); star3Path.AddLineTo(new PointF(32.5f, 19.8f)); star3Path.AddLineTo(new PointF(28.97f, 20.95f)); star3Path.AddLineTo(new PointF(29.08f, 17.52f)); star3Path.AddLineTo(new PointF(26.79f, 14.8f)); star3Path.AddLineTo(new PointF(30.38f, 13.83f)); star3Path.ClosePath(); UIColor.White.SetFill(); star3Path.Fill(); UIColor.Black.SetStroke(); star3Path.LineWidth = 2.5f; star3Path.Stroke(); //// Star 4 Drawing UIBezierPath star4Path = new UIBezierPath(); star4Path.MoveTo(new PointF(50, 11.5f)); star4Path.AddLineTo(new PointF(51.94f, 14.07f)); star4Path.AddLineTo(new PointF(55.23f, 14.95f)); star4Path.AddLineTo(new PointF(53.14f, 17.43f)); star4Path.AddLineTo(new PointF(53.23f, 20.55f)); star4Path.AddLineTo(new PointF(50, 19.5f)); star4Path.AddLineTo(new PointF(46.77f, 20.55f)); star4Path.AddLineTo(new PointF(46.86f, 17.43f)); star4Path.AddLineTo(new PointF(44.77f, 14.95f)); star4Path.AddLineTo(new PointF(48.06f, 14.07f)); star4Path.ClosePath(); UIColor.White.SetFill(); star4Path.Fill(); UIColor.Black.SetStroke(); star4Path.LineWidth = 2.5f; star4Path.Stroke(); //// Star 5 Drawing UIBezierPath star5Path = new UIBezierPath(); star5Path.MoveTo(new PointF(62.5f, 36.5f)); star5Path.AddLineTo(new PointF(64.97f, 40.1f)); star5Path.AddLineTo(new PointF(69.16f, 41.34f)); star5Path.AddLineTo(new PointF(66.49f, 44.8f)); star5Path.AddLineTo(new PointF(66.61f, 49.16f)); star5Path.AddLineTo(new PointF(62.5f, 47.7f)); star5Path.AddLineTo(new PointF(58.39f, 49.16f)); star5Path.AddLineTo(new PointF(58.51f, 44.8f)); star5Path.AddLineTo(new PointF(55.84f, 41.34f)); star5Path.AddLineTo(new PointF(60.03f, 40.1f)); star5Path.ClosePath(); UIColor.White.SetFill(); star5Path.Fill(); UIColor.Black.SetStroke(); star5Path.LineWidth = 2.5f; star5Path.Stroke(); }
void DrawFilledShape() { var bezierPath = new UIBezierPath(); bezierPath.MoveTo(new PointF(41.35f, 17.47f)); bezierPath.AddLineTo(new PointF(39.61f, 17.47f)); bezierPath.AddCurveToPoint(new PointF(36.99f, 14.79f), new PointF(38.18f, 17.47f), new PointF(36.99f, 16.24f)); bezierPath.AddCurveToPoint(new PointF(37.85f, 12.9f), new PointF(36.99f, 14.06f), new PointF(37.3f, 13.39f)); bezierPath.AddLineTo(new PointF(38.98f, 11.8f)); bezierPath.AddCurveToPoint(new PointF(38.98f, 7.8f), new PointF(40.09f, 10.7f), new PointF(40.09f, 8.9f)); bezierPath.AddLineTo(new PointF(36.42f, 5.27f)); bezierPath.AddCurveToPoint(new PointF(34.41f, 4.47f), new PointF(35.91f, 4.77f), new PointF(35.17f, 4.47f)); bezierPath.AddCurveToPoint(new PointF(32.4f, 5.27f), new PointF(33.65f, 4.47f), new PointF(32.92f, 4.77f)); bezierPath.AddLineTo(new PointF(31.33f, 6.35f)); bezierPath.AddCurveToPoint(new PointF(29.38f, 7.23f), new PointF(30.81f, 6.92f), new PointF(30.12f, 7.23f)); bezierPath.AddCurveToPoint(new PointF(26.68f, 4.63f), new PointF(27.91f, 7.23f), new PointF(26.68f, 6.04f)); bezierPath.AddLineTo(new PointF(26.68f, 2.88f)); bezierPath.AddCurveToPoint(new PointF(23.86f, 0), new PointF(26.68f, 1.33f), new PointF(25.42f, 0)); bezierPath.AddLineTo(new PointF(20.38f, 0)); bezierPath.AddCurveToPoint(new PointF(17.58f, 2.88f), new PointF(18.82f, 0), new PointF(17.58f, 1.32f)); bezierPath.AddLineTo(new PointF(17.58f, 4.62f)); bezierPath.AddCurveToPoint(new PointF(14.89f, 7.22f), new PointF(17.58f, 6.03f), new PointF(16.36f, 7.22f)); bezierPath.AddCurveToPoint(new PointF(12.98f, 6.37f), new PointF(14.15f, 7.22f), new PointF(13.48f, 6.91f)); bezierPath.AddLineTo(new PointF(11.87f, 5.27f)); bezierPath.AddCurveToPoint(new PointF(9.86f, 4.47f), new PointF(11.37f, 4.75f), new PointF(10.62f, 4.47f)); bezierPath.AddCurveToPoint(new PointF(7.86f, 5.27f), new PointF(9.11f, 4.47f), new PointF(8.37f, 4.77f)); bezierPath.AddLineTo(new PointF(5.28f, 7.79f)); bezierPath.AddCurveToPoint(new PointF(5.28f, 11.78f), new PointF(4.18f, 8.89f), new PointF(4.18f, 10.69f)); bezierPath.AddLineTo(new PointF(6.35f, 12.85f)); bezierPath.AddCurveToPoint(new PointF(7.25f, 14.79f), new PointF(6.93f, 13.37f), new PointF(7.25f, 14.06f)); bezierPath.AddCurveToPoint(new PointF(4.63f, 17.47f), new PointF(7.25f, 16.26f), new PointF(6.06f, 17.47f)); bezierPath.AddLineTo(new PointF(2.89f, 17.47f)); bezierPath.AddCurveToPoint(new PointF(0, 20.25f), new PointF(1.32f, 17.47f), new PointF(0, 18.7f)); bezierPath.AddLineTo(new PointF(0, 21.99f)); bezierPath.AddLineTo(new PointF(0, 23.74f)); bezierPath.AddCurveToPoint(new PointF(2.89f, 26.52f), new PointF(0, 25.28f), new PointF(1.32f, 26.52f)); bezierPath.AddLineTo(new PointF(4.63f, 26.52f)); bezierPath.AddCurveToPoint(new PointF(7.25f, 29.2f), new PointF(6.06f, 26.52f), new PointF(7.25f, 27.74f)); bezierPath.AddCurveToPoint(new PointF(6.35f, 31.14f), new PointF(7.25f, 29.93f), new PointF(6.93f, 30.62f)); bezierPath.AddLineTo(new PointF(5.28f, 32.2f)); bezierPath.AddCurveToPoint(new PointF(5.28f, 36.19f), new PointF(4.18f, 33.3f), new PointF(4.18f, 35.1f)); bezierPath.AddLineTo(new PointF(7.83f, 38.73f)); bezierPath.AddCurveToPoint(new PointF(9.84f, 39.53f), new PointF(8.34f, 39.25f), new PointF(9.08f, 39.53f)); bezierPath.AddCurveToPoint(new PointF(11.85f, 38.73f), new PointF(10.6f, 39.53f), new PointF(11.33f, 39.23f)); bezierPath.AddLineTo(new PointF(12.96f, 37.63f)); bezierPath.AddCurveToPoint(new PointF(14.87f, 36.78f), new PointF(13.44f, 37.09f), new PointF(14.13f, 36.78f)); bezierPath.AddCurveToPoint(new PointF(17.56f, 39.38f), new PointF(16.33f, 36.78f), new PointF(17.56f, 37.97f)); bezierPath.AddLineTo(new PointF(17.56f, 41.12f)); bezierPath.AddCurveToPoint(new PointF(20.37f, 44), new PointF(17.56f, 42.67f), new PointF(18.8f, 44)); bezierPath.AddLineTo(new PointF(23.86f, 44)); bezierPath.AddCurveToPoint(new PointF(26.66f, 41.12f), new PointF(25.42f, 44), new PointF(26.66f, 42.68f)); bezierPath.AddLineTo(new PointF(26.66f, 39.38f)); bezierPath.AddCurveToPoint(new PointF(29.35f, 36.78f), new PointF(26.66f, 37.97f), new PointF(27.88f, 36.78f)); bezierPath.AddCurveToPoint(new PointF(31.3f, 37.67f), new PointF(30.09f, 36.78f), new PointF(30.77f, 37.1f)); bezierPath.AddLineTo(new PointF(32.38f, 38.74f)); bezierPath.AddCurveToPoint(new PointF(34.39f, 39.54f), new PointF(32.9f, 39.25f), new PointF(33.63f, 39.54f)); bezierPath.AddCurveToPoint(new PointF(36.39f, 38.74f), new PointF(35.14f, 39.54f), new PointF(35.88f, 39.25f)); bezierPath.AddLineTo(new PointF(38.95f, 36.2f)); bezierPath.AddCurveToPoint(new PointF(38.95f, 32.2f), new PointF(40.05f, 35.1f), new PointF(40.05f, 33.3f)); bezierPath.AddLineTo(new PointF(37.83f, 31.1f)); bezierPath.AddCurveToPoint(new PointF(36.97f, 29.21f), new PointF(37.28f, 30.61f), new PointF(36.97f, 29.93f)); bezierPath.AddCurveToPoint(new PointF(39.58f, 26.53f), new PointF(36.97f, 27.74f), new PointF(38.16f, 26.53f)); bezierPath.AddLineTo(new PointF(41.33f, 26.53f)); bezierPath.AddCurveToPoint(new PointF(44, 23.75f), new PointF(42.89f, 26.53f), new PointF(44, 25.3f)); bezierPath.AddLineTo(new PointF(44, 21.99f)); bezierPath.AddLineTo(new PointF(44, 20.25f)); bezierPath.AddCurveToPoint(new PointF(41.35f, 17.47f), new PointF(44.02f, 18.7f), new PointF(42.91f, 17.47f)); bezierPath.ClosePath(); bezierPath.MoveTo(new PointF(31.29f, 21.99f)); bezierPath.AddLineTo(new PointF(31.29f, 21.99f)); bezierPath.AddCurveToPoint(new PointF(22.11f, 31.16f), new PointF(31.29f, 27.05f), new PointF(27.2f, 31.16f)); bezierPath.AddCurveToPoint(new PointF(12.94f, 21.99f), new PointF(17.03f, 31.16f), new PointF(12.94f, 27.05f)); bezierPath.AddLineTo(new PointF(12.94f, 21.99f)); bezierPath.AddLineTo(new PointF(12.94f, 21.99f)); bezierPath.AddCurveToPoint(new PointF(22.11f, 12.83f), new PointF(12.94f, 16.94f), new PointF(17.03f, 12.83f)); bezierPath.AddCurveToPoint(new PointF(31.29f, 21.99f), new PointF(27.2f, 12.83f), new PointF(31.29f, 16.94f)); bezierPath.AddLineTo(new PointF(31.29f, 21.99f)); bezierPath.ClosePath(); bezierPath.MiterLimit = 4; DefaultFillColor.SetColor (); bezierPath.Fill (); }
// 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, int page) { base.DrawPrintFormatterForPage (printFormatter, page); // To keep our custom drawing in sync with the printFormatter, base our drawing // on the formatters rect. RectangleF 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 PointF (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 PointF (rect.Left, rect.Bottom)); // Draw the right border border.MoveTo (new PointF (rect.Right, rect.Top)); border.AddLineTo (new PointF (rect.Right, rect.Bottom)); if (page == printFormatter.StartPage + printFormatter.PageCount - 1) border.AddLineTo (new PointF (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 DrawRect (RectangleF area, UIViewPrintFormatter formatter) { base.DrawRect (area, formatter); //General Declarations CGContext context = UIGraphics.GetCurrentContext (); // Color Declarations UIColor mmFill = new UIColor (0F, 0F, 0F, 0.196F); UIColor shape1DropShadowColor = new UIColor (1F, 1F, 1F, 0.4F); UIColor shape1InnerShadowColor = new UIColor (0F, 0F, 0F, 0.392F); // Shadow Declarations UIColor mmDropShadow = shape1DropShadowColor; SizeF mmDropShadowOffset = new SizeF (0.1F, 1.1F); Single mmDropShadowBlurRadius = 0; UIColor mmInnerShadow = shape1InnerShadowColor; SizeF mmInnerShadowOffset = new SizeF (0.1F, 1.1F); Single mmInnerShadowBlurRadius = 0; // Frames RectangleF frame = this.Bounds; // mmGroup { // mmShape Drawing UIBezierPath mmShapePath = new UIBezierPath (); mmShapePath.MoveTo (new PointF (frame.GetMinX () + 0.51759F * frame.Width, frame.GetMinY () + 0.96761F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.37558F * frame.Width, frame.GetMinY() + 0.91398F * frame.Height), new PointF (frame.GetMinX() + 0.46395F * frame.Width, frame.GetMinY() + 0.96761F * frame.Height), new PointF (frame.GetMinX() + 0.41351F * frame.Width, frame.GetMinY() + 0.94854F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.31759F * frame.Width, frame.GetMinY() + 0.76824F * frame.Height), new PointF (frame.GetMinX() + 0.33346F * frame.Width, frame.GetMinY() + 0.87556F * frame.Height), new PointF (frame.GetMinX() + 0.31234F * frame.Width, frame.GetMinY() + 0.82249F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.31904F * frame.Width, frame.GetMinY() + 0.75325F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.30262F * frame.Width, frame.GetMinY() + 0.75459F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.28470F * frame.Width, frame.GetMinY() + 0.75535F * frame.Height), new PointF (frame.GetMinX() + 0.29666F * frame.Width, frame.GetMinY() + 0.75510F * frame.Height), new PointF (frame.GetMinX() + 0.29065F * frame.Width, frame.GetMinY() + 0.75535F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.14274F * frame.Width, frame.GetMinY() + 0.70173F * frame.Height), new PointF (frame.GetMinX() + 0.23106F * frame.Width, frame.GetMinY() + 0.75535F * frame.Height), new PointF (frame.GetMinX() + 0.18067F * frame.Width, frame.GetMinY() + 0.73625F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.14274F * frame.Width, frame.GetMinY() + 0.44291F * frame.Height), new PointF (frame.GetMinX() + 0.06451F * frame.Width, frame.GetMinY() + 0.63038F * frame.Height), new PointF (frame.GetMinX() + 0.06451F * frame.Width, frame.GetMinY() + 0.51425F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.45528F * frame.Width, frame.GetMinY() + 0.15799F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.48085F * frame.Width, frame.GetMinY() + 0.14832F * frame.Height), new PointF (frame.GetMinX() + 0.46207F * frame.Width, frame.GetMinY() + 0.15176F * frame.Height), new PointF (frame.GetMinX() + 0.47120F * frame.Width, frame.GetMinY() + 0.14832F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.50639F * frame.Width, frame.GetMinY() + 0.15799F * frame.Height), new PointF (frame.GetMinX() + 0.49051F * frame.Width, frame.GetMinY() + 0.14832F * frame.Height), new PointF (frame.GetMinX() + 0.49957F * frame.Width, frame.GetMinY() + 0.15176F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.50639F * frame.Width, frame.GetMinY() + 0.20462F * frame.Height), new PointF (frame.GetMinX() + 0.52050F * frame.Width, frame.GetMinY() + 0.17087F * frame.Height), new PointF (frame.GetMinX() + 0.52050F * frame.Width, frame.GetMinY() + 0.19177F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.19390F * frame.Width, frame.GetMinY() + 0.48951F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.19386F * frame.Width, frame.GetMinY() + 0.65510F * frame.Height), new PointF (frame.GetMinX() + 0.14397F * frame.Width, frame.GetMinY() + 0.53518F * frame.Height), new PointF (frame.GetMinX() + 0.14397F * frame.Width, frame.GetMinY() + 0.60942F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.28476F * frame.Width, frame.GetMinY() + 0.68936F * frame.Height), new PointF (frame.GetMinX() + 0.21821F * frame.Width, frame.GetMinY() + 0.67720F * frame.Height), new PointF (frame.GetMinX() + 0.25047F * frame.Width, frame.GetMinY() + 0.68936F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.37557F * frame.Width, frame.GetMinY() + 0.65514F * frame.Height), new PointF (frame.GetMinX() + 0.31904F * frame.Width, frame.GetMinY() + 0.68936F * frame.Height), new PointF (frame.GetMinX() + 0.35128F * frame.Width, frame.GetMinY() + 0.67720F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.68812F * frame.Width, frame.GetMinY() + 0.37025F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.71365F * frame.Width, frame.GetMinY() + 0.36056F * frame.Height), new PointF (frame.GetMinX() + 0.69491F * frame.Width, frame.GetMinY() + 0.36401F * frame.Height), new PointF (frame.GetMinX() + 0.70403F * frame.Width, frame.GetMinY() + 0.36056F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.73923F * frame.Width, frame.GetMinY() + 0.37025F * frame.Height), new PointF (frame.GetMinX() + 0.72332F * frame.Width, frame.GetMinY() + 0.36056F * frame.Height), new PointF (frame.GetMinX() + 0.73241F * frame.Width, frame.GetMinY() + 0.36401F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.73923F * frame.Width, frame.GetMinY() + 0.41681F * frame.Height), new PointF (frame.GetMinX() + 0.75333F * frame.Width, frame.GetMinY() + 0.38310F * frame.Height), new PointF (frame.GetMinX() + 0.75333F * frame.Width, frame.GetMinY() + 0.40399F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.42673F * frame.Width, frame.GetMinY() + 0.70173F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.42670F * frame.Width, frame.GetMinY() + 0.86737F * frame.Height), new PointF (frame.GetMinX() + 0.37681F * frame.Width, frame.GetMinY() + 0.74744F * frame.Height), new PointF (frame.GetMinX() + 0.37681F * frame.Width, frame.GetMinY() + 0.82172F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.51759F * frame.Width, frame.GetMinY() + 0.90159F * frame.Height), new PointF (frame.GetMinX() + 0.45104F * frame.Width, frame.GetMinY() + 0.88944F * frame.Height), new PointF (frame.GetMinX() + 0.48328F * frame.Width, frame.GetMinY() + 0.90159F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.60840F * frame.Width, frame.GetMinY() + 0.86743F * frame.Height), new PointF (frame.GetMinX() + 0.55183F * frame.Width, frame.GetMinY() + 0.90159F * frame.Height), new PointF (frame.GetMinX() + 0.58413F * frame.Width, frame.GetMinY() + 0.88944F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.92092F * frame.Width, frame.GetMinY() + 0.58246F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.94646F * frame.Width, frame.GetMinY() + 0.57284F * frame.Height), new PointF (frame.GetMinX() + 0.92773F * frame.Width, frame.GetMinY() + 0.57623F * frame.Height), new PointF (frame.GetMinX() + 0.93682F * frame.Width, frame.GetMinY() + 0.57284F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.97208F * frame.Width, frame.GetMinY() + 0.58246F * frame.Height), new PointF (frame.GetMinX() + 0.95617F * frame.Width, frame.GetMinY() + 0.57284F * frame.Height), new PointF (frame.GetMinX() + 0.96523F * frame.Width, frame.GetMinY() + 0.57623F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.97208F * frame.Width, frame.GetMinY() + 0.62912F * frame.Height), new PointF (frame.GetMinX() + 0.98615F * frame.Width, frame.GetMinY() + 0.59535F * frame.Height), new PointF (frame.GetMinX() + 0.98615F * frame.Width, frame.GetMinY() + 0.61626F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.65956F * frame.Width, frame.GetMinY() + 0.91398F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.51759F * frame.Width, frame.GetMinY() + 0.96761F * frame.Height), new PointF (frame.GetMinX() + 0.62160F * frame.Width, frame.GetMinY() + 0.94854F * frame.Height), new PointF (frame.GetMinX() + 0.57117F * frame.Width, frame.GetMinY() + 0.96761F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.51759F * frame.Width, frame.GetMinY() + 0.96761F * frame.Height)); mmShapePath.ClosePath (); mmShapePath.MoveTo (new PointF (frame.GetMinX() + 0.51965F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.49408F * frame.Width, frame.GetMinY() + 0.80982F * frame.Height), new PointF (frame.GetMinX() + 0.50999F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height), new PointF (frame.GetMinX() + 0.50091F * frame.Width, frame.GetMinY() + 0.81600F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.49408F * frame.Width, frame.GetMinY() + 0.76313F * frame.Height), new PointF (frame.GetMinX() + 0.48000F * frame.Width, frame.GetMinY() + 0.79686F * frame.Height), new PointF (frame.GetMinX() + 0.48000F * frame.Width, frame.GetMinY() + 0.77600F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.80659F * frame.Width, frame.GetMinY() + 0.47824F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.80662F * frame.Width, frame.GetMinY() + 0.31264F * frame.Height), new PointF (frame.GetMinX() + 0.85650F * frame.Width, frame.GetMinY() + 0.43259F * frame.Height), new PointF (frame.GetMinX() + 0.85650F * frame.Width, frame.GetMinY() + 0.35831F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.71574F * frame.Width, frame.GetMinY() + 0.27840F * frame.Height), new PointF (frame.GetMinX() + 0.78226F * frame.Width, frame.GetMinY() + 0.29053F * frame.Height), new PointF (frame.GetMinX() + 0.75001F * frame.Width, frame.GetMinY() + 0.27840F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.62493F * frame.Width, frame.GetMinY() + 0.31260F * frame.Height), new PointF (frame.GetMinX() + 0.68146F * frame.Width, frame.GetMinY() + 0.27840F * frame.Height), new PointF (frame.GetMinX() + 0.64921F * frame.Width, frame.GetMinY() + 0.29053F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.31239F * frame.Width, frame.GetMinY() + 0.59752F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.28684F * frame.Width, frame.GetMinY() + 0.60718F * frame.Height), new PointF (frame.GetMinX() + 0.30556F * frame.Width, frame.GetMinY() + 0.60378F * frame.Height), new PointF (frame.GetMinX() + 0.29644F * frame.Width, frame.GetMinY() + 0.60718F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.26125F * frame.Width, frame.GetMinY() + 0.59752F * frame.Height), new PointF (frame.GetMinX() + 0.27718F * frame.Width, frame.GetMinY() + 0.60718F * frame.Height), new PointF (frame.GetMinX() + 0.26808F * frame.Width, frame.GetMinY() + 0.60378F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.26125F * frame.Width, frame.GetMinY() + 0.55093F * frame.Height), new PointF (frame.GetMinX() + 0.24715F * frame.Width, frame.GetMinY() + 0.58467F * frame.Height), new PointF (frame.GetMinX() + 0.24715F * frame.Width, frame.GetMinY() + 0.56377F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.57377F * frame.Width, frame.GetMinY() + 0.26601F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.57380F * frame.Width, frame.GetMinY() + 0.10041F * frame.Height), new PointF (frame.GetMinX() + 0.62368F * frame.Width, frame.GetMinY() + 0.22029F * frame.Height), new PointF (frame.GetMinX() + 0.62368F * frame.Width, frame.GetMinY() + 0.14606F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.48291F * frame.Width, frame.GetMinY() + 0.06617F * frame.Height), new PointF (frame.GetMinX() + 0.54946F * frame.Width, frame.GetMinY() + 0.07832F * frame.Height), new PointF (frame.GetMinX() + 0.51721F * frame.Width, frame.GetMinY() + 0.06617F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.39208F * frame.Width, frame.GetMinY() + 0.10040F * frame.Height), new PointF (frame.GetMinX() + 0.44863F * frame.Width, frame.GetMinY() + 0.06617F * frame.Height), new PointF (frame.GetMinX() + 0.41637F * frame.Width, frame.GetMinY() + 0.07832F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.07956F * frame.Width, frame.GetMinY() + 0.38530F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.05400F * frame.Width, frame.GetMinY() + 0.39496F * frame.Height), new PointF (frame.GetMinX() + 0.07274F * frame.Width, frame.GetMinY() + 0.39149F * frame.Height), new PointF (frame.GetMinX() + 0.06365F * frame.Width, frame.GetMinY() + 0.39496F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.02841F * frame.Width, frame.GetMinY() + 0.38530F * frame.Height), new PointF (frame.GetMinX() + 0.04434F * frame.Width, frame.GetMinY() + 0.39496F * frame.Height), new PointF (frame.GetMinX() + 0.03525F * frame.Width, frame.GetMinY() + 0.39149F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.02841F * frame.Width, frame.GetMinY() + 0.33867F * frame.Height), new PointF (frame.GetMinX() + 0.01434F * frame.Width, frame.GetMinY() + 0.37241F * frame.Height), new PointF (frame.GetMinX() + 0.01434F * frame.Width, frame.GetMinY() + 0.35151F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.34095F * frame.Width, frame.GetMinY() + 0.05378F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.48291F * frame.Width, frame.GetMinY() + 0.00013F * frame.Height), new PointF (frame.GetMinX() + 0.37888F * frame.Width, frame.GetMinY() + 0.01919F * frame.Height), new PointF (frame.GetMinX() + 0.42931F * frame.Width, frame.GetMinY() + 0.00013F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.62491F * frame.Width, frame.GetMinY() + 0.05378F * frame.Height), new PointF (frame.GetMinX() + 0.53657F * frame.Width, frame.GetMinY() + 0.00013F * frame.Height), new PointF (frame.GetMinX() + 0.58700F * frame.Width, frame.GetMinY() + 0.01919F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.68292F * frame.Width, frame.GetMinY() + 0.19950F * frame.Height), new PointF (frame.GetMinX() + 0.66705F * frame.Width, frame.GetMinY() + 0.09219F * frame.Height), new PointF (frame.GetMinX() + 0.68815F * frame.Width, frame.GetMinY() + 0.14529F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.68143F * frame.Width, frame.GetMinY() + 0.21454F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.69786F * frame.Width, frame.GetMinY() + 0.21318F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.71580F * frame.Width, frame.GetMinY() + 0.21244F * frame.Height), new PointF (frame.GetMinX() + 0.70379F * frame.Width, frame.GetMinY() + 0.21269F * frame.Height), new PointF (frame.GetMinX() + 0.70984F * frame.Width, frame.GetMinY() + 0.21244F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.85774F * frame.Width, frame.GetMinY() + 0.26604F * frame.Height), new PointF (frame.GetMinX() + 0.76941F * frame.Width, frame.GetMinY() + 0.21244F * frame.Height), new PointF (frame.GetMinX() + 0.81981F * frame.Width, frame.GetMinY() + 0.23147F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.85774F * frame.Width, frame.GetMinY() + 0.52485F * frame.Height), new PointF (frame.GetMinX() + 0.93599F * frame.Width, frame.GetMinY() + 0.33738F * frame.Height), new PointF (frame.GetMinX() + 0.93599F * frame.Width, frame.GetMinY() + 0.45349F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.54521F * frame.Width, frame.GetMinY() + 0.80977F * frame.Height)); mmShapePath.AddCurveToPoint ( new PointF (frame.GetMinX() + 0.51965F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height), new PointF (frame.GetMinX() + 0.53840F * frame.Width, frame.GetMinY() + 0.81600F * frame.Height), new PointF (frame.GetMinX() + 0.52930F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height)); mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.51965F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height)); mmShapePath.ClosePath (); context.SaveState (); context.SetShadowWithColor (mmDropShadowOffset, mmDropShadowBlurRadius, mmDropShadow.CGColor); context.SetBlendMode (CGBlendMode.Overlay); mmFill.SetFill (); mmShapePath.Fill (); RectangleF mmShapeBorderRect = RectangleF.Inflate (mmShapePath.Bounds, mmInnerShadowBlurRadius, mmInnerShadowBlurRadius); mmShapeBorderRect.Offset (mmInnerShadowOffset.Width, mmInnerShadowOffset.Height); mmShapeBorderRect.UnionWith (mmShapePath.Bounds); UIBezierPath mmShapeNegativePath = UIBezierPath.FromRect (mmShapeBorderRect); mmShapeNegativePath.AppendPath (mmShapePath); mmShapeNegativePath.UsesEvenOddFillRule = true; context.SaveState (); { Single xOffset = mmInnerShadowOffset.Width + (float) Math.Round (mmShapeBorderRect.Size.Width); Single yOffset = mmInnerShadowOffset.Height; context.SetShadowWithColor (new SizeF (xOffset + CopySign (0.1F, xOffset), yOffset + CopySign (0.1F, yOffset)), mmInnerShadowBlurRadius, mmInnerShadow.CGColor); mmShapePath.AddClip (); CGAffineTransform transform = CGAffineTransform.MakeTranslation ((float)-Math.Round (mmShapeBorderRect.Size.Width), 0F); mmShapeNegativePath.ApplyTransform (transform); UIColor.Gray.SetFill (); mmShapeNegativePath.Fill (); } context.RestoreState (); context.RestoreState (); } }
public override void TouchesEnded(NSSet touches, UIEvent evt) { UITouch touch = touches.AnyObject as UITouch; //Obtain the location of the touch and add it to the current path and current_points array. PointF touchLocation = touch.LocationInView (this); currentPath.AddLineTo (touchLocation); currentPoints.Add (touchLocation); //Obtain the smoothed path and the points array for that path. currentPath = smoothedPathWithGranularity (40, out currentPoints); //Add the smoothed path and points array to their Lists. paths.Add (currentPath); points.Add (currentPoints.ToArray ()); //Obtain the image for the imported signature and display it in the image view. imageView.Image = GetImage (false); updateBounds (touchLocation); SetNeedsDisplay (); }
public override void Draw (RectangleF rect) { UIView head = ((WalkingDead)Superview).head; UIBezierPath path = new UIBezierPath (); path.LineCapStyle = CGLineCap.Round; RectangleF headFrame = head.Frame; if (!MovingRight) { rect.X -= 20; path.MoveTo (new PointF (rect.GetMidX () + 20, headFrame.GetMaxY () + 10)); path.AddLineTo (new PointF (rect.GetMidX () + 20 + rect.Size.Width / 6, headFrame.GetMaxY () + 10)); path.AddLineTo (new PointF (rect.GetMidX () + 20 + rect.Size.Width / 6 + 10, headFrame.GetMaxY () + 10 + 20)); } else { path.MoveTo (new PointF (rect.GetMidX () - 20, headFrame.GetMaxY () + 10)); path.AddLineTo (new PointF (rect.GetMidX () - 20 - rect.Size.Width / 6, headFrame.GetMaxY () + 10)); path.AddLineTo (new PointF (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 (); }
//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 PointF.Empty in the array. public void LoadPoints(PointF[] loadedPoints) { if (loadedPoints == null || loadedPoints.Count () == 0) return; var startIndex = 0; var emptyIndex = loadedPoints.ToList ().IndexOf (PointF.Empty); if (emptyIndex == -1) emptyIndex = loadedPoints.Count (); //Clear any existing paths or points. paths = new List<UIBezierPath> (); points = new List<PointF[]> (); do { //Create a new path and set the line options currentPath = UIBezierPath.Create (); currentPath.LineWidth = StrokeWidth; currentPath.LineJoinStyle = CGLineJoin.Round; currentPoints = new List<PointF> (); //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 (PointF.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. imageView.Image = GetImage (false); //Display the clear button. btnClear.Hidden = false; SetNeedsDisplay (); }
//Delete the current signature. public void Clear() { paths = new List<UIBezierPath> (); currentPath = UIBezierPath.Create (); points = new List<PointF[]> (); currentPoints.Clear (); imageView.Image = null; btnClear.Hidden = true; SetNeedsDisplay (); }
public override void Draw (RectangleF rect) { base.Draw (rect); // ------------- START PAINTCODE ---------------- //// General Declarations var colorSpace = CGColorSpace.CreateDeviceRGB (); 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 float [] {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 float [] {0, 0.26f, 0.26f}; var calendarGradient = new CGGradient (colorSpace, calendarGradientColors, calendarGradientLocations); //// Shadow Declarations var shadow = UIColor.DarkGray.CGColor; var shadowOffset = new SizeF (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 RectangleF (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 RectangleF (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 RectangleF (8.5f, 60.5f, 37, 36), 4); context.SaveState (); context.SetShadowWithColor (shadowOffset, shadowBlurRadius, shadow); context.BeginTransparencyLayer (null); roundedRectanglePath.AddClip (); context.DrawLinearGradient (calendarGradient, new PointF (27, 96.5f), new PointF (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 PointF (9, 91.2f)); roundedRectangle3Path.AddCurveToPoint (new PointF (12.56f, 95), new PointF (9, 93.3f), new PointF (10.32f, 95)); roundedRectangle3Path.AddLineTo (new PointF (40.94f, 95)); roundedRectangle3Path.AddCurveToPoint (new PointF (45, 91.2f), new PointF (43.18f, 95), new PointF (45, 93.3f)); roundedRectangle3Path.AddLineTo (new PointF (45, 87)); roundedRectangle3Path.AddCurveToPoint (new PointF (43.42f, 85.5f), new PointF (45, 84.9f), new PointF (45.66f, 85.5f)); roundedRectangle3Path.AddLineTo (new PointF (10.94f, 85.5f)); roundedRectangle3Path.AddCurveToPoint (new PointF (9, 87), new PointF (8.7f, 85.5f), new PointF (9, 84.9f)); roundedRectangle3Path.AddLineTo (new PointF (9, 91.2f)); roundedRectangle3Path.ClosePath (); UIColor.Red.SetFill (); roundedRectangle3Path.Fill (); //// Month Drawing var monthRect = new RectangleF (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 RectangleF (0, 58, 54, 31); UIColor.Black.SetFill (); new NSString (dayContent).DrawString (dayRect, dayFont, UILineBreakMode.WordWrap, UITextAlignment.Center); //// Text Drawing var textRect = new RectangleF (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 PointF (31, 14.5f)); starPath.AddLineTo (new PointF (26.24f, 21.45f)); starPath.AddLineTo (new PointF (18.16f, 23.83f)); starPath.AddLineTo (new PointF (23.3f, 30.5f)); starPath.AddLineTo (new PointF (23.06f, 38.92f)); starPath.AddLineTo (new PointF (31, 36.1f)); starPath.AddLineTo (new PointF (38.94f, 38.92f)); starPath.AddLineTo (new PointF (38.7f, 30.5f)); starPath.AddLineTo (new PointF (43.84f, 23.83f)); starPath.AddLineTo (new PointF (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 PointF (256.5f, 16.5f)); blueBlobPath.AddCurveToPoint (new PointF (240.5f, 41.5f), new PointF (235.5f, 37.5f), new PointF (217.53f, 41.55f)); blueBlobPath.AddCurveToPoint (new PointF (265.5f, 30.5f), new PointF (263.47f, 41.45f), new PointF (265.5f, 30.5f)); blueBlobPath.AddCurveToPoint (new PointF (256.5f, 16.5f), new PointF (265.5f, 30.5f), new PointF (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 RectangleF (54.5f, 10.5f, 163, 31), 4); context.SaveState (); buttonPath.AddClip (); context.DrawRadialGradient (newGradient, new PointF (100.39f, 55.13f), 7.84f, new PointF (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 RectangleF (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 RectangleF (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 RectangleF (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 PointF (172.5f, 80.5f)); bezier2Path.AddCurveToPoint (new PointF (185.5f, 85.5f), new PointF (177.75f, 85), new PointF (182.04f, 86.03f)); bezier2Path.AddCurveToPoint (new PointF (194.5f, 79.5f), new PointF (191.27f, 84.62f), new PointF (194.5f, 79.5f)); UIColor.Black.SetStroke (); bezier2Path.LineWidth = 2; bezier2Path.Stroke (); //// Oval 5 Drawing var oval5Path = UIBezierPath.FromOval (new RectangleF (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 RectangleF (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 RectangleF (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 RectangleF (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 RectangleF (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 RectangleF (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 RectangleF (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 PointF (270.5f, 81.5f)); bezier5Path.AddCurveToPoint (new PointF (267.5f, 88.5f), new PointF (269.5f, 85.5f), new PointF (267.5f, 88.5f)); UIColor.Black.SetStroke (); bezier5Path.LineWidth = 1; bezier5Path.Stroke (); //// Bezier 6 Drawing UIBezierPath bezier6Path = new UIBezierPath (); bezier6Path.MoveTo (new PointF (272.5f, 81.5f)); bezier6Path.AddLineTo (new PointF (274.5f, 87.5f)); UIColor.Black.SetStroke (); bezier6Path.LineWidth = 1; bezier6Path.Stroke (); // ------------- END PAINTCODE ---------------- }
public static UIImage MakeFlosshatt() { bool retina = (UIScreen.MainScreen.Scale > 1.0); if (retina) { UIGraphics.BeginImageContext (new System.Drawing.SizeF (96, 64)); ///BEGIN PAINTCODE RETINA //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations UIColor shadowColor2 = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 0.454f); UIColor color4 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); //// Shadow Declarations var shadow = shadowColor2.ColorWithAlpha(0.5f).CGColor; var shadowOffset = new SizeF(0.1f, -1.1f); var shadowBlurRadius = 10; //// Group { //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRect(new RectangleF(20.5f, 15.5f, 0, 0)); color4.SetFill(); rectanglePath.Fill(); color4.SetStroke(); rectanglePath.LineWidth = 1; rectanglePath.Stroke(); //// Rectangle 2 Drawing UIBezierPath rectangle2Path = new UIBezierPath(); rectangle2Path.MoveTo(new PointF(20.72f, 49.5f)); rectangle2Path.AddCurveToPoint(new PointF(45.5f, 54.5f), new PointF(20.72f, 49.5f), new PointF(32.97f, 54.5f)); rectangle2Path.AddCurveToPoint(new PointF(70.84f, 49.5f), new PointF(58.03f, 54.5f), new PointF(70.84f, 49.5f)); rectangle2Path.AddLineTo(new PointF(70.5f, 9.5f)); rectangle2Path.AddCurveToPoint(new PointF(59.27f, 15), new PointF(70.5f, 9.5f), new PointF(68.43f, 13.56f)); rectangle2Path.AddCurveToPoint(new PointF(34.21f, 15), new PointF(50.12f, 16.44f), new PointF(41.85f, 15.58f)); rectangle2Path.AddCurveToPoint(new PointF(20.72f, 9.25f), new PointF(26.58f, 14.41f), new PointF(20.72f, 9.25f)); rectangle2Path.AddLineTo(new PointF(20.72f, 49.5f)); rectangle2Path.ClosePath(); color4.SetFill(); rectangle2Path.Fill(); ////// Rectangle 2 Inner Shadow var rectangle2BorderRect = rectangle2Path.Bounds; rectangle2BorderRect.Inflate(shadowBlurRadius, shadowBlurRadius); rectangle2BorderRect.Offset(-shadowOffset.Width, -shadowOffset.Height); rectangle2BorderRect = RectangleF.Union(rectangle2BorderRect, rectangle2Path.Bounds); rectangle2BorderRect.Inflate(1, 1); var rectangle2NegativePath = UIBezierPath.FromRect(rectangle2BorderRect); rectangle2NegativePath.AppendPath(rectangle2Path); rectangle2NegativePath.UsesEvenOddFillRule = true; context.SaveState(); { var xOffset = shadowOffset.Width + (float)Math.Round(rectangle2BorderRect.Width); var yOffset = shadowOffset.Height; context.SetShadowWithColor( new SizeF(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)), shadowBlurRadius, shadow); rectangle2Path.AddClip(); var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(rectangle2BorderRect.Width), 0); rectangle2NegativePath.ApplyTransform(transform); UIColor.Gray.SetFill(); rectangle2NegativePath.Fill(); } context.RestoreState(); color4.SetStroke(); rectangle2Path.LineWidth = 1; rectangle2Path.Stroke(); //// Oval Drawing UIBezierPath ovalPath = new UIBezierPath(); ovalPath.MoveTo(new PointF(41.75f, 29.14f)); ovalPath.AddCurveToPoint(new PointF(41.75f, 29.14f), new PointF(41.64f, 28.93f), new PointF(41.75f, 29.14f)); ovalPath.AddCurveToPoint(new PointF(41.75f, 29.14f), new PointF(41.75f, 29.14f), new PointF(41.85f, 29.34f)); ovalPath.ClosePath(); ovalPath.MoveTo(new PointF(71.09f, 40.78f)); ovalPath.AddCurveToPoint(new PointF(85.5f, 53.5f), new PointF(71.09f, 40.78f), new PointF(90.3f, 44.46f)); ovalPath.AddCurveToPoint(new PointF(71.5f, 60.5f), new PointF(83.59f, 57.1f), new PointF(79.87f, 58.44f)); ovalPath.AddCurveToPoint(new PointF(43.5f, 63.5f), new PointF(68.37f, 61.27f), new PointF(55.33f, 63.35f)); ovalPath.AddCurveToPoint(new PointF(19.98f, 60.61f), new PointF(32.61f, 63.64f), new PointF(22.5f, 61.09f)); ovalPath.AddCurveToPoint(new PointF(6.48f, 53.09f), new PointF(14.84f, 59.63f), new PointF(6.96f, 54.65f)); ovalPath.AddCurveToPoint(new PointF(19.98f, 40.78f), new PointF(5.15f, 48.79f), new PointF(10.39f, 43.13f)); ovalPath.AddLineTo(new PointF(19.98f, 49.64f)); ovalPath.AddCurveToPoint(new PointF(45.5f, 53.5f), new PointF(19.98f, 49.64f), new PointF(32.72f, 53.5f)); ovalPath.AddCurveToPoint(new PointF(71.09f, 49.64f), new PointF(58.28f, 53.5f), new PointF(71.09f, 49.64f)); ovalPath.AddLineTo(new PointF(71.09f, 40.78f)); ovalPath.ClosePath(); ovalPath.MiterLimit = 6; color4.SetFill(); ovalPath.Fill(); ////// Oval Inner Shadow var ovalBorderRect = ovalPath.Bounds; ovalBorderRect.Inflate(shadowBlurRadius, shadowBlurRadius); ovalBorderRect.Offset(-shadowOffset.Width, -shadowOffset.Height); ovalBorderRect = RectangleF.Union(ovalBorderRect, ovalPath.Bounds); ovalBorderRect.Inflate(1, 1); var ovalNegativePath = UIBezierPath.FromRect(ovalBorderRect); ovalNegativePath.AppendPath(ovalPath); ovalNegativePath.UsesEvenOddFillRule = true; context.SaveState(); { var xOffset = shadowOffset.Width + (float)Math.Round(ovalBorderRect.Width); var yOffset = shadowOffset.Height; context.SetShadowWithColor( new SizeF(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)), shadowBlurRadius, shadow); ovalPath.AddClip(); var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(ovalBorderRect.Width), 0); ovalNegativePath.ApplyTransform(transform); UIColor.Gray.SetFill(); ovalNegativePath.Fill(); } context.RestoreState(); color4.SetStroke(); ovalPath.LineWidth = 1; ovalPath.Stroke(); //// Oval 2 Drawing var oval2Path = UIBezierPath.FromOval(new RectangleF(20.5f, 3.5f, 50, 12)); color4.SetFill(); oval2Path.Fill(); ////// Oval 2 Inner Shadow var oval2BorderRect = oval2Path.Bounds; oval2BorderRect.Inflate(shadowBlurRadius, shadowBlurRadius); oval2BorderRect.Offset(-shadowOffset.Width, -shadowOffset.Height); oval2BorderRect = RectangleF.Union(oval2BorderRect, oval2Path.Bounds); oval2BorderRect.Inflate(1, 1); var oval2NegativePath = UIBezierPath.FromRect(oval2BorderRect); oval2NegativePath.AppendPath(oval2Path); oval2NegativePath.UsesEvenOddFillRule = true; context.SaveState(); { var xOffset = shadowOffset.Width + (float)Math.Round(oval2BorderRect.Width); var yOffset = shadowOffset.Height; context.SetShadowWithColor( new SizeF(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)), shadowBlurRadius, shadow); oval2Path.AddClip(); var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(oval2BorderRect.Width), 0); oval2NegativePath.ApplyTransform(transform); UIColor.Gray.SetFill(); oval2NegativePath.Fill(); } context.RestoreState(); color4.SetStroke(); oval2Path.LineWidth = 1; oval2Path.Stroke(); } // END PAINTCODE RETINA } else { UIGraphics.BeginImageContext (new System.Drawing.SizeF (48, 32)); //start paintcode //// General Declarations var context = UIGraphics.GetCurrentContext(); //// Color Declarations UIColor shadowColor2 = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 0.454f); UIColor color4 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f); //// Shadow Declarations var shadow = shadowColor2.ColorWithAlpha(0.5f).CGColor; var shadowOffset = new SizeF(0.1f, -1.1f); var shadowBlurRadius = 10; //// Group { //// Rectangle Drawing var rectanglePath = UIBezierPath.FromRect(new RectangleF(10.5f, 7.5f, 0, 0)); color4.SetFill(); rectanglePath.Fill(); color4.SetStroke(); rectanglePath.LineWidth = 1; rectanglePath.Stroke(); //// Rectangle 2 Drawing UIBezierPath rectangle2Path = new UIBezierPath(); rectangle2Path.MoveTo(new PointF(9.81f, 24.87f)); rectangle2Path.AddCurveToPoint(new PointF(22.97f, 27.33f), new PointF(9.81f, 24.87f), new PointF(16.32f, 27.33f)); rectangle2Path.AddCurveToPoint(new PointF(36.42f, 24.87f), new PointF(29.62f, 27.33f), new PointF(36.42f, 24.87f)); rectangle2Path.AddLineTo(new PointF(36.24f, 5.2f)); rectangle2Path.AddCurveToPoint(new PointF(30.28f, 7.9f), new PointF(36.24f, 5.2f), new PointF(35.14f, 7.19f)); rectangle2Path.AddCurveToPoint(new PointF(16.98f, 7.9f), new PointF(25.42f, 8.61f), new PointF(21.03f, 8.19f)); rectangle2Path.AddCurveToPoint(new PointF(9.81f, 5.07f), new PointF(12.92f, 7.61f), new PointF(9.81f, 5.07f)); rectangle2Path.AddLineTo(new PointF(9.81f, 24.87f)); rectangle2Path.ClosePath(); color4.SetFill(); rectangle2Path.Fill(); ////// Rectangle 2 Inner Shadow var rectangle2BorderRect = rectangle2Path.Bounds; rectangle2BorderRect.Inflate(shadowBlurRadius, shadowBlurRadius); rectangle2BorderRect.Offset(-shadowOffset.Width, -shadowOffset.Height); rectangle2BorderRect = RectangleF.Union(rectangle2BorderRect, rectangle2Path.Bounds); rectangle2BorderRect.Inflate(1, 1); var rectangle2NegativePath = UIBezierPath.FromRect(rectangle2BorderRect); rectangle2NegativePath.AppendPath(rectangle2Path); rectangle2NegativePath.UsesEvenOddFillRule = true; context.SaveState(); { var xOffset = shadowOffset.Width + (float)Math.Round(rectangle2BorderRect.Width); var yOffset = shadowOffset.Height; context.SetShadowWithColor( new SizeF(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)), shadowBlurRadius, shadow); rectangle2Path.AddClip(); var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(rectangle2BorderRect.Width), 0); rectangle2NegativePath.ApplyTransform(transform); UIColor.Gray.SetFill(); rectangle2NegativePath.Fill(); } context.RestoreState(); color4.SetStroke(); rectangle2Path.LineWidth = 1; rectangle2Path.Stroke(); //// Oval Drawing UIBezierPath ovalPath = new UIBezierPath(); ovalPath.MoveTo(new PointF(20.98f, 14.86f)); ovalPath.AddCurveToPoint(new PointF(20.98f, 14.86f), new PointF(20.92f, 14.75f), new PointF(20.98f, 14.86f)); ovalPath.AddCurveToPoint(new PointF(20.98f, 14.86f), new PointF(20.98f, 14.86f), new PointF(21.03f, 14.96f)); ovalPath.ClosePath(); ovalPath.MoveTo(new PointF(36.56f, 20.58f)); ovalPath.AddCurveToPoint(new PointF(44.2f, 26.84f), new PointF(36.56f, 20.58f), new PointF(46.75f, 22.39f)); ovalPath.AddCurveToPoint(new PointF(36.77f, 30.28f), new PointF(43.19f, 28.61f), new PointF(41.21f, 29.27f)); ovalPath.AddCurveToPoint(new PointF(21.91f, 31.75f), new PointF(35.11f, 30.66f), new PointF(28.18f, 31.68f)); ovalPath.AddCurveToPoint(new PointF(9.42f, 30.33f), new PointF(16.13f, 31.82f), new PointF(10.76f, 30.57f)); ovalPath.AddCurveToPoint(new PointF(2.25f, 26.63f), new PointF(6.69f, 29.85f), new PointF(2.51f, 27.4f)); ovalPath.AddCurveToPoint(new PointF(9.42f, 20.58f), new PointF(1.55f, 24.52f), new PointF(4.33f, 21.73f)); ovalPath.AddLineTo(new PointF(9.42f, 24.94f)); ovalPath.AddCurveToPoint(new PointF(22.97f, 26.84f), new PointF(9.42f, 24.94f), new PointF(16.19f, 26.84f)); ovalPath.AddCurveToPoint(new PointF(36.56f, 24.94f), new PointF(29.75f, 26.84f), new PointF(36.56f, 24.94f)); ovalPath.AddLineTo(new PointF(36.56f, 20.58f)); ovalPath.ClosePath(); ovalPath.MiterLimit = 6; color4.SetFill(); ovalPath.Fill(); ////// Oval Inner Shadow var ovalBorderRect = ovalPath.Bounds; ovalBorderRect.Inflate(shadowBlurRadius, shadowBlurRadius); ovalBorderRect.Offset(-shadowOffset.Width, -shadowOffset.Height); ovalBorderRect = RectangleF.Union(ovalBorderRect, ovalPath.Bounds); ovalBorderRect.Inflate(1, 1); var ovalNegativePath = UIBezierPath.FromRect(ovalBorderRect); ovalNegativePath.AppendPath(ovalPath); ovalNegativePath.UsesEvenOddFillRule = true; context.SaveState(); { var xOffset = shadowOffset.Width + (float)Math.Round(ovalBorderRect.Width); var yOffset = shadowOffset.Height; context.SetShadowWithColor( new SizeF(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)), shadowBlurRadius, shadow); ovalPath.AddClip(); var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(ovalBorderRect.Width), 0); ovalNegativePath.ApplyTransform(transform); UIColor.Gray.SetFill(); ovalNegativePath.Fill(); } context.RestoreState(); color4.SetStroke(); ovalPath.LineWidth = 1; ovalPath.Stroke(); //// Oval 2 Drawing var oval2Path = UIBezierPath.FromOval(new RectangleF(10.5f, 2.5f, 25, 5)); color4.SetFill(); oval2Path.Fill(); ////// Oval 2 Inner Shadow var oval2BorderRect = oval2Path.Bounds; oval2BorderRect.Inflate(shadowBlurRadius, shadowBlurRadius); oval2BorderRect.Offset(-shadowOffset.Width, -shadowOffset.Height); oval2BorderRect = RectangleF.Union(oval2BorderRect, oval2Path.Bounds); oval2BorderRect.Inflate(1, 1); var oval2NegativePath = UIBezierPath.FromRect(oval2BorderRect); oval2NegativePath.AppendPath(oval2Path); oval2NegativePath.UsesEvenOddFillRule = true; context.SaveState(); { var xOffset = shadowOffset.Width + (float)Math.Round(oval2BorderRect.Width); var yOffset = shadowOffset.Height; context.SetShadowWithColor( new SizeF(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)), shadowBlurRadius, shadow); oval2Path.AddClip(); var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(oval2BorderRect.Width), 0); oval2NegativePath.ApplyTransform(transform); UIColor.Gray.SetFill(); oval2NegativePath.Fill(); } context.RestoreState(); color4.SetStroke(); oval2Path.LineWidth = 1; oval2Path.Stroke(); } // END PAINTCODE } var converted = UIGraphics.GetImageFromCurrentImageContext (); UIGraphics.EndImageContext (); return converted; }
public override void TouchesMoved (MonoTouch.Foundation.NSSet touches, UIEvent evt) { if (!Enabled) return; Editing = true; var touch = touches.AnyObject as UITouch; var p = touch.LocationInView (this); ctr++; pts [ctr] = p; if (ctr == 4) { pts[3] = new PointF((pts[2].X + pts[4].X)/2.0f, (pts[2].Y + pts[4].Y)/2.0f); // move the endpoint to the middle of the line joining the second control point of the first Bezier segment and the first control point of the second Bezier segment var path = new UIBezierPath (); path.LineWidth = lineThickness; path.MoveTo(pts[0]); path.AddCurveToPoint(pts[3], pts[1], pts[2]); // add a cubic Bezier from pt[0] to pt[3], with control points pt[1] and pt[2] paths.Last().Add (path); this.SetNeedsDisplay(); // replace points and get ready to handle the next segment pts[0] = pts[3]; pts[1] = pts[4]; ctr = 1; } }
public static NSArray PSPDFBezierPathGetPoints(UIBezierPath path) { return new NSArray(_PSPDFBezierPathGetPoints(path.Handle)); }
void drawBorder() { UIBezierPath bezierPath = new UIBezierPath(); bezierPath.MoveTo(new PointF(22.09f, 10.97f)); bezierPath.AddCurveToPoint(new PointF(14.31f, 14.18f), new PointF(19.15f, 10.97f), new PointF(16.39f, 12.11f)); bezierPath.AddCurveToPoint(new PointF(11.09f, 21.94f), new PointF(12.24f, 16.25f), new PointF(11.09f, 19.01f)); bezierPath.AddCurveToPoint(new PointF(14.31f, 29.7f), new PointF(11.09f, 24.88f), new PointF(12.24f, 27.62f)); bezierPath.AddCurveToPoint(new PointF(22.09f, 32.91f), new PointF(16.39f, 31.77f), new PointF(19.16f, 32.91f)); bezierPath.AddCurveToPoint(new PointF(29.87f, 29.7f), new PointF(25.04f, 32.91f), new PointF(27.8f, 31.77f)); bezierPath.AddCurveToPoint(new PointF(33.09f, 21.94f), new PointF(31.95f, 27.63f), new PointF(33.09f, 24.88f)); bezierPath.AddCurveToPoint(new PointF(29.87f, 14.18f), new PointF(33.09f, 19.01f), new PointF(31.95f, 16.26f)); bezierPath.AddCurveToPoint(new PointF(22.09f, 10.97f), new PointF(27.8f, 12.11f), new PointF(25.04f, 10.97f)); bezierPath.ClosePath(); bezierPath.MoveTo(new PointF(22.09f, 31.09f)); bezierPath.AddCurveToPoint(new PointF(12.92f, 21.94f), new PointF(17.02f, 31.09f), new PointF(12.92f, 26.98f)); bezierPath.AddCurveToPoint(new PointF(22.09f, 12.8f), new PointF(12.92f, 16.9f), new PointF(17.02f, 12.8f)); bezierPath.AddCurveToPoint(new PointF(31.26f, 21.94f), new PointF(27.17f, 12.8f), new PointF(31.26f, 16.9f)); bezierPath.AddCurveToPoint(new PointF(22.09f, 31.09f), new PointF(31.26f, 26.98f), new PointF(27.17f, 31.09f)); bezierPath.ClosePath(); bezierPath.MiterLimit = 4; UIColor.LightGray.ColorWithAlpha(.5f).SetFill(); bezierPath.Fill(); //// Bezier 2 Drawing UIBezierPath bezier2Path = new UIBezierPath(); bezier2Path.MoveTo(new PointF(41.31f, 17.37f)); bezier2Path.AddLineTo(new PointF(39.57f, 17.37f)); bezier2Path.AddCurveToPoint(new PointF(36.95f, 14.72f), new PointF(38.14f, 17.37f), new PointF(36.95f, 16.18f)); bezier2Path.AddCurveToPoint(new PointF(37.81f, 12.85f), new PointF(36.95f, 13.99f), new PointF(37.26f, 13.34f)); bezier2Path.AddLineTo(new PointF(38.94f, 11.75f)); bezier2Path.AddCurveToPoint(new PointF(38.94f, 7.76f), new PointF(40.05f, 10.65f), new PointF(40.05f, 8.87f)); bezier2Path.AddLineTo(new PointF(36.38f, 5.23f)); bezier2Path.AddCurveToPoint(new PointF(34.38f, 4.43f), new PointF(35.88f, 4.73f), new PointF(35.13f, 4.43f)); bezier2Path.AddCurveToPoint(new PointF(32.37f, 5.23f), new PointF(33.62f, 4.43f), new PointF(32.89f, 4.73f)); bezier2Path.AddLineTo(new PointF(31.29f, 6.31f)); bezier2Path.AddCurveToPoint(new PointF(29.32f, 7.19f), new PointF(30.78f, 6.88f), new PointF(30.07f, 7.19f)); bezier2Path.AddCurveToPoint(new PointF(26.61f, 4.59f), new PointF(27.86f, 7.19f), new PointF(26.61f, 6)); bezier2Path.AddLineTo(new PointF(26.61f, 2.87f)); bezier2Path.AddCurveToPoint(new PointF(23.86f, 0), new PointF(26.61f, 1.33f), new PointF(25.4f, 0)); bezier2Path.AddLineTo(new PointF(20.37f, 0)); bezier2Path.AddCurveToPoint(new PointF(17.53f, 2.87f), new PointF(18.79f, 0), new PointF(17.53f, 1.31f)); bezier2Path.AddLineTo(new PointF(17.53f, 4.61f)); bezier2Path.AddCurveToPoint(new PointF(14.85f, 7.2f), new PointF(17.53f, 6.01f), new PointF(16.32f, 7.2f)); bezier2Path.AddCurveToPoint(new PointF(12.95f, 6.35f), new PointF(14.12f, 7.2f), new PointF(13.45f, 6.89f)); bezier2Path.AddLineTo(new PointF(11.84f, 5.26f)); bezier2Path.AddCurveToPoint(new PointF(9.83f, 4.46f), new PointF(11.33f, 4.74f), new PointF(10.59f, 4.46f)); bezier2Path.AddCurveToPoint(new PointF(7.83f, 5.26f), new PointF(9.07f, 4.46f), new PointF(8.34f, 4.75f)); bezier2Path.AddLineTo(new PointF(5.27f, 7.77f)); bezier2Path.AddCurveToPoint(new PointF(5.27f, 11.75f), new PointF(4.17f, 8.87f), new PointF(4.17f, 10.66f)); bezier2Path.AddLineTo(new PointF(6.35f, 12.82f)); bezier2Path.AddCurveToPoint(new PointF(7.24f, 14.73f), new PointF(6.92f, 13.34f), new PointF(7.24f, 13.99f)); bezier2Path.AddCurveToPoint(new PointF(4.63f, 17.38f), new PointF(7.24f, 16.19f), new PointF(6.05f, 17.38f)); bezier2Path.AddLineTo(new PointF(2.89f, 17.38f)); bezier2Path.AddCurveToPoint(new PointF(0, 20.21f), new PointF(1.32f, 17.37f), new PointF(0, 18.65f)); bezier2Path.AddLineTo(new PointF(0, 21.94f)); bezier2Path.AddLineTo(new PointF(0, 23.68f)); bezier2Path.AddCurveToPoint(new PointF(2.89f, 26.51f), new PointF(0, 25.22f), new PointF(1.32f, 26.51f)); bezier2Path.AddLineTo(new PointF(4.63f, 26.51f)); bezier2Path.AddCurveToPoint(new PointF(7.24f, 29.17f), new PointF(6.05f, 26.51f), new PointF(7.24f, 27.7f)); bezier2Path.AddCurveToPoint(new PointF(6.35f, 31.09f), new PointF(7.24f, 29.9f), new PointF(6.92f, 30.57f)); bezier2Path.AddLineTo(new PointF(5.27f, 32.14f)); bezier2Path.AddCurveToPoint(new PointF(5.27f, 36.11f), new PointF(4.17f, 33.23f), new PointF(4.17f, 35.02f)); bezier2Path.AddLineTo(new PointF(7.83f, 38.65f)); bezier2Path.AddCurveToPoint(new PointF(9.83f, 39.45f), new PointF(8.33f, 39.17f), new PointF(9.07f, 39.45f)); bezier2Path.AddCurveToPoint(new PointF(11.84f, 38.65f), new PointF(10.59f, 39.45f), new PointF(11.32f, 39.15f)); bezier2Path.AddLineTo(new PointF(12.95f, 37.55f)); bezier2Path.AddCurveToPoint(new PointF(14.84f, 36.71f), new PointF(13.43f, 37.02f), new PointF(14.11f, 36.71f)); bezier2Path.AddCurveToPoint(new PointF(17.52f, 39.3f), new PointF(16.31f, 36.71f), new PointF(17.52f, 37.9f)); bezier2Path.AddLineTo(new PointF(17.52f, 41.04f)); bezier2Path.AddCurveToPoint(new PointF(20.35f, 43.91f), new PointF(17.52f, 42.58f), new PointF(18.78f, 43.91f)); bezier2Path.AddLineTo(new PointF(23.83f, 43.91f)); bezier2Path.AddCurveToPoint(new PointF(26.69f, 41.04f), new PointF(25.39f, 43.91f), new PointF(26.69f, 42.59f)); bezier2Path.AddLineTo(new PointF(26.69f, 39.3f)); bezier2Path.AddCurveToPoint(new PointF(29.36f, 36.71f), new PointF(26.69f, 37.9f), new PointF(27.89f, 36.71f)); bezier2Path.AddCurveToPoint(new PointF(31.29f, 37.59f), new PointF(30.09f, 36.71f), new PointF(30.77f, 37.03f)); bezier2Path.AddLineTo(new PointF(32.37f, 38.66f)); bezier2Path.AddCurveToPoint(new PointF(34.38f, 39.46f), new PointF(32.89f, 39.17f), new PointF(33.62f, 39.46f)); bezier2Path.AddCurveToPoint(new PointF(36.38f, 38.66f), new PointF(35.13f, 39.46f), new PointF(35.86f, 39.17f)); bezier2Path.AddLineTo(new PointF(38.94f, 36.13f)); bezier2Path.AddCurveToPoint(new PointF(38.94f, 32.14f), new PointF(40.04f, 35.03f), new PointF(40.04f, 33.23f)); bezier2Path.AddLineTo(new PointF(37.81f, 31.04f)); bezier2Path.AddCurveToPoint(new PointF(36.95f, 29.13f), new PointF(37.26f, 30.55f), new PointF(36.95f, 29.85f)); bezier2Path.AddCurveToPoint(new PointF(39.57f, 26.43f), new PointF(36.95f, 27.67f), new PointF(38.14f, 26.43f)); bezier2Path.AddLineTo(new PointF(41.31f, 26.43f)); bezier2Path.AddCurveToPoint(new PointF(43.98f, 23.7f), new PointF(42.87f, 26.43f), new PointF(43.98f, 25.26f)); bezier2Path.AddLineTo(new PointF(43.98f, 21.94f)); bezier2Path.AddLineTo(new PointF(43.98f, 20.21f)); bezier2Path.AddCurveToPoint(new PointF(41.31f, 17.37f), new PointF(43.98f, 18.65f), new PointF(42.87f, 17.37f)); bezier2Path.ClosePath(); bezier2Path.MoveTo(new PointF(42.17f, 21.94f)); bezier2Path.AddLineTo(new PointF(42.17f, 23.67f)); bezier2Path.AddCurveToPoint(new PointF(41.33f, 24.57f), new PointF(42.17f, 24.15f), new PointF(41.9f, 24.57f)); bezier2Path.AddLineTo(new PointF(39.59f, 24.57f)); bezier2Path.AddCurveToPoint(new PointF(36.44f, 25.94f), new PointF(38.41f, 24.57f), new PointF(37.29f, 25.07f)); bezier2Path.AddCurveToPoint(new PointF(35.14f, 29.12f), new PointF(35.6f, 26.8f), new PointF(35.14f, 27.93f)); bezier2Path.AddCurveToPoint(new PointF(36.57f, 32.34f), new PointF(35.14f, 30.35f), new PointF(35.65f, 31.5f)); bezier2Path.AddLineTo(new PointF(37.66f, 33.42f)); bezier2Path.AddCurveToPoint(new PointF(37.66f, 34.82f), new PointF(38.04f, 33.81f), new PointF(38.04f, 34.45f)); bezier2Path.AddLineTo(new PointF(35.11f, 37.36f)); bezier2Path.AddCurveToPoint(new PointF(34.39f, 37.63f), new PointF(34.92f, 37.53f), new PointF(34.66f, 37.63f)); bezier2Path.AddCurveToPoint(new PointF(33.66f, 37.36f), new PointF(34.11f, 37.63f), new PointF(33.84f, 37.53f)); bezier2Path.AddLineTo(new PointF(32.62f, 36.32f)); bezier2Path.AddCurveToPoint(new PointF(29.36f, 34.88f), new PointF(31.74f, 35.39f), new PointF(30.58f, 34.88f)); bezier2Path.AddCurveToPoint(new PointF(26.21f, 36.16f), new PointF(28.16f, 34.88f), new PointF(27.06f, 35.34f)); bezier2Path.AddCurveToPoint(new PointF(24.88f, 39.3f), new PointF(25.33f, 37.01f), new PointF(24.88f, 38.11f)); bezier2Path.AddLineTo(new PointF(24.88f, 41.04f)); bezier2Path.AddCurveToPoint(new PointF(23.86f, 42.08f), new PointF(24.88f, 41.6f), new PointF(24.38f, 42.08f)); bezier2Path.AddLineTo(new PointF(20.37f, 42.08f)); bezier2Path.AddCurveToPoint(new PointF(19.38f, 41.04f), new PointF(19.85f, 42.08f), new PointF(19.38f, 41.6f)); bezier2Path.AddLineTo(new PointF(19.38f, 39.3f)); bezier2Path.AddCurveToPoint(new PointF(18.04f, 36.16f), new PointF(19.38f, 38.13f), new PointF(18.91f, 37.01f)); bezier2Path.AddCurveToPoint(new PointF(14.87f, 34.88f), new PointF(17.18f, 35.34f), new PointF(16.05f, 34.88f)); bezier2Path.AddCurveToPoint(new PointF(11.65f, 36.3f), new PointF(13.66f, 34.88f), new PointF(12.49f, 35.39f)); bezier2Path.AddLineTo(new PointF(10.59f, 37.36f)); bezier2Path.AddCurveToPoint(new PointF(9.87f, 37.63f), new PointF(10.4f, 37.53f), new PointF(10.14f, 37.63f)); bezier2Path.AddCurveToPoint(new PointF(9.17f, 37.38f), new PointF(9.59f, 37.63f), new PointF(9.32f, 37.54f)); bezier2Path.AddLineTo(new PointF(9.16f, 37.37f)); bezier2Path.AddLineTo(new PointF(9.14f, 37.36f)); bezier2Path.AddLineTo(new PointF(6.59f, 34.82f)); bezier2Path.AddCurveToPoint(new PointF(6.59f, 33.43f), new PointF(6.21f, 34.45f), new PointF(6.21f, 33.82f)); bezier2Path.AddLineTo(new PointF(7.63f, 32.4f)); bezier2Path.AddCurveToPoint(new PointF(9.09f, 29.14f), new PointF(8.57f, 31.53f), new PointF(9.09f, 30.38f)); bezier2Path.AddCurveToPoint(new PointF(7.79f, 26.01f), new PointF(9.09f, 27.95f), new PointF(8.63f, 26.87f)); bezier2Path.AddCurveToPoint(new PointF(4.64f, 24.7f), new PointF(6.94f, 25.14f), new PointF(5.82f, 24.7f)); bezier2Path.AddLineTo(new PointF(2.89f, 24.7f)); bezier2Path.AddCurveToPoint(new PointF(1.83f, 23.69f), new PointF(2.31f, 24.7f), new PointF(1.83f, 24.21f)); bezier2Path.AddLineTo(new PointF(1.83f, 21.94f)); bezier2Path.AddLineTo(new PointF(1.83f, 20.21f)); bezier2Path.AddCurveToPoint(new PointF(2.89f, 19.2f), new PointF(1.83f, 19.69f), new PointF(2.31f, 19.2f)); bezier2Path.AddLineTo(new PointF(4.63f, 19.2f)); bezier2Path.AddCurveToPoint(new PointF(7.78f, 17.89f), new PointF(5.81f, 19.2f), new PointF(6.93f, 18.75f)); bezier2Path.AddCurveToPoint(new PointF(9.08f, 14.74f), new PointF(8.62f, 17.03f), new PointF(9.08f, 15.92f)); bezier2Path.AddCurveToPoint(new PointF(7.62f, 11.5f), new PointF(9.08f, 13.51f), new PointF(8.56f, 12.35f)); bezier2Path.AddLineTo(new PointF(6.57f, 10.46f)); bezier2Path.AddCurveToPoint(new PointF(6.28f, 9.76f), new PointF(6.31f, 10.21f), new PointF(6.28f, 9.92f)); bezier2Path.AddCurveToPoint(new PointF(6.57f, 9.06f), new PointF(6.28f, 9.61f), new PointF(6.31f, 9.31f)); bezier2Path.AddLineTo(new PointF(9.11f, 6.54f)); bezier2Path.AddCurveToPoint(new PointF(9.83f, 6.26f), new PointF(9.29f, 6.37f), new PointF(9.56f, 6.26f)); bezier2Path.AddCurveToPoint(new PointF(10.53f, 6.51f), new PointF(10.11f, 6.26f), new PointF(10.38f, 6.35f)); bezier2Path.AddLineTo(new PointF(10.54f, 6.53f)); bezier2Path.AddLineTo(new PointF(10.55f, 6.54f)); bezier2Path.AddLineTo(new PointF(11.63f, 7.61f)); bezier2Path.AddCurveToPoint(new PointF(14.85f, 9.03f), new PointF(12.48f, 8.53f), new PointF(13.62f, 9.03f)); bezier2Path.AddCurveToPoint(new PointF(18.01f, 7.75f), new PointF(16.04f, 9.03f), new PointF(17.15f, 8.57f)); bezier2Path.AddCurveToPoint(new PointF(19.36f, 4.61f), new PointF(18.88f, 6.9f), new PointF(19.36f, 5.79f)); bezier2Path.AddLineTo(new PointF(19.36f, 2.87f)); bezier2Path.AddCurveToPoint(new PointF(20.34f, 1.83f), new PointF(19.36f, 2.31f), new PointF(19.82f, 1.83f)); bezier2Path.AddLineTo(new PointF(23.83f, 1.83f)); bezier2Path.AddCurveToPoint(new PointF(24.75f, 2.87f), new PointF(24.35f, 1.83f), new PointF(24.75f, 2.31f)); bezier2Path.AddLineTo(new PointF(24.75f, 4.61f)); bezier2Path.AddCurveToPoint(new PointF(26.12f, 7.75f), new PointF(24.75f, 5.78f), new PointF(25.25f, 6.9f)); bezier2Path.AddCurveToPoint(new PointF(29.31f, 9.03f), new PointF(26.98f, 8.57f), new PointF(28.12f, 9.03f)); bezier2Path.AddCurveToPoint(new PointF(32.59f, 7.59f), new PointF(30.55f, 9.03f), new PointF(31.72f, 8.51f)); bezier2Path.AddLineTo(new PointF(33.63f, 6.55f)); bezier2Path.AddCurveToPoint(new PointF(34.35f, 6.27f), new PointF(33.81f, 6.38f), new PointF(34.08f, 6.27f)); bezier2Path.AddCurveToPoint(new PointF(35.07f, 6.54f), new PointF(34.63f, 6.27f), new PointF(34.9f, 6.38f)); bezier2Path.AddLineTo(new PointF(37.63f, 9.06f)); bezier2Path.AddCurveToPoint(new PointF(37.93f, 9.76f), new PointF(37.81f, 9.25f), new PointF(37.93f, 9.5f)); bezier2Path.AddCurveToPoint(new PointF(37.64f, 10.46f), new PointF(37.93f, 10.02f), new PointF(37.82f, 10.27f)); bezier2Path.AddLineTo(new PointF(36.55f, 11.53f)); bezier2Path.AddCurveToPoint(new PointF(35.12f, 14.75f), new PointF(35.64f, 12.38f), new PointF(35.12f, 13.52f)); bezier2Path.AddCurveToPoint(new PointF(36.41f, 17.89f), new PointF(35.12f, 15.94f), new PointF(35.58f, 17.03f)); bezier2Path.AddCurveToPoint(new PointF(39.57f, 19.2f), new PointF(37.26f, 18.75f), new PointF(38.39f, 19.2f)); bezier2Path.AddLineTo(new PointF(41.31f, 19.2f)); bezier2Path.AddCurveToPoint(new PointF(42.17f, 20.23f), new PointF(41.93f, 19.2f), new PointF(42.16f, 19.77f)); bezier2Path.AddLineTo(new PointF(42.17f, 21.94f)); bezier2Path.ClosePath(); bezier2Path.MiterLimit = 4; UIColor.LightGray.ColorWithAlpha(.5f).SetFill(); bezier2Path.Fill(); }
public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, UIEvent evt) { //Create a new path and set the options. currentPath = UIBezierPath.Create (); currentPath.LineWidth = StrokeWidth; currentPath.LineJoinStyle = CGLineJoin.Round; currentPoints.Clear (); UITouch touch = touches.AnyObject as UITouch; //Obtain the location of the touch, move the path to that position and add it to the //current_points array. PointF touchLocation = touch.LocationInView (this); currentPath.MoveTo (touchLocation); currentPoints.Add (touchLocation); resetBounds (touchLocation); btnClear.Hidden = false; }