/// <summary> /// Draws the map rectangle. /// </summary> /// <param name="mapRect">Map rectangle.</param> /// <param name="zoomScale">Zoom scale.</param> /// <param name="context"> Graphics context.</param> public override void DrawMapRect(MKMapRect mapRect, nfloat zoomScale, CGContext context) { base.DrawMapRect(mapRect, zoomScale, context); var multiPolygons = (MultiPolygon)this.polygonOverlay; foreach (var item in multiPolygons.Polygons) { var path = new CGPath(); this.InvokeOnMainThread(() => { path = PolyPath(item.Polygon); }); if (path != null) { context.SetFillColor(item.FillColor); context.BeginPath(); context.AddPath(path); context.DrawPath(CGPathDrawingMode.EOFill); if (item.DrawOutlines) { context.BeginPath(); context.AddPath(path); context.StrokePath(); } } } }
void FillRoundedRect(RectangleF rect, CGContext context) { float radius = 10.0f; context.BeginPath(); //context.SetGrayFillColor (0.0f, this.Opacity); context.MoveTo(rect.GetMinX() + radius, rect.GetMinY()); context.AddArc(rect.GetMaxX() - radius, rect.GetMinY() + radius, radius, (float)(3 * Math.PI / 2), 0f, false); context.AddArc(rect.GetMaxX() - radius, rect.GetMaxY() - radius, radius, 0, (float)(Math.PI / 2), false); context.AddArc(rect.GetMinX() + radius, rect.GetMaxY() - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false); context.AddArc(rect.GetMinX() + radius, rect.GetMinY() + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false); context.ClosePath(); context.SetFillColorWithColor(this.RectangleColor.CGColor); context.FillPath(); context.SetStrokeColorWithColor(RectangleBorderColor.CGColor); context.BeginPath(); //context.SetGrayFillColor (0.0f, this.Opacity); context.MoveTo(rect.GetMinX() + radius, rect.GetMinY()); context.AddArc(rect.GetMaxX() - radius, rect.GetMinY() + radius, radius, (float)(3 * Math.PI / 2), 0f, false); context.AddArc(rect.GetMaxX() - radius, rect.GetMaxY() - radius, radius, 0, (float)(Math.PI / 2), false); context.AddArc(rect.GetMinX() + radius, rect.GetMaxY() - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false); context.AddArc(rect.GetMinX() + radius, rect.GetMinY() + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false); context.ClosePath(); context.StrokePath(); }
// // Helper function to generate shadow // private void GenerateShapeShadow(CGContext context, UIBezierPath shapeObject, nfloat xOffset, nfloat yOffset, nfloat blurValue, CGBlendMode blendingMode, UIColor shadowColor, nfloat borderWidth, int borderPosition, nfloat iWidth, nfloat iHeight) { CGPoint basePoint; CGPoint offsetPoint; CGSize calculatedShadowOffset; nfloat calculatedShadowBlur; CGPoint constPointZero; constPointZero = new CGPoint(0, 0); basePoint = baseTransform.TransformPoint(context.PointToDeviceSpace(constPointZero)); offsetPoint = baseTransform.TransformPoint(context.PointToDeviceSpace(new CGPoint(xOffset, yOffset))); calculatedShadowOffset = new CGSize(offsetPoint.X - basePoint.X, offsetPoint.Y - basePoint.Y); if (blurValue == 0) { calculatedShadowBlur = 0; } else { calculatedShadowBlur = Hypot(calculatedShadowOffset.Width, calculatedShadowOffset.Height) / blurValue; } context.SetShadow(calculatedShadowOffset, calculatedShadowBlur, shadowColor.CGColor); context.SetBlendMode(blendingMode); context.BeginTransparencyLayer(null); UIColor.Black.SetFill(); shapeObject.Fill(); if (borderWidth > 0) { if (borderPosition == 0) { context.SaveState(); shapeObject.LineWidth = borderWidth; UIColor.Black.SetStroke(); shapeObject.Stroke(); context.RestoreState(); } if (borderPosition == 1) { context.BeginPath(); context.AddPath(shapeObject.CGPath); context.EOClip(); } if (borderPosition == 2) { context.BeginPath(); context.AddPath(shapeObject.CGPath); context.AddRect(RectangleFExtensions.Inset(shapeObject.Bounds, iWidth, iHeight)); context.EOClip(); } } context.EndTransparencyLayer(); }
public override void DrawLayer(CALayer layer, CGContext context) { //layer.Frame = new CGRect(0,0,ImageView.Image.Size.Width,ImageView.Image.Size.Height); //var context=UIGraphics.GetCurrentContext(); float kEdgeInset = 20; float kLineLength = 20; float kTopOffset = 20; float kBottomOffset = 50; RectangleF layerFrame = layer.Frame; context.BeginPath(); context.SetLineWidth(5); context.MoveTo(kEdgeInset + kLineLength, kEdgeInset * 2); context.AddLineToPoint(kEdgeInset, kEdgeInset * 2); context.AddLineToPoint(kEdgeInset, kEdgeInset * 2 + kEdgeInset); //context.ClosePath (); //UIColor.White.SetStroke (); context.SetStrokeColorWithColor(UIColor.White.CGColor); context.DrawPath(CGPathDrawingMode.Stroke); context.BeginPath(); context.SetLineWidth(5); context.MoveTo(kEdgeInset, layerFrame.Size.Height - kBottomOffset - kEdgeInset); context.AddLineToPoint(kEdgeInset, layerFrame.Size.Height - kBottomOffset); context.AddLineToPoint(kLineLength + kEdgeInset, layerFrame.Size.Height - kBottomOffset); //context.ClosePath (); //UIColor.White.SetStroke (); //context.SetStrokeColorWithColor (UIColor.White.CGColor); context.DrawPath(CGPathDrawingMode.Stroke); //context.SetStrokeColorWithColor (UIColor.White.CGColor); context.DrawPath(CGPathDrawingMode.Stroke); context.BeginPath(); context.SetLineWidth(5); context.MoveTo(layerFrame.Width - kEdgeInset - kLineLength, kEdgeInset * 2); context.AddLineToPoint(layerFrame.Width - kEdgeInset, kEdgeInset * 2); context.AddLineToPoint(layerFrame.Width - kEdgeInset, kEdgeInset * 2 + kTopOffset); context.DrawPath(CGPathDrawingMode.Stroke); context.BeginPath(); context.SetLineWidth(5); context.MoveTo(layerFrame.Width - kEdgeInset, layerFrame.Height - kBottomOffset - kEdgeInset); context.AddLineToPoint(layerFrame.Width - kEdgeInset, layerFrame.Height - kBottomOffset); context.AddLineToPoint(layerFrame.Width - kEdgeInset * 2, layerFrame.Height - kBottomOffset); context.DrawPath(CGPathDrawingMode.Stroke); //layer.BackgroundColor = UIColor.Green.CGColor; layer.BorderWidth = 2.0f; //layer.BorderColor = UIColor.White.CGColor; }
private void DrawCurrentTouch(CGContext ctx) { if (mCurrTouch == PointF.Empty) { return; } var parentDIV = (DrawingImageView)Superview; var grandParentDISV = (DrawingImageScrollView)parentDIV.Superview; var zoomScale = grandParentDISV.ZoomScale; // circle try { ctx.SaveState(); ctx.BeginPath(); ctx.SetStrokeColorWithColor(LineColor); ctx.SetLineWidth(9f / zoomScale); var rad = CurrentTouchRadius / zoomScale; ctx.AddArc(mCurrTouch.X, mCurrTouch.Y, rad, 0.0f, 2.0f * (float)Math.PI, true); } finally { ctx.StrokePath(); ctx.RestoreState(); } // crosshairs try { ctx.SaveState(); ctx.BeginPath(); ctx.SetStrokeColorWithColor(LineColor); ctx.SetLineWidth(1f / zoomScale); // horizontal line ctx.MoveTo(0f, mCurrTouch.Y); ctx.AddLineToPoint(Frame.Right, mCurrTouch.Y); // vertical line ctx.MoveTo(mCurrTouch.X, 0f); ctx.AddLineToPoint(mCurrTouch.X, Frame.Bottom); } finally { ctx.StrokePath(); ctx.RestoreState(); } }
public void FillPath(Color color, GraphicsPath path) { StartDrawing(); if (!Flipped) { context.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, ViewHeight)); } context.BeginPath(); context.AddPath(path.ControlObject as CGPath); context.ClosePath(); context.SetFillColor(Generator.Convert(color)); context.FillPath(); EndDrawing(); }
public void DrawPolyline(MKPolyline polygon,MKMapRect mapRect, float zoomScale, CGContext context) { CGPath path = this.polyPath (polygon,mapRect,zoomScale,context); if (path != null) { this.ApplyFillProperties (context, zoomScale); context.BeginPath (); context.AddPath (path); context.DrawPath (CGPathDrawingMode.Stroke); this.ApplyStrokeProperties (context, zoomScale); context.BeginPath (); context.AddPath (path); context.StrokePath (); } }
public override void Draw(RectangleF rect) { base.Draw(rect); if (!IsSelected) { return; } CGContext context = UIGraphics.GetCurrentContext(); context.SaveState(); context.SetFillColorWithColor(new UIColor(0, 0, 0, 0.5f).CGColor); context.BeginPath(); // top border context.AddRect(new RectangleF(0, 0, Frame.Width, 4)); // left border context.AddRect(new RectangleF(0, 0, 4, Frame.Height)); // right border context.AddRect(new RectangleF(Frame.Width - 4, 0, 4, Frame.Height)); // bottom border context.AddRect(new RectangleF(0, Frame.Height - 4, Frame.Width, 4)); context.ClosePath(); context.FillPath(); context.RestoreState(); context.SetBlendMode(MonoTouch.CoreGraphics.CGBlendMode.Clear); }
public override void TouchesMoved(NSSet touches, UIEvent evt) { if (_signingMode) { mouseSwiped = true; UITouch touch = (UITouch)touches.AnyObject; CGPoint currentPoint = touch.LocationInView(sigCanvas); // Console.WriteLine("Event fired: TouchesMoved: "+currentPoint.ToString ()); UIGraphics.BeginImageContext(sigCanvas.Frame.Size); _sig.Image.Draw(new CGRect(0, 0, sigCanvas.Frame.Size.Width, sigCanvas.Frame.Size.Height)); CGContext cgc = UIGraphics.GetCurrentContext(); cgc.SetLineCap(CGLineCap.Round); cgc.SetLineWidth(5); cgc.SetStrokeColor(0, 0, 0, 1); cgc.BeginPath(); cgc.MoveTo(lastPoint.X, lastPoint.Y); cgc.AddLineToPoint(currentPoint.X, currentPoint.Y); cgc.StrokePath(); cgc.Flush(); _sig.Image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); cgc.Dispose(); lastPoint = currentPoint; mouseMoved++; if (mouseMoved == 10) { mouseMoved = 0; } } }
public void DrawInContext(CGContext context, bool usePreciseLocation) { LinePoint maybePriorPoint = null; foreach (var point in Points) { if (maybePriorPoint == null) { maybePriorPoint = point; continue; } var priorPoint = maybePriorPoint; var location = usePreciseLocation ? point.PreciseLocation : point.Location; var priorLocation = usePreciseLocation ? priorPoint.PreciseLocation : priorPoint.Location; context.BeginPath(); context.MoveTo(priorLocation.X, priorLocation.Y); context.AddLineToPoint(location.X, location.Y); context.SetStrokeColor(LineColor.CGColor); context.SetLineWidth(LineWidth); context.StrokePath(); maybePriorPoint = point; } }
public void DrawPolyline(MKPolyline polygon, MKMapRect mapRect, float zoomScale, CGContext context) { CGPath path = this.polyPath(polygon, mapRect, zoomScale, context); if (path != null) { this.ApplyFillProperties(context, zoomScale); context.BeginPath(); context.AddPath(path); context.DrawPath(CGPathDrawingMode.Stroke); this.ApplyStrokeProperties(context, zoomScale); context.BeginPath(); context.AddPath(path); context.StrokePath(); } }
// rect changes depending on if the whole view is being redrawn, or just a section public override void Draw(CGRect rect) { Console.WriteLine("Draw() Called"); base.Draw(rect); using (CGContext context = UIGraphics.GetCurrentContext()) { // fill the background with white // set fill color UIColor.White.SetFill(); //context.SetRGBFillColor (1, 1, 1, 1f); // paint context.FillRect(rect); // draw a rectangle using stroke rect UIColor.Blue.SetStroke(); context.StrokeRect(new CGRect(10, 10, 200, 100)); // draw a rectangle using a path context.BeginPath(); context.MoveTo(220, 10); context.AddLineToPoint(420, 10); context.AddLineToPoint(420, 110); context.AddLineToPoint(220, 110); context.ClosePath(); UIColor.DarkGray.SetFill(); context.DrawPath(CGPathDrawingMode.FillStroke); // draw a rectangle using a path CGPath rectPath = new CGPath(); rectPath.AddRect(new CGRect(new CGPoint(430, 10), new CGSize(200, 100))); context.AddPath(rectPath); context.DrawPath(CGPathDrawingMode.Stroke); } }
public override void Draw(CGRect bounds, CGContext context, UIView view) { var width = 0.5f / UIScreen.MainScreen.Scale; context.BeginPath(); context.SetLineWidth(width); context.SetStrokeColor(UIColor.FromRGB(150, 150, 154).CGColor); var x = bounds.Width / 2f - width; context.MoveTo(x, 0f); context.AddLineToPoint(x, bounds.Height); context.StrokePath(); var row = Value; var half = bounds.Height / 2; var halfText = _font.LineHeight / 2 + 1; row.Image1.Draw(new CGRect(15, half - 8f, 16f, 16f)); if (!string.IsNullOrEmpty(row.Text1)) { UIColor.Gray.SetColor(); new NSString(row.Text1).DrawString(new CGRect(36, half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation); } row.Image2.Draw(new CGRect(bounds.Width / 2 + 15, half - 8f, 16f, 16f)); if (!string.IsNullOrEmpty(row.Text2)) { UIColor.Gray.SetColor(); new NSString(row.Text2).DrawString(new CGRect(bounds.Width / 2 + 36, half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation); } }
public override void TouchesEnded(NSSet touches, UIEvent evt) { if (_signingMode) { // Console.WriteLine("Event fired: TouchesEnded: "+ lastPoint.ToString()); UITouch touch = (UITouch)touches.AnyObject; if (touch.TapCount == 3) // triple tap by user clears the signature field { _sig.Image = new UIImage(); _tabs._navWorkflow.RightButton.Enabled = false; return; } if (!mouseSwiped) { UIGraphics.BeginImageContext(sigCanvas.Frame.Size); _sig.Image.Draw(new CGRect(0, 0, sigCanvas.Frame.Size.Width, sigCanvas.Frame.Size.Height)); CGContext cgc = UIGraphics.GetCurrentContext(); cgc.SetLineCap(CGLineCap.Round); cgc.SetLineWidth(5); cgc.SetStrokeColor(0, 0, 0, 1); cgc.BeginPath(); cgc.MoveTo(lastPoint.X, lastPoint.Y); cgc.AddLineToPoint(lastPoint.X, lastPoint.Y); cgc.StrokePath(); cgc.Flush(); _sig.Image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); cgc.Dispose(); } } hasBeenSigned = true; }
private void DrawAudioMixTracks(CGRect bannerRect, CGRect rowRect, ref float runningTop) { bannerRect.Y = runningTop; CGContext context = UIGraphics.GetCurrentContext(); context.SetFillColor(1.00f, 1.00f, 1.00f, 1.00f); // white NSString compositionTitle = new NSString("AVAudioMix"); compositionTitle.DrawString(bannerRect, UIFont.PreferredCaption1); runningTop += (float)bannerRect.Height; foreach (List <CGPoint> mixTrack in audioMixTracks) { rowRect.Y = runningTop; CGRect rampRect = rowRect; rampRect.Width = (float)duration.Seconds * scaledDurationToWidth; rampRect = rampRect.Inset(3f, 3f); context.SetFillColor(0.55f, 0.02f, 0.02f, 1.00f); // darker red context.SetStrokeColor(0.87f, 0.10f, 0.10f, 1.00f); // brighter red context.SetLineWidth(2f); context.AddRect(rampRect); context.DrawPath(CGPathDrawingMode.FillStroke); context.BeginPath(); context.SetStrokeColor(0.95f, 0.68f, 0.09f, 1.00f); // yellow context.SetLineWidth(3f); bool firstPoint = true; foreach (CGPoint pointValue in mixTrack) { CGPoint timeVolumePoint = pointValue; CGPoint pointInRow = new CGPoint(); pointInRow.X = rampRect.X + timeVolumePoint.X * scaledDurationToWidth; pointInRow.Y = rampRect.Y + (0.9f - 0.8f * timeVolumePoint.Y) * rampRect.Height; pointInRow.X = (float)Math.Max(pointInRow.X, rampRect.GetMinX()); pointInRow.X = (float)Math.Min(pointInRow.X, rampRect.GetMaxX()); if (firstPoint) { context.MoveTo(pointInRow.X, pointInRow.Y); firstPoint = false; } else { context.AddLineToPoint(pointInRow.X, pointInRow.Y); } } context.StrokePath(); runningTop += (float)rowRect.Height; } runningTop += GapAfterRows; }
private void DrawRoundedRect(CGContext context, CGRect rect) { context.SaveState(); context.BeginPath(); context.SetFillColor(_badgeColor.CGColor); MakePath(context, rect); context.FillPath(); context.RestoreState(); }
void DrawBottomBorder(CGContext ctx, CGRect rect) { if (ViewInfo.BottomBorderThickness <= 0) { return; } ctx.SetStrokeColor(ViewInfo.BottomBorderColor.CGColor); ctx.SetLineWidth((nfloat)ViewInfo.BottomBorderThickness); ctx.BeginPath(); ctx.MoveTo(rect.GetMinX(), rect.GetMaxY()); ctx.AddLineToPoint(rect.GetMaxX(), rect.GetMaxY()); ctx.StrokePath(); }
private void FillRoundedRect(RectangleF rect, CGContext context) { float radius = 10.0f; context.BeginPath(); context.SetGrayFillColor(0.0f, Opacity); context.MoveTo(rect.GetMinX() + radius, rect.GetMinY()); context.AddArc(rect.GetMaxX() - radius, rect.GetMinY() + radius, radius, (float)(3 * Math.PI / 2), 0f, false); context.AddArc(rect.GetMaxX() - radius, rect.GetMaxY() - radius, radius, 0, (float)(Math.PI / 2), false); context.AddArc(rect.GetMinX() + radius, rect.GetMaxY() - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false); context.AddArc(rect.GetMinX() + radius, rect.GetMinY() + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false); context.ClosePath(); context.FillPath(); }
public override void DrawInContext(CGContext ctx) { base.DrawInContext(ctx); var bounds = Bounds; var c = new PointF(bounds.GetMidX(), bounds.GetMidY()); ctx.BeginPath(); ctx.MoveTo(c.X, c.Y); ctx.AddLineToPoint(bounds.Right, c.Y); ctx.AddArc(c.X, c.Y, bounds.Width / 2, (float)0, (float)Angle, false); ctx.AddLineToPoint(c.X, c.Y); ctx.SetFillColor(otherColor); ctx.FillPath(); ctx.BeginPath(); ctx.MoveTo(c.X, c.Y); ctx.AddLineToPoint(bounds.Right, c.Y); ctx.AddArc(c.X, c.Y, bounds.Width / 2, (float)0, (float)(1e-7 + Angle), true); ctx.AddLineToPoint(c.X, c.Y); ctx.SetFillColor(color); ctx.FillPath(); }
public override void Draw(CGRect rect) { CGContext ctx = UIGraphics.GetCurrentContext(); if (ViewInfo.LeftBorderThickness > 0) { ctx.SetStrokeColor(ViewInfo.LeftBorderColor.CGColor); ctx.SetLineWidth((nfloat)ViewInfo.LeftBorderThickness); ctx.BeginPath(); ctx.MoveTo(rect.GetMinX(), rect.GetMinY()); ctx.AddLineToPoint(rect.GetMinX(), rect.GetMaxY()); ctx.StrokePath(); } if (ViewInfo.BottomBorderThickness > 0) { ctx.SetStrokeColor(ViewInfo.BottomBorderColor.CGColor); ctx.SetLineWidth((nfloat)ViewInfo.BottomBorderThickness); ctx.BeginPath(); ctx.MoveTo(rect.GetMinX(), rect.GetMaxY()); ctx.AddLineToPoint(rect.GetMaxX(), rect.GetMaxY()); ctx.StrokePath(); } }
public override void Draw(CGRect rect) { CGRect viewBounds = Bounds; CGContext curContext = UIGraphics.GetCurrentContext(); var numberString = Value.ToString(TextFormat); CGSize numberSize = new NSString(numberString).StringSize(Font); using (CGPath badgePath = NewBadgePathForTextSize(numberSize)) { CGRect badgeRect = badgePath.PathBoundingBox; badgeRect.X = 0; badgeRect.Y = 0; badgeRect.Size = new SizeF((float)Math.Ceiling(badgeRect.Size.Width), (float)Math.Ceiling(badgeRect.Size.Height)); curContext.SaveState(); curContext.SetLineWidth(StrokeWidth); curContext.SetStrokeColor(StrokeColor.CGColor); curContext.SetFillColor(SubFillColor.CGColor); curContext.AddEllipseInRect(badgeRect); curContext.DrawPath(CGPathDrawingMode.Fill); curContext.SetFillColor(FillColor.CGColor); // Line stroke straddles the path, so we need to account for the outer portion badgeRect.Size = new CGSize(badgeRect.Size.Width + (float)Math.Ceiling(StrokeWidth / 2), badgeRect.Size.Height + (float)Math.Ceiling(StrokeWidth / 2)); CGPoint ctm = new PointF(0f, 0f); curContext.TranslateCTM(ctm.X, ctm.Y); curContext.BeginPath(); curContext.AddPath(badgePath); curContext.ClosePath(); curContext.DrawPath(CGPathDrawingMode.EOFill); curContext.RestoreState(); curContext.SaveState(); curContext.SetFillColor(TextColor.CGColor); CGPoint textPt = new CGPoint(ctm.X + ((badgeRect.Size.Width - numberSize.Width) / 2) + AdjustOffset.X, ctm.Y + ((badgeRect.Size.Height - numberSize.Height) / 2) + AdjustOffset.Y); curContext.RestoreState(); } }
public override void DrawInContext (CGContext ctx) { base.DrawInContext (ctx); var bounds = Bounds; var c = new PointF (bounds.GetMidX (), bounds.GetMidY ()); ctx.BeginPath (); ctx.MoveTo (c.X, c.Y); ctx.AddLineToPoint (bounds.Right, c.Y); ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)Angle, false); ctx.AddLineToPoint (c.X, c.Y); ctx.SetFillColor (otherColor); ctx.FillPath (); ctx.BeginPath (); ctx.MoveTo (c.X, c.Y); ctx.AddLineToPoint (bounds.Right, c.Y); ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)(1e-7 + Angle), true); ctx.AddLineToPoint (c.X, c.Y); ctx.SetFillColor (color); ctx.FillPath (); }
/// <summary> /// Draw the triangle /// </summary> /// <param name="rect">Rect.</param> public override void Draw(CGRect rect) { UIColor.Clear.SetColor(); UIGraphics.RectFill(rect); CGContext context = UIGraphics.GetCurrentContext(); context.BeginPath(); context.MoveTo(0.0f, 0.0f); context.AddLineToPoint(ENDGE_LENGTH, ENDGE_LENGTH); context.AddLineToPoint(ENDGE_LENGTH, 0.0f); context.ClosePath(); TriangleBackgroundColor.SetFill(); context.DrawPath(CGPathDrawingMode.Fill); AddSubview(ActionView); }
public override void Draw(RectangleF rect) { base.Draw(rect); CGContext context = UIGraphics.GetCurrentContext(); context.DrawPath(CGPathDrawingMode.FillStroke); //UIColor strokeColor = new UIColor (87.0f,108.0f,137.0f,1.0f) CGColor strokeColor = new CGColor(87f, 108f, 137f, 1f); context.SetStrokeColorWithColor(strokeColor); context.BeginPath(); context.MoveTo(0f, this.Bounds.Size.Height - 1); context.AddLineToPoint(this.Bounds.Size.Width, this.Bounds.Size.Height - 1); context.StrokePath(); }
public override void Draw(RectangleF bounds, CGContext context, UIView view) { context.BeginPath(); context.SetLineWidth(1.0f); context.SetStrokeColor(UIColor.FromRGB(199, 199, 205).CGColor); var x = (int)System.Math.Ceiling(bounds.Width / 2 - 0.5f); context.MoveTo(x, 0f); context.AddLineToPoint(x, bounds.Height); context.StrokePath(); /* * context.BeginPath(); * context.SetStrokeColor(UIColor.FromRGBA(250, 250, 250, 128).CGColor); * context.MoveTo(bounds.Width / 2 + 0.5f, 0); * context.AddLineToPoint(bounds.Width / 2 + 0.5f, bounds.Height); * context.StrokePath(); */ var row = Value; var half = bounds.Height / 2; var halfText = _font.LineHeight / 2 + 1; row.Image1.Draw(new RectangleF(15, half - 8f, 16f, 16f)); if (!string.IsNullOrEmpty(row.Text1)) { UIColor.Gray.SetColor(); view.DrawString(row.Text1, new RectangleF(36, half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation); } row.Image2.Draw(new RectangleF(bounds.Width / 2 + 15, half - 8f, 16f, 16f)); if (!string.IsNullOrEmpty(row.Text2)) { UIColor.Gray.SetColor(); view.DrawString(row.Text2, new RectangleF(bounds.Width / 2 + 36, half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation); } }
public override void Draw(RectangleF area) { if (this.data == null || this.data.Count() == 0) { base.Draw(area); return; } var color = LineColor.CGColor; if (color == null) { color = new CGColor(255, 255, 255); } CGContext context = UIGraphics.GetCurrentContext(); context.BeginPath(); context.SetStrokeColor(color); var d = this.data; float mx = this.max; float yscale = Bounds.Height / (mx - this.min); float xscale = Bounds.Width / 60; context.MoveTo(0, (mx - d[0].Value) * yscale); for (int i = 0; i < d.Count(); i++) { var telemetry = d[i]; var x = ((float)(telemetry.Timestamp - DateTime.UtcNow).TotalSeconds * xscale) + Bounds.Width; var y = (mx - telemetry.Value) * yscale; //Console.WriteLine("X:{0} , Y:{1}",x,y); context.AddLineToPoint(x, y); } context.DrawPath(CGPathDrawingMode.Stroke); }
/// <summary> /// Draw the triangle /// </summary> /// <param name="rect">Rect.</param> public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); NSGraphicsContext.GlobalSaveGraphicsState(); BackgroudColor.Set(); CGContext context = NSGraphicsContext.CurrentContext.GraphicsPort; context.BeginPath(); context.MoveTo(PUBLICATION_DOWN_WIDTH, PUBLICATION_DOWN_WIDTH); context.AddLineToPoint(PUBLICATION_DOWN_WIDTH, 0.0f); context.AddLineToPoint(0.0f, PUBLICATION_DOWN_WIDTH); context.AddLineToPoint(PUBLICATION_DOWN_WIDTH, PUBLICATION_DOWN_WIDTH); context.ClosePath(); context.DrawPath(CGPathDrawingMode.Fill); NSGraphicsContext.GlobalRestoreGraphicsState(); }
public override void Draw(RectangleF bounds, CGContext context, UIView view) { context.BeginPath(); context.SetLineWidth(1.0f); context.SetStrokeColor(UIColor.FromRGB(199, 199, 205).CGColor); var x = (int)System.Math.Ceiling(bounds.Width / 2 - 0.5f); context.MoveTo(x, 0f); context.AddLineToPoint(x, bounds.Height); context.StrokePath(); /* context.BeginPath(); context.SetStrokeColor(UIColor.FromRGBA(250, 250, 250, 128).CGColor); context.MoveTo(bounds.Width / 2 + 0.5f, 0); context.AddLineToPoint(bounds.Width / 2 + 0.5f, bounds.Height); context.StrokePath(); */ var row = Value; var half = bounds.Height / 2; var halfText = _font.LineHeight / 2 + 1; row.Image1.Draw(new RectangleF(15, half - 8f, 16f, 16f)); if (!string.IsNullOrEmpty(row.Text1)) { UIColor.Gray.SetColor(); view.DrawString(row.Text1, new RectangleF(36, half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation); } row.Image2.Draw(new RectangleF(bounds.Width / 2 + 15, half - 8f, 16f, 16f)); if (!string.IsNullOrEmpty(row.Text2)) { UIColor.Gray.SetColor(); view.DrawString(row.Text2, new RectangleF(bounds.Width / 2 + 36, half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation); } }
//does the actual coloring void DrawPoints(CGContext dctx) { var swatches = Swatches; var swatchslider = swatchSlider; dctx.BeginPath(); dctx.MoveTo(Points.First().X, Points.First().Y); dctx.SetLineWidth(swatchslider.Value); dctx.SetBlendMode(CGBlendMode.Normal); foreach (var crayon in Crayons) { if (crayon.Selected) { if (crayon.Name == "Eraser") { dctx.SetBlendMode(CGBlendMode.Clear); dctx.SetStrokeColor(UIColor.Clear.CGColor); } else { dctx.SetBlendMode(CGBlendMode.Normal); var swatchImg = colorSwatch(swatches[0], crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 1f); UIColor pattern = UIColor.FromPatternImage(swatchImg); dctx.SetStrokeColor(pattern.CGColor); } dctx.SetLineCap(CGLineCap.Round); dctx.SetLineJoin(CGLineJoin.Round); } } //set fill color with current crayons foreach (var point in Points) { dctx.AddLineToPoint(point.X, point.Y); } dctx.StrokePath(); }
//no use void DrawUpdateView() { if (BookInfo.DaysRemaining < 0) { NSColor.Red.Set(); } else { Utility.ColorWithRGB(0, 128, 252, 1.0f).Set(); } CGContext context = NSGraphicsContext.CurrentContext.GraphicsPort; context.BeginPath(); context.MoveTo(PUBLICATION_DOWN_ORGX, PUBLICATION_VIEW_HEIGHT); context.AddLineToPoint(PUBLICATION_COVER_WIDTH, PUBLICATION_DOWN_ORGY); context.AddLineToPoint(PUBLICATION_COVER_WIDTH, PUBLICATION_VIEW_HEIGHT); context.AddLineToPoint(PUBLICATION_DOWN_ORGX, PUBLICATION_VIEW_HEIGHT); context.ClosePath(); context.DrawPath(CGPathDrawingMode.Fill); }
public static void RoundRectPath(CGContext cr, CGRect rect, float[] cornerRadii) { if (cornerRadii == null || cornerRadii.Length != 4) { throw new ArgumentOutOfRangeException("cornerRadii", "cornerRadii count must be 4."); } cr.BeginPath(); float radius = cornerRadii[0]; cr.AddArc(rect.X + radius, rect.Y + radius, radius, (float)Math.PI, (float)(3.0f * Math.PI / 2.0f), false); radius = cornerRadii[1]; cr.AddArc(rect.X + rect.Width - radius, rect.Y + radius, radius, (float)(3.0f * Math.PI / 2.0f), 2.0f * (float)Math.PI, false); radius = cornerRadii[2]; cr.AddArc(rect.X + rect.Width - radius, rect.Y + rect.Height - radius, radius, (float)(2 * Math.PI), 5.0f * ((float)Math.PI / 2.0f), false); radius = cornerRadii[3]; cr.AddArc(rect.X + radius, rect.Y + rect.Height - radius, radius, (float)(5.0f * Math.PI / 2.0f), (float)(3.0f * Math.PI), false); cr.ClosePath(); }
public void Draw(CGContext ctx, RectangleF rect) { try { ctx.SaveState(); ctx.BeginPath(); ctx.SetLineWidth(LineWidth); ctx.SetStrokeColorWithColor(LineColor); ctx.SetLineCap(CGLineCap.Round); ctx.MoveTo(Start.X, Start.Y); var path = new CGPath(); path.AddLines(Points.ToArray()); ctx.AddPath(path); } finally { ctx.StrokePath(); ctx.RestoreState(); } }
void DrawArcInContext(CGContext context, PointF center, float radius, float startAngle, float endAngle, CGColor color, bool cgClockwise) { context.BeginPath(); context.MoveTo(center.X, center.Y); context.AddArc(center.X, center.Y, radius, startAngle, endAngle, cgClockwise); context.SetFillColor(color); context.FillPath(); }
//does the actual coloring void DrawPoints(CGContext dctx) { var swatches = Swatches; var swatchslider = swatchSlider; dctx.BeginPath (); dctx.MoveTo (Points.First().X, Points.First().Y); dctx.SetLineWidth (swatchslider.Value); dctx.SetBlendMode (CGBlendMode.Normal); foreach (var crayon in Crayons) { if(crayon.Selected) { if (crayon.Name == "Eraser") { dctx.SetBlendMode (CGBlendMode.Clear); dctx.SetStrokeColor (UIColor.Clear.CGColor); } else { dctx.SetBlendMode (CGBlendMode.Normal); var swatchImg = colorSwatch (swatches[0], crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 1f); UIColor pattern = UIColor.FromPatternImage(swatchImg); dctx.SetStrokeColor(pattern.CGColor); } dctx.SetLineCap (CGLineCap.Round); dctx.SetLineJoin (CGLineJoin.Round); } } //set fill color with current crayons foreach (var point in Points) { dctx.AddLineToPoint(point.X, point.Y); } dctx.StrokePath(); }
public override void Draw(CGRect rect) { var boxView = (RoundedStackLayout)Element; double sourceWidth = rect.Size.Width; double sourceHeight = rect.Size.Height; double desiredWidth = sourceWidth; double desiredHeight = sourceHeight; var topLeftCornerSize = boxView.CornerRadius; var topRightCornerSize = boxView.CornerRadius; var bottomLeftCornerSize = boxView.CornerRadius; var bottomRightCornerSize = boxView.CornerRadius; using (CGContext context = UIGraphics.GetCurrentContext()) { context.BeginPath(); using (var path = new UIBezierPath()) { // TopLeft if (boxView.CornersAttributes.HasFlag(CornerAttributes.TopLeftRounded)) { path.MoveTo(new CGPoint(0, topLeftCornerSize)); path.AddQuadCurveToPoint(new CGPoint(topLeftCornerSize, 0), new CGPoint(0, 0)); } else { path.MoveTo(new CGPoint(0, 0)); } // TopRight if (boxView.CornersAttributes.HasFlag(CornerAttributes.TopRightRounded)) { path.AddLineTo(new CGPoint(desiredWidth - topRightCornerSize, 0)); path.AddQuadCurveToPoint(new CGPoint(desiredWidth, topRightCornerSize), new CGPoint(desiredWidth, 0)); } else { path.AddLineTo(new CGPoint(desiredWidth, 0)); } // BottomRight if (boxView.CornersAttributes.HasFlag(CornerAttributes.BottomRightRounded)) { path.AddLineTo(new CGPoint(desiredWidth, desiredHeight - bottomRightCornerSize)); path.AddQuadCurveToPoint(new CGPoint(desiredWidth - bottomRightCornerSize, desiredHeight), new CGPoint(desiredWidth, desiredHeight)); } else { path.AddLineTo(new CGPoint(desiredWidth, desiredHeight)); } // BottomLeft if (boxView.CornersAttributes.HasFlag(CornerAttributes.BottomLeftRounded)) { path.AddLineTo(new CGPoint(bottomLeftCornerSize, desiredHeight)); path.AddQuadCurveToPoint(new CGPoint(0, desiredHeight - bottomLeftCornerSize), new CGPoint(0, desiredHeight)); } else { path.AddLineTo(new CGPoint(0, desiredHeight)); } boxView.BackgroundColor.ToUIColor().SetFill(); path.Fill(); path.ClosePath(); context.AddPath(path.CGPath); context.Clip(); } } }
public void DrawInContext (CGContext context, bool isDebuggingEnabled, bool usePreciseLocation) { LinePoint maybePriorPoint = null; foreach (var point in points) { if (maybePriorPoint == null) { maybePriorPoint = point; continue; } var priorPoint = maybePriorPoint; var color = UIColor.Black; if (isDebuggingEnabled) { if (point.Properties.Contains (PointType.Cancelled)) color = UIColor.Red; else if (point.Properties.Contains (PointType.NeedsUpdate)) color = UIColor.Orange; else if (point.Properties.Contains (PointType.Finger)) color = UIColor.Purple; else if (point.Properties.Contains (PointType.Coalesced)) color = UIColor.Green; else if (point.Properties.Contains (PointType.Predicted)) color = UIColor.Blue; } else { if (point.Properties.Contains (PointType.Cancelled)) color = UIColor.Clear; else if (point.Properties.Contains (PointType.Finger)) color = UIColor.Purple; if (point.Properties.Contains (PointType.Predicted) && !point.Properties.Contains (PointType.Cancelled)) color = color.ColorWithAlpha (0.5f); } var location = usePreciseLocation ? point.PreciseLocation : point.Location; var priorLocation = usePreciseLocation ? priorPoint.PreciseLocation : priorPoint.Location; context.SetStrokeColor (color.CGColor); context.BeginPath (); context.MoveTo (priorLocation.X, priorLocation.Y); context.AddLineToPoint (location.X, location.Y); context.SetLineWidth (point.Magnitude); context.StrokePath (); maybePriorPoint = point; } }
private void DrawRect(CGContext g, CGRect rect, Thickness borderThickness, Brush borderBrush, Brush fill, CornerRadius cornerRadius) { var center = new CGPoint(rect.Left + cornerRadius.TopLeft + borderThickness.Left / 2, rect.Top + cornerRadius.TopLeft + borderThickness.Top / 2); var strokeColor = borderBrush != null ? borderBrush.ToUIColor(rect.Size).CGColor : UIColor.Black.CGColor; g.SetStrokeColor(strokeColor); g.SetFillColor(strokeColor); List<Arc> innerArcs = new List<Arc>(); if (cornerRadius.TopLeft != 0) { innerArcs.Add(this.DrawArc(g, cornerRadius.TopLeft, center, borderThickness.LeftF(), borderThickness.TopF(), 180f, 270f)); } else { innerArcs.Add(new Arc() { Center = center }); } g.BeginPath(); g.SetLineWidth(borderThickness.TopF()); g.MoveTo((nfloat)cornerRadius.TopLeft, borderThickness.TopF() / 2); g.AddLineToPoint(rect.Right - (nfloat)cornerRadius.TopRight - borderThickness.RightF() / 2, borderThickness.TopF() / 2); g.StrokePath(); center = new CGPoint(rect.Right - cornerRadius.TopRight - borderThickness.Right / 2, rect.Top + cornerRadius.TopRight + borderThickness.Top / 2); if (cornerRadius.TopRight != 0) { innerArcs.Add(this.DrawArc(g, cornerRadius.TopRight, center, borderThickness.TopF(), borderThickness.RightF(), -90f, 0f)); } else { innerArcs.Add(new Arc { Center = center }); } g.BeginPath(); g.SetLineWidth(borderThickness.RightF()); g.MoveTo(rect.Right - borderThickness.RightF() / 2, (nfloat)cornerRadius.TopRight); g.AddLineToPoint(rect.Right - borderThickness.RightF() / 2, rect.Height - (nfloat)cornerRadius.BottomRight); g.StrokePath(); center = new CGPoint(rect.Right - cornerRadius.BottomRight - borderThickness.Right / 2, rect.Bottom - cornerRadius.BottomRight - borderThickness.Bottom / 2); if (cornerRadius.BottomRight != 0) { innerArcs.Add(this.DrawArc(g, cornerRadius.BottomRight, center, borderThickness.RightF(), borderThickness.BottomF(), 0f, 90f)); } else { innerArcs.Add(new Arc() { Center = center }); } g.BeginPath(); g.SetLineWidth(borderThickness.BottomF()); g.MoveTo(rect.Right - (nfloat)cornerRadius.BottomRight, rect.Bottom - borderThickness.BottomF() / 2); g.AddLineToPoint(rect.Left + (nfloat)cornerRadius.BottomLeft, rect.Bottom - borderThickness.BottomF() / 2); g.StrokePath(); center = new CGPoint((rect.Left + cornerRadius.BottomLeft + borderThickness.Left / 2), (rect.Bottom - cornerRadius.BottomLeft - borderThickness.Bottom / 2)); if (cornerRadius.BottomLeft != 0) { innerArcs.Add(this.DrawArc(g, cornerRadius.BottomLeft, center, borderThickness.BottomF(), borderThickness.LeftF(), 90f, 180f)); } else { innerArcs.Add(new Arc() { Center = center }); } g.SetLineWidth((nfloat)borderThickness.Left); g.MoveTo(rect.Left + borderThickness.LeftF() / 2, rect.Bottom - (nfloat)cornerRadius.BottomLeft); g.AddLineToPoint(rect.Left + borderThickness.LeftF() / 2, rect.Top + (nfloat)cornerRadius.TopLeft); g.StrokePath(); if (fill != null) { var fillColor = fill.ToUIColor(rect.Size).CGColor; g.SetFillColor(fillColor); g.SetLineWidth(0); using (CGPath path = new CGPath()) { path.AddArc( innerArcs[0].Center.X, innerArcs[0].Center.Y, innerArcs[0].Radius, innerArcs[0].EndingAngle, innerArcs[0].StartingAngle, false); path.AddArc( innerArcs[1].Center.X, innerArcs[1].Center.Y, innerArcs[1].Radius, innerArcs[1].EndingAngle, innerArcs[1].StartingAngle, false); path.AddArc( innerArcs[2].Center.X, innerArcs[2].Center.Y, innerArcs[2].Radius, innerArcs[2].EndingAngle, innerArcs[2].StartingAngle, false); path.AddArc( innerArcs[3].Center.X, innerArcs[3].Center.Y, innerArcs[3].Radius, innerArcs[3].EndingAngle, innerArcs[3].StartingAngle, false); g.AddPath(path); g.DrawPath(CGPathDrawingMode.Fill); } } }
private void DrawShine(CGContext context, RectangleF rect) { context.SaveState (); context.BeginPath (); var maxY = MakePath (context, rect); context.Clip (); /*var locations = new float[] { 0.0f, 0.5f }; var components = new float[] { 0.92f, 0.92f, 0.92f, 1.0f, 0.82f, 0.82f, 0.82f, 0.4f };*/ var locations = new float[] { 0f, 0.4f, 0.5f, 0.5f, 0.6f, 1.0f }; var colors = new UIColor[] { UIColor.FromWhiteAlpha (1.0f, 0.885f), UIColor.FromWhiteAlpha (1.0f, 0.45f), UIColor.FromWhiteAlpha (1.0f, 0.23f), UIColor.FromWhiteAlpha (1.0f, 0.10f), UIColor.FromRGBA (0f, 0f, 0f, 0.13f), UIColor.FromRGBA (0f, 0f, 0f, 0.13f) }; var components = GetComponents (colors); var darkLoc = new float[] { 0.5f, 1.0f }; var darkComp = new float[] { 0.08f, 0.08f, 0.08f, 0.6f, 0.18f, 0.18f, 0.18f, 0.2f }; using (var cspace = CGColorSpace.CreateDeviceRGB ()) using (var darkGrad = new CGGradient (cspace, darkComp, darkLoc)) using (var gradient = new CGGradient (cspace, components, locations)) { PointF sPoint = new PointF (0f, 0f), ePoint = new PointF (0f, maxY); context.DrawLinearGradient (gradient, sPoint, ePoint, 0); } context.RestoreState (); }
private void DrawRoundedRect(CGContext context, RectangleF rect) { context.SaveState (); context.BeginPath (); context.SetFillColor (badgeColor.CGColor); MakePath (context, rect); context.SetShadowWithColor (new SizeF (1.0f, 1.0f), 3, UIColor.Black.CGColor); context.FillPath (); context.RestoreState (); }
private void DrawBorder(CGContext context, RectangleF rect) { context.SaveState (); context.BeginPath (); float lineSize = 2f; if (this.scaleFactor > 1) { lineSize += this.scaleFactor * .25f; } context.SetLineWidth (lineSize); context.SetStrokeColor (this.borderColor.CGColor); MakePath (context, rect); context.ClosePath (); context.StrokePath (); context.RestoreState (); }
public void DrawInContext(CGContext context, bool isDebuggingEnabled, bool usePreciseLocation) { LinePoint maybePriorPoint = null; foreach (var point in Points) { if (maybePriorPoint == null) { maybePriorPoint = point; continue; } var priorPoint = maybePriorPoint; var color = UIColor.Black; var pointType = point.PointType; if (isDebuggingEnabled) { if (pointType.Has (PointType.Cancelled)) color = UIColor.Red; else if (pointType.Has (PointType.NeedsUpdate)) color = UIColor.Orange; else if (pointType.Has (PointType.Finger)) color = UIColor.Purple; else if (pointType.Has (PointType.Coalesced)) color = UIColor.Green; else if (pointType.Has (PointType.Predicted)) color = UIColor.Blue; } else { if (pointType.Has (PointType.Cancelled)) color = UIColor.Red; else if (pointType.Has (PointType.Finger)) color = UIColor.Purple; if (pointType.Has (PointType.Predicted) && !pointType.Has (PointType.Cancelled)) color = color.ColorWithAlpha (.5f); } var location = usePreciseLocation ? point.PreciseLocation : point.Location; var priorLocation = usePreciseLocation ? priorPoint.PreciseLocation : priorPoint.Location; context.SetStrokeColor (color.CGColor); context.BeginPath (); context.MoveTo (priorLocation.X, priorLocation.Y); context.AddLineToPoint (location.X, location.Y); context.SetLineWidth (point.Magnitude); context.StrokePath (); // Draw azimuith and elevation on all non-coalesced points when debugging. if (isDebuggingEnabled && !point.PointType.Has (PointType.Coalesced) && !point.PointType.Has (PointType.Predicted) && !point.PointType.Has (PointType.Finger)) { context.BeginPath (); context.SetStrokeColor (UIColor.Red.CGColor); context.SetLineWidth (.5f); context.MoveTo (location.X, location.Y); var targetPoint = new CGPoint (.5f + 10f * NMath.Cos (point.AltitudeAngle), 0f); targetPoint = CGAffineTransform.MakeRotation (point.AzimuthAngle).TransformPoint (targetPoint); targetPoint.X += location.X; targetPoint.Y += location.Y; context.AddLineToPoint (targetPoint.X, targetPoint.Y); context.StrokePath (); } maybePriorPoint = point; } }
private void DrawRectangle(CGContext g, PinboardData.RectangleInfo rectInfo) { g.SetFillColor(rectInfo.Color); g.FillRect(rectInfo.Rectangle); float pw = 0.5f; CGColor rectBorderColor = new CGColor(0f, rectInfo.Color.Alpha); g.SetLineWidth(pw); g.SetStrokeColor(rectBorderColor); g.SetFillColor(rectInfo.Color); g.SetLineJoin(CGLineJoin.Miter); g.BeginPath(); g.StrokeRect(rectInfo.Rectangle); int margin = 5; // TODO: Make the font configurable NSFont font = NSFont.FromFontName("Helvetica", 12f); NSObject[] objects = new NSObject[] { font, (NSNumber)0 }; NSObject[] keys = new NSObject[] { NSAttributedString.FontAttributeName, NSAttributedString.LigatureAttributeName }; NSDictionary attributes = NSDictionary.FromObjectsAndKeys(objects, keys); NSAttributedString attrString = new NSAttributedString(rectInfo.Name, attributes); attrString.DrawString(new RectangleF(rectInfo.X + margin, rectInfo.Y + margin, rectInfo.Width - 2 * margin, rectInfo.Height - 2 * margin)); }
void FillRoundedRect (RectangleF rect, CGContext context) { float radius = 10.0f; context.BeginPath (); context.SetGrayFillColor (0.0f, this.Opacity); context.MoveTo (rect.GetMinX () + radius, rect.GetMinY ()); context.AddArc (rect.GetMaxX () - radius, rect.GetMinY () + radius, radius, (float)(3 * Math.PI / 2), 0f, false); context.AddArc (rect.GetMaxX () - radius, rect.GetMaxY () - radius, radius, 0, (float)(Math.PI / 2), false); context.AddArc (rect.GetMinX () + radius, rect.GetMaxY () - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false); context.AddArc (rect.GetMinX () + radius, rect.GetMinY () + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false); context.ClosePath (); context.FillPath (); }
void drawSlicesSeparators(CGContext contextRef, SizeF viewSize, PointF center) { int outerDiameter = (int)Math.Min(viewSize.Width, viewSize.Height); double outerRadius = outerDiameter / 2.0 - internalPadding; int innerDiameter = (int)(outerDiameter - Theme.Thickness); double innerRadius = innerDiameter / 2.0; int sliceCount = (int)ProgressTotal; double sliceAngle = (2 * M_PI) / sliceCount; contextRef.SetLineWidth(Theme.SliceDividerThickness); contextRef.SetStrokeColor(Theme.SliceDividerColor.CGColor); contextRef.MoveTo(center.X, center.Y); for (int i = 0; i < sliceCount; i++) { contextRef.BeginPath(); double startAngle = sliceAngle * i - M_PI_2; double endAngle = sliceAngle * (i + 1) - M_PI_2; contextRef.AddArc(center.X, center.Y, (float)outerRadius, (float)startAngle, (float)endAngle, false); contextRef.AddArc(center.X, center.Y, (float)innerRadius, (float)endAngle, (float)startAngle, true); contextRef.StrokePath(); } }
// // ShapeObjectLogo // private void DrawShapeObjectLogo(CGContext context) { UIBezierPath ShapeObjectLogo; // Shape Path ShapeObjectLogo = new UIBezierPath(); ShapeObjectLogo.MoveTo(new CGPoint(21.640106, 0.000000)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(16.612139, 2.920175), new CGPoint(19.615119, 0.005031), new CGPoint(17.632132, 1.159215)); ShapeObjectLogo.AddLineTo(new CGPoint(0.752245, 30.580328)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(0.752245, 36.419672), new CGPoint(-0.250748, 32.346320), new CGPoint(-0.250748, 34.654687)); ShapeObjectLogo.AddLineTo(new CGPoint(16.612139, 64.080831)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(21.641106, 67.000000), new CGPoint(17.632132, 65.841791), new CGPoint(19.615119, 66.995975)); ShapeObjectLogo.AddLineTo(new CGPoint(53.359894, 67.000000)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(58.387861, 64.080831), new CGPoint(55.384881, 66.995975), new CGPoint(57.367868, 65.841791)); ShapeObjectLogo.AddLineTo(new CGPoint(74.247755, 36.419672)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(74.247755, 30.580328), new CGPoint(75.250748, 34.654687), new CGPoint(75.250748, 32.346320)); ShapeObjectLogo.AddLineTo(new CGPoint(58.386861, 2.920175)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(53.359894, 0.000000), new CGPoint(57.367868, 1.159215), new CGPoint(55.384881, 0.004025)); ShapeObjectLogo.AddLineTo(new CGPoint(21.640106, 0.000000)); ShapeObjectLogo.ClosePath(); ShapeObjectLogo.MoveTo(new CGPoint(21.640106, 0.000000)); ShapeObjectLogo.MoveTo(new CGPoint(21.928104, 16.181713)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(22.061103, 16.181713), new CGPoint(21.972313, 16.176991), new CGPoint(22.016894, 16.176991)); ShapeObjectLogo.AddLineTo(new CGPoint(27.532066, 16.181713)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(28.130062, 16.537930), new CGPoint(27.778919, 16.189389), new CGPoint(28.004637, 16.323845)); ShapeObjectLogo.AddLineTo(new CGPoint(37.411001, 33.143280)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.500000, 33.410946), new CGPoint(37.458060, 33.225659), new CGPoint(37.488317, 33.316656)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.587999, 33.143280), new CGPoint(37.511374, 33.316728), new CGPoint(37.541289, 33.225734)); ShapeObjectLogo.AddLineTo(new CGPoint(46.846938, 16.537930)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(47.466934, 16.181713), new CGPoint(46.977011, 16.317781), new CGPoint(47.212411, 16.182533)); ShapeObjectLogo.AddLineTo(new CGPoint(52.936897, 16.181713)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(53.557893, 17.229233), new CGPoint(53.421894, 16.186744), new CGPoint(53.784891, 16.798552)); ShapeObjectLogo.AddLineTo(new CGPoint(44.497953, 33.500503)); ShapeObjectLogo.AddLineTo(new CGPoint(53.557893, 49.748630)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(52.937897, 50.818287), new CGPoint(53.806891, 50.181323), new CGPoint(53.434894, 50.823318)); ShapeObjectLogo.AddLineTo(new CGPoint(47.466934, 50.818287)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(46.846938, 50.439932), new CGPoint(47.207875, 50.812898), new CGPoint(46.971429, 50.668606)); ShapeObjectLogo.AddLineTo(new CGPoint(37.586999, 33.834582)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.500000, 33.566916), new CGPoint(37.540639, 33.752052), new CGPoint(37.511064, 33.661063)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.411001, 33.834582), new CGPoint(37.488317, 33.661206), new CGPoint(37.458060, 33.752204)); ShapeObjectLogo.AddLineTo(new CGPoint(28.131062, 50.439932)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(27.532066, 50.818287), new CGPoint(28.010506, 50.662417), new CGPoint(27.783589, 50.805749)); ShapeObjectLogo.AddLineTo(new CGPoint(22.062103, 50.818287)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(21.442107, 49.748630), new CGPoint(21.564106, 50.823318), new CGPoint(21.192109, 50.182329)); ShapeObjectLogo.AddLineTo(new CGPoint(30.500047, 33.500503)); ShapeObjectLogo.AddLineTo(new CGPoint(21.440107, 17.229233)); ShapeObjectLogo.AddCurveToPoint(new CGPoint(21.927104, 16.181713), new CGPoint(21.223109, 16.836790), new CGPoint(21.488107, 16.265233)); ShapeObjectLogo.AddLineTo(new CGPoint(21.928104, 16.181713)); ShapeObjectLogo.ClosePath(); ShapeObjectLogo.MoveTo(new CGPoint(21.928104, 16.181713)); context.SaveState(); context.TranslateCTM(3.000000f, 7.000000f); // Shape Outer Shadow context.SaveState(); context.BeginPath(); context.AddPath(ShapeObjectLogo.CGPath); context.AddRect(RectangleFExtensions.Inset(ShapeObjectLogo.Bounds, -1f, -2f)); context.EOClip(); context.TranslateCTM(-77f, 0f); GenerateShapeShadow(context, ShapeObjectLogo, 77f, 1f, 77f, 0, UIColor.FromHSBA(0.000000f, 0.000000f, 0.000000f, 0.500000f), 0f, 0, 0f, 0f); context.RestoreState(); // Shape Fill context.SaveState(); if (Active) { UIColor.FromHSBA(0.530476f, 0.849515f, 0.807843f, 1.000000f).SetFill(); } else { UIColor.FromRGB(137, 137, 137).SetFill(); } ShapeObjectLogo.Fill(); context.RestoreState(); context.RestoreState(); }
void drawSlicesWithRadius(float radius, PointF center, CGContext contextRef) { bool cgClockwise = !Clockwise; uint startingSlice = StartingSlice - 1; if (ProgressCounter == 0 && Theme.DrawIncompleteArcIfNoProgress) { DrawArcInContext(contextRef, center, radius, 0, M_PI * 2, Theme.IncompletedColor.CGColor, cgClockwise); return; } if (!Theme.SliceDividerHidden && Theme.SliceDividerThickness > 0) { float sliceAngle = (2 * M_PI) / ProgressTotal; for (int i =0; i < ProgressTotal; i++) { float startValue = (sliceAngle * i) + sliceAngle * startingSlice; float startAngle, endAngle; if (Clockwise) { startAngle = -M_PI_2 + startValue; endAngle = startAngle + sliceAngle; } else { startAngle = -M_PI_2 - startValue; endAngle = startAngle - sliceAngle; } contextRef.BeginPath(); contextRef.MoveTo(center.X, center.Y); contextRef.AddArc(center.X, center.Y, radius, startAngle, endAngle, cgClockwise); CGColor color = Theme.IncompletedColor.CGColor; if (i < ProgressCounter) { color = Theme.CompletedColor.CGColor; } contextRef.SetFillColor(color); contextRef.FillPath(); } } else { double originAngle, endAngle; double sliceAngle = (2 * M_PI) / ProgressTotal; double startingAngle = sliceAngle * startingSlice; double progressAngle = sliceAngle * ProgressCounter; if (Clockwise) { originAngle = - M_PI_2 + startingAngle; endAngle = originAngle + progressAngle; } else { originAngle = - M_PI_2 - startingAngle; endAngle = originAngle - progressAngle; } DrawArcInContext(contextRef, center, radius, (float)originAngle, (float)endAngle, Theme.CompletedColor.CGColor, cgClockwise); if (ProgressCounter < ProgressTotal) { DrawArcInContext(contextRef, center, radius, (float)endAngle, (float)originAngle, Theme.IncompletedColor.CGColor, cgClockwise); } } }