public void DrawLayer(CALayer layer, CoreGraphics.CGContext context) { NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext graphicsContext = NSGraphicsContext.FromGraphicsPort(context, true); NSGraphicsContext.CurrentContext = graphicsContext; NSBezierPath path = new NSBezierPath(); //ベジェ曲線 var x1 = this.Frame.Left; var y1 = this.Frame.Top; var x2 = this.Frame.Right; var y2 = this.Frame.Bottom; path.MoveTo(new CoreGraphics.CGPoint(x1, y1)); path.CurveTo(new CoreGraphics.CGPoint(x2, y1), new CoreGraphics.CGPoint(x1, y2), new CoreGraphics.CGPoint(x2, y2)); //背景は白 NSColor.White.Set(); path.Fill(); //線は青 NSColor.Blue.Set(); //線の太さ path.LineWidth = 2; path.Stroke(); NSGraphicsContext.GlobalRestoreGraphicsState(); }
public override void DrawRect(CoreGraphics.CGRect dirtyRect) { NSBezierPath path = new NSBezierPath(); path.MoveTo(new CoreGraphics.CGPoint(200, 50)); path.CurveTo(new CoreGraphics.CGPoint(300, 50), new CoreGraphics.CGPoint(100, 300), new CoreGraphics.CGPoint(400, 300)); DrawPath(path); }
public static void AddQuadCurveToPoint(this NSBezierPath bezierPath, CGPoint endPoint, CGPoint controlPoint) { var d1x = controlPoint.X - bezierPath.CurrentPoint.X; var d1y = controlPoint.Y - bezierPath.CurrentPoint.Y; var d2x = endPoint.X - controlPoint.X; var d2y = endPoint.Y - controlPoint.Y; var cp1 = new CGPoint(controlPoint.X - d1x / 3.0, controlPoint.Y - d1y / 3.0); var cp2 = new CGPoint(controlPoint.X + d2x / 3.0, controlPoint.Y + d2y / 3.0); bezierPath.CurveTo(endPoint, cp1, cp2); }
public void CreateRandomCurves() { CGPoint point1 = new CGPoint(mRandom.Next((int)this.Bounds.Width), mRandom.Next((int)this.Bounds.Height)); mPath.MoveTo(point1); for (nint i = 0; i < 25; i++) { point1 = new CGPoint(mRandom.Next((int)this.Bounds.Width), mRandom.Next((int)this.Bounds.Height)); CGPoint cp1 = new CGPoint(mRandom.Next((int)this.Bounds.Width), mRandom.Next((int)this.Bounds.Height)); CGPoint cp2 = new CGPoint(mRandom.Next((int)this.Bounds.Width), mRandom.Next((int)this.Bounds.Height)); mPath.CurveTo(point1, cp1, cp2); } }
private NSBezierPath MosconeFloor() { var path = new NSBezierPath(); path.MoveTo(new CGPoint(69, 0)); path.LineTo(new CGPoint(69, -107)); path.LineTo(new CGPoint(0, -107)); path.LineTo(new CGPoint(0, -480)); path.LineTo(new CGPoint(104, -480)); path.LineTo(new CGPoint(104, -500)); path.LineTo(new CGPoint(184, -480)); path.LineTo(new CGPoint(226, -480)); path.LineTo(new CGPoint(226, -500)); path.LineTo(new CGPoint(306, -480)); path.LineTo(new CGPoint(348, -480)); path.LineTo(new CGPoint(348, -500)); path.LineTo(new CGPoint(428, -480)); path.LineTo(new CGPoint(470, -480)); path.LineTo(new CGPoint(470, -500)); path.LineTo(new CGPoint(550, -480)); path.LineTo(new CGPoint(592, -480)); path.LineTo(new CGPoint(592, -505)); path.LineTo(new CGPoint(752.548776f, -460.046343f)); path.CurveTo(new CGPoint(767.32333f, -440.999893f), new CGPoint(760.529967f, -457.811609f), new CGPoint(767.218912f, -449.292876f)); path.CurveTo(new CGPoint(700, 0), new CGPoint(767.32333f, -440.999893f), new CGPoint(776, -291)); path.LineTo(new CGPoint(69, 0)); path.MoveTo(new CGPoint(676, -238)); path.LineTo(new CGPoint(676, -348)); path.LineTo(new CGPoint(710, -348)); path.LineTo(new CGPoint(710, -238)); path.LineTo(new CGPoint(676, -238)); path.LineTo(new CGPoint(676, -238)); return(path); }
public override void DrawRect(CoreGraphics.CGRect dirtyRect) { var rect = this.Bounds; var x1 = rect.Left; var y1 = rect.Top; var x2 = rect.Right; var y2 = rect.Bottom; NSBezierPath path = new NSBezierPath(); path.MoveTo(new CoreGraphics.CGPoint(x1, y1)); path.CurveTo(new CoreGraphics.CGPoint(x2, y1), new CoreGraphics.CGPoint(x1, y2), new CoreGraphics.CGPoint(x2, y2)); path.LineWidth = 5; NSColor.Red.SetStroke(); path.Stroke(); }
public override void DrawRect(RectangleF dirtyRect) { var contentRect = new RectangleF(Bounds.X + LineThickness, Bounds.Y + LineThickness, Bounds.Width - (LineThickness * 2), Bounds.Height - (LineThickness * 2)); // Mac coords are reversed vs. .Net / MonoTouch coords, so we just reverse the top/bottom coords to compensate var top = contentRect.Bottom; var bottom = contentRect.Top; var left = contentRect.Left; var right = contentRect.Right; var path = new NSBezierPath(); // Draw the 'arrow' at the top path.MoveTo(new PointF(ArrowX, top)); path.LineTo(new PointF(ArrowX + ArrowWidth / 2, top - ArrowHeight)); path.LineTo(new PointF(right - CornerRadius, top - ArrowHeight)); // Right right var topRightCorner = new PointF(right, top - ArrowHeight); path.CurveTo(new PointF(right, top - ArrowHeight - CornerRadius), topRightCorner, topRightCorner); // Right line path.LineTo(new PointF(right, bottom + CornerRadius)); // Bottom right var bottomRightCorner = new PointF(right, bottom); path.CurveTo(new PointF(right - CornerRadius, bottom), bottomRightCorner, bottomRightCorner); // Bottom line path.LineTo(new PointF(left + CornerRadius, bottom)); // Bottom left var bottomLeftCorner = new PointF(left, bottom); path.CurveTo(new PointF(left, bottom + CornerRadius), bottomLeftCorner, bottomLeftCorner); // Left line path.LineTo(new PointF(left, top - ArrowHeight - CornerRadius)); // Top left var topLeftCorner = new PointF(left, top - ArrowHeight); path.CurveTo(new PointF(left + CornerRadius, top - ArrowHeight), topLeftCorner, topLeftCorner); // Line up to start of 'arrow' & finish path.LineTo(new PointF(ArrowX - ArrowWidth / 2, top - ArrowHeight)); path.ClosePath(); // Fill the path with a semi-transparent white NSColor.FromDeviceWhite(1.0f, FillOpacity).SetFill(); path.Fill(); NSGraphicsContext.GlobalSaveGraphicsState(); // Clip all rendering of controls within view to within the path outline we specified earlier var clip = NSBezierPath.FromRect(Bounds); clip.AppendPath(path); clip.AddClip(); // Draw the border path.LineWidth = LineThickness * 2; NSColor.White.SetStroke(); path.Stroke(); NSGraphicsContext.GlobalRestoreGraphicsState(); }
private NSBezierPath MosconeFloor () { var path = new NSBezierPath (); path.MoveTo (new CGPoint (69, 0)); path.LineTo (new CGPoint (69, -107)); path.LineTo (new CGPoint (0, -107)); path.LineTo (new CGPoint (0, -480)); path.LineTo (new CGPoint (104, -480)); path.LineTo (new CGPoint (104, -500)); path.LineTo (new CGPoint (184, -480)); path.LineTo (new CGPoint (226, -480)); path.LineTo (new CGPoint (226, -500)); path.LineTo (new CGPoint (306, -480)); path.LineTo (new CGPoint (348, -480)); path.LineTo (new CGPoint (348, -500)); path.LineTo (new CGPoint (428, -480)); path.LineTo (new CGPoint (470, -480)); path.LineTo (new CGPoint (470, -500)); path.LineTo (new CGPoint (550, -480)); path.LineTo (new CGPoint (592, -480)); path.LineTo (new CGPoint (592, -505)); path.LineTo (new CGPoint (752.548776f, -460.046343f)); path.CurveTo (new CGPoint (767.32333f, -440.999893f), new CGPoint (760.529967f, -457.811609f), new CGPoint (767.218912f, -449.292876f)); path.CurveTo (new CGPoint (700, 0), new CGPoint (767.32333f, -440.999893f), new CGPoint (776, -291)); path.LineTo (new CGPoint (69, 0)); path.MoveTo (new CGPoint (676, -238)); path.LineTo (new CGPoint (676, -348)); path.LineTo (new CGPoint (710, -348)); path.LineTo (new CGPoint (710, -238)); path.LineTo (new CGPoint (676, -238)); path.LineTo (new CGPoint (676, -238)); return path; }
public virtual void AddCurveToPoint(CGPoint endPoint, CGPoint controlPoint1, CGPoint controlPoint2) { path.CurveTo(endPoint, controlPoint1, controlPoint2); }
public override void DrawRect(RectangleF rect) { var xamarinBlue = NSColor.FromDeviceRgba(0.071f, 0.463f, 0.725f, 1.000f); NSBezierPath xamarinLogoPath = new NSBezierPath(); xamarinLogoPath.MoveTo(new PointF(230.49f, 92.68f)); xamarinLogoPath.LineTo(new PointF(200.74f, 92.68f)); xamarinLogoPath.LineTo(new PointF(159.7f, 167.71f)); xamarinLogoPath.LineTo(new PointF(200.74f, 242.73f)); xamarinLogoPath.LineTo(new PointF(230.49f, 242.73f)); xamarinLogoPath.LineTo(new PointF(191.23f, 167.71f)); xamarinLogoPath.LineTo(new PointF(230.49f, 92.68f)); xamarinLogoPath.ClosePath(); xamarinLogoPath.MoveTo(new PointF(118.66f, 92.68f)); xamarinLogoPath.LineTo(new PointF(88.92f, 92.68f)); xamarinLogoPath.LineTo(new PointF(128.18f, 167.71f)); xamarinLogoPath.LineTo(new PointF(88.92f, 242.73f)); xamarinLogoPath.LineTo(new PointF(118.66f, 242.73f)); xamarinLogoPath.LineTo(new PointF(159.7f, 167.71f)); xamarinLogoPath.LineTo(new PointF(118.66f, 92.68f)); xamarinLogoPath.ClosePath(); xamarinLogoPath.MoveTo(new PointF(220.7f, 37.0f)); xamarinLogoPath.CurveTo(new PointF(232.55f, 41.1f), new PointF(220.7f, 37.0f), new PointF(227.07f, 38.03f)); xamarinLogoPath.CurveTo(new PointF(242.62f, 49.31f), new PointF(238.03f, 44.18f), new PointF(242.62f, 49.31f)); xamarinLogoPath.LineTo(new PointF(304.22f, 152.47f)); xamarinLogoPath.CurveTo(new PointF(308.95f, 170.05f), new PointF(304.22f, 152.47f), new PointF(309.55f, 163.02f)); xamarinLogoPath.CurveTo(new PointF(304.22f, 183.53f), new PointF(308.36f, 177.09f), new PointF(304.22f, 183.53f)); xamarinLogoPath.LineTo(new PointF(243.57f, 286.11f)); xamarinLogoPath.CurveTo(new PointF(234.05f, 294.31f), new PointF(243.57f, 286.11f), new PointF(239.7f, 291.09f)); xamarinLogoPath.CurveTo(new PointF(220.97f, 299.0f), new PointF(228.4f, 297.53f), new PointF(220.97f, 299.0f)); xamarinLogoPath.LineTo(new PointF(97.25f, 299.0f)); xamarinLogoPath.CurveTo(new PointF(84.16f, 294.31f), new PointF(97.25f, 299.0f), new PointF(89.51f, 297.53f)); xamarinLogoPath.CurveTo(new PointF(75.83f, 286.11f), new PointF(78.81f, 291.09f), new PointF(75.83f, 286.11f)); xamarinLogoPath.LineTo(new PointF(13.99f, 181.77f)); xamarinLogoPath.CurveTo(new PointF(11.03f, 170.05f), new PointF(13.99f, 181.77f), new PointF(11.33f, 176.21f)); xamarinLogoPath.CurveTo(new PointF(12.81f, 157.16f), new PointF(10.73f, 163.9f), new PointF(12.81f, 157.16f)); xamarinLogoPath.LineTo(new PointF(75.59f, 49.31f)); xamarinLogoPath.CurveTo(new PointF(85.07f, 41.1f), new PointF(75.59f, 49.31f), new PointF(79.59f, 44.18f)); xamarinLogoPath.CurveTo(new PointF(97.5f, 37.0f), new PointF(90.54f, 38.03f), new PointF(97.5f, 37.0f)); xamarinLogoPath.LineTo(new PointF(220.7f, 37.0f)); xamarinLogoPath.LineTo(new PointF(220.7f, 37.0f)); xamarinLogoPath.ClosePath(); xamarinBlue.SetFill(); xamarinLogoPath.Fill(); }