public void DrawRect(CGRect aRect, bool selected) { NSGraphics.RectClip(aRect); aRect.Intersect(Frame); Color.Set(); NSGraphics.RectFill(aRect); if (selected) { NSColor.Black.Set(); NSGraphics.FrameRectWithWidth(Frame, 4.0f); } if (IsLocked) { float xSize = (Frame.Width > 10.0f) ? 5.0f : 3.0f; NSBezierPath path = new NSBezierPath(); NSColor.Black.Set(); path.LineWidth = 3.0f; path.MoveTo(new CGPoint(MidX(Frame) - xSize, MidY(Frame) - xSize)); path.LineTo(new CGPoint(MidX(Frame) + xSize, MidY(Frame) + xSize)); path.MoveTo(new CGPoint(MidX(Frame) - xSize, MidY(Frame) + xSize)); path.LineTo(new CGPoint(MidX(Frame) + xSize, MidY(Frame) - xSize)); path.Stroke(); } }
private NSBezierPath StarPath(float innerRadius, float outerRadius) { var raysCount = 5; var delta = 2.0f * (float)Math.PI / raysCount; var path = new NSBezierPath(); for (var i = 0; i < raysCount; ++i) { var alpha = i * delta + (float)Math.PI / 2; if (i == 0) { path.MoveTo(new CGPoint(outerRadius * (float)Math.Cos(alpha), outerRadius * (float)Math.Sin(alpha))); } else { path.LineTo(new CGPoint(outerRadius * (float)Math.Cos(alpha), outerRadius * (float)Math.Sin(alpha))); } alpha += 0.5f * delta; path.LineTo(new CGPoint(innerRadius * (float)Math.Cos(alpha), innerRadius * (float)Math.Sin(alpha))); } return(path); }
public void DrawRect(CGRect aRect, bool selected) { NSGraphics.RectClip (aRect); aRect.Intersect (Frame); Color.Set (); NSGraphics.RectFill (aRect); if (selected) { NSColor.Black.Set (); NSGraphics.FrameRectWithWidth (Frame, 4.0f); } if (IsLocked){ float xSize = (Frame.Width > 10.0f) ? 5.0f : 3.0f; NSBezierPath path = new NSBezierPath (); NSColor.Black.Set (); path.LineWidth = 3.0f; path.MoveTo (new CGPoint (MidX (Frame) - xSize, MidY (Frame) - xSize)); path.LineTo (new CGPoint (MidX (Frame) + xSize, MidY (Frame) + xSize)); path.MoveTo (new CGPoint (MidX (Frame) - xSize, MidY (Frame) + xSize)); path.LineTo (new CGPoint (MidX (Frame) + xSize, MidY (Frame) - xSize)); path.Stroke (); } }
private NSBezierPath TextChamferProfile() { var profile = new NSBezierPath(); profile.MoveTo(new CGPoint(0, 1)); profile.LineTo(new CGPoint(1.5f, 1)); profile.LineTo(new CGPoint(1.5f, 0)); profile.LineTo(new CGPoint(1, 0)); return(profile); }
public static XIR.Image RemoteRepresentation(this NSLineJoinStyle obj) { // Customize the line cap style for the new object. var aPath = new NSBezierPath(); var lineWidth = 10; var sampleWidth = 50; // First we draw the presentation line aPath.LineWidth = lineWidth; aPath.MoveTo(new CGPoint(lineWidth, lineWidth)); aPath.LineTo(new CGPoint(lineWidth + sampleWidth / 2, sampleWidth)); aPath.LineTo(new CGPoint(lineWidth + sampleWidth, lineWidth)); switch ((NSLineJoinStyle)obj) { case NSLineJoinStyle.Bevel: aPath.LineJoinStyle = NSLineJoinStyle.Bevel; break; case NSLineJoinStyle.Miter: aPath.LineJoinStyle = NSLineJoinStyle.Miter; break; case NSLineJoinStyle.Round: aPath.LineJoinStyle = NSLineJoinStyle.Round; break; } // let's make sure we leave a little room for the line width drawing as well by adding the lineWidth as well var width = aPath.ControlPointBounds.Right + lineWidth; var height = aPath.ControlPointBounds.Bottom + lineWidth; var nsimage = new NSImage(new CGSize(width, height)); nsimage.LockFocus(); brush.Set(); aPath.Stroke(); // Second, we draw the inset line to demonstrate the bounds aPath.RemoveAllPoints(); aPath.LineWidth = 2; aPath.MoveTo(new CGPoint(lineWidth, lineWidth)); aPath.LineTo(new CGPoint(lineWidth + sampleWidth / 2, sampleWidth)); aPath.LineTo(new CGPoint(lineWidth + sampleWidth, lineWidth)); pen.Set(); aPath.Stroke(); nsimage.UnlockFocus(); return(nsimage.RemoteRepresentation()); }
public override void DrawWithFrame (CGRect cellFrame, NSView inView) { if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark) { var inset = cellFrame.Inset (0.25f, 0.25f); inset = new CGRect (inset.X, inset.Y + 2, inset.Width, inset.Height - 2); var path = NSBezierPath.FromRoundedRect (inset, 3, 3); path.LineWidth = 0.5f; Styles.DarkBorderColor.ToNSColor ().SetStroke (); path.Stroke (); inset = new CGRect (inset.X + 3, inset.Y, inset.Width, inset.Height); DrawInteriorWithFrame (inset, inView); path = new NSBezierPath (); // Draw the separators for (int segment = 1; segment < SegmentCount; segment++) { nfloat x = inset.X + (33 * segment); path.MoveTo (new CGPoint (x, 0)); path.LineTo (new CGPoint (x, inset.Y + inset.Height)); } path.LineWidth = 0.5f; path.Stroke (); } else { base.DrawWithFrame (cellFrame, inView); } }
public override void DrawRow(nint row, CGRect clipRect) { if (row >= RowCount) { return; } base.DrawRow(row, clipRect); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext.ShouldAntialias = false; CGRect rectRow = RectForRow(row); CGRect rectColumn = RectForColumn(0); CGRect rect = Frame; CGPoint start = new CGPoint(rectColumn.Left, rectRow.Top); CGPoint end = new CGPoint(rectRow.Right, rectRow.Top); var linePath = new NSBezierPath(); GridColor.Set(); linePath.MoveTo(start); linePath.LineTo(end); linePath.ClosePath(); linePath.Stroke(); NSGraphicsContext.GlobalRestoreGraphicsState(); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); // Use Core Graphic routines to draw our UI NSBezierPath path = new NSBezierPath(); foreach (var p in _paths) { path.MoveTo(p.Item1); path.LineTo(p.Item2); } foreach (var n in _nodes) { path.AppendPathWithOvalInRect(new CGRect( n.X - NodeRadius, n.Y - NodeRadius, 2 * NodeRadius, 2 * NodeRadius)); } NSColor.Cyan.SetStroke(); path.Stroke(); NSColor.Orange.SetFill(); path.Fill(); }
public static CAShapeLayer ToShape(this LinePath element) { var line = new CAShapeLayer(); var bezierPath = new NSBezierPath(); bezierPath.MoveTo(new CGPoint(element.X1, element.Y1)); bezierPath.LineTo(new CGPoint(element.X2, element.Y2)); line.Path = bezierPath.ToCGPath(); if (!string.IsNullOrEmpty(element.Stroke)) { line.StrokeColor = XExtensions.ConvertToNSColor(element.Stroke).CGColor; } if (!string.IsNullOrEmpty(element.Fill)) { line.FillColor = XExtensions.ConvertToNSColor(element.Fill).CGColor; } line.LineWidth = element.StrokeWidth; var width = Math.Max(element.X1, element.X2) - Math.Min(element.X1, element.X2); var height = Math.Max(element.Y1, element.Y2) - Math.Min(element.Y1, element.Y2); line.Bounds = new CGRect(0, 0, width, height); return(line); }
public MyView (CGRect frame) : base (frame) { lineColor = NSColor.Blue; path = new NSBezierPath (); path.MoveTo (Bounds.Location); path.LineTo (new CGPoint (Bounds.GetMaxX (),Bounds.GetMaxY ())); }
public MyView(RectangleF frame) : base(frame) { lineColor = NSColor.Blue; path = new NSBezierPath(); path.MoveTo(Bounds.Location); path.LineTo(new PointF(Bounds.GetMaxX(), Bounds.GetMaxY())); }
public override void DrawWithFrame(CGRect cellFrame, NSView inView) { if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark) { var inset = cellFrame.Inset(0.25f, 0.25f); inset = new CGRect(inset.X, inset.Y + 2, inset.Width, inset.Height - 2); var path = NSBezierPath.FromRoundedRect(inset, 3, 3); path.LineWidth = 0.5f; Styles.DarkBorderColor.ToNSColor().SetStroke(); path.Stroke(); inset = new CGRect(inset.X + 3, inset.Y, inset.Width, inset.Height); DrawInteriorWithFrame(inset, inView); path = new NSBezierPath(); // Draw the separators for (int segment = 1; segment < SegmentCount; segment++) { nfloat x = inset.X + (33 * segment); path.MoveTo(new CGPoint(x, 0)); path.LineTo(new CGPoint(x, inset.Y + inset.Height)); } path.LineWidth = 0.5f; path.Stroke(); } else { base.DrawWithFrame(cellFrame, inView); } }
public override void DrawRect(RectangleF dirtyRect) { int radius = 5, arrowHeight = 10, arrowWidth = 20; var roundedRectangleRect = new RectangleF(0, 0, this.Bounds.Width, this.Bounds.Height - arrowHeight); var path = new NSBezierPath(); path.AppendPathWithRoundedRect(roundedRectangleRect, radius, radius); // Draw the triangle path.MoveTo(new PointF((this.Bounds.Width / 2) - (arrowWidth / 2), this.Bounds.Height - arrowHeight)); path.LineTo(new PointF((this.Bounds.Width / 2), this.Bounds.Height)); path.LineTo(new PointF((this.Bounds.Width / 2) + (arrowWidth / 2), this.Bounds.Height - arrowHeight)); path.ClosePath(); NSColor.Control.SetFill(); path.Fill(); }
private NSBezierPath OutlineChamferProfilePath() { var path = new NSBezierPath(); path.MoveTo(new CGPoint(1, 1)); path.LineTo(new CGPoint(1, 0)); return(path); }
void AddPointToPath(CGPoint currentPoint) { currentPath.LineTo(currentPoint); Element.Points.CollectionChanged -= OnPointsCollectionChanged; var point = currentPoint.ToPoint(); Element.Points.Add(point); Element.Points.CollectionChanged += OnPointsCollectionChanged; }
// void DrawBottomLine() { var linePath = new NSBezierPath(); Utility.ColorWithHexColorValue(BookInfo.FontColor, 1.0f).SetStroke(); linePath.LineWidth = 2; linePath.MoveTo(bottomLineTS); linePath.LineTo(bottomLineTE); linePath.ClosePath(); linePath.Stroke(); //var lineTPath = new NSBezierPath (); linePath.MoveTo(bottomLineBS); linePath.LineTo(bottomLineBE); linePath.ClosePath(); linePath.Stroke(); }
public static NSBezierPath SCArrowBezierPath(CGSize baseSize, CGSize tipSize, float hollow, bool twoSides) { var arrow = new NSBezierPath(); var h = new nfloat[5]; var w = new nfloat[4]; w [0] = 0; w [1] = baseSize.Width - tipSize.Width - hollow; w [2] = baseSize.Width - tipSize.Width; w [3] = baseSize.Width; h [0] = 0; h [1] = (tipSize.Height - baseSize.Height) * 0.5f; h [2] = (tipSize.Height) * 0.5f; h [3] = (tipSize.Height + baseSize.Height) * 0.5f; h [4] = tipSize.Height; if (twoSides) { arrow.MoveTo(new CGPoint(tipSize.Width, h [1])); arrow.LineTo(new CGPoint(tipSize.Width + hollow, h [0])); arrow.LineTo(new CGPoint(0, h [2])); arrow.LineTo(new CGPoint(tipSize.Width + hollow, h [4])); arrow.LineTo(new CGPoint(tipSize.Width, h [3])); } else { arrow.MoveTo(new CGPoint(0, h [1])); arrow.LineTo(new CGPoint(0, h [3])); } arrow.LineTo(new CGPoint(w [2], h [3])); arrow.LineTo(new CGPoint(w [1], h [4])); arrow.LineTo(new CGPoint(w [3], h [2])); arrow.LineTo(new CGPoint(w [1], h [0])); arrow.LineTo(new CGPoint(w [2], h [1])); arrow.ClosePath(); return(arrow); }
private static void DrawHand(NSBezierPath path, PointF center, double radians, float radius) { path.MoveTo(center); path.LineTo(new PointF { X = center.X + (float)Math.Sin(radians) * radius, Y = center.Y + (float)Math.Cos(radians) * radius, }); path.Stroke(); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); var line = new NSBezierPath(); line.MoveTo(new CGPoint(Frame.Width / 2, 0)); line.LineTo(new CGPoint(Frame.Width / 2, Frame.Height)); line.LineWidth = 1; NSColor.Gray.Set(); line.Stroke(); }
public override void UpdateLayer() { Layer.BackgroundColor = NSColor.FromRgb(245, 245, 245).CGColor; if (arrowLayers != null) { arrowLayers.ForEach(layer => layer.RemoveFromSuperLayer()); } arrowLayers = new List <CAShapeLayer> (); nfloat lastX = 8; var lastItem = items [items.Count - 1]; foreach (var item in items) { item.Layer.Position = new CGPoint(lastX, Bounds.GetMidY() - 1); lastX += item.Layer.Frame.Width + 20; if (item.Equals(lastItem)) { continue; } var arrow = new CAShapeLayer(); var path = new NSBezierPath(); path.MoveTo(new CGPoint(item.Layer.Frame.Right + 5, Bounds.Height)); path.LineTo(new CGPoint(item.Layer.Frame.Right + 15, Bounds.GetMidY())); path.LineTo(new CGPoint(item.Layer.Frame.Right + 5, 0)); arrow.ContentsScale = NSScreen.MainScreen.BackingScaleFactor; arrow.Path = path.ToCGPath(false); arrow.FillColor = null; arrow.StrokeColor = NSColor.FromWhite(0.85f, 1.0f).CGColor; arrowLayers.Add(arrow); Layer.AddSublayer(arrow); } }
public void CreateRandomPath() { CGPoint p = RandomPoint(); mPath.MoveTo(p); for (nint i = 0; i < 25; i++) { p = RandomPoint(); mPath.LineTo(p); } mPath.ClosePath(); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); StrokeColor.SetStroke(); var path = new NSBezierPath(); path.MoveTo(Start); path.LineTo(End); path.LineWidth = LineThickness; if (LineDash.Length > 0) { path.SetLineDash(LineDash.Select(w => w * LineThickness).ToArray(), 0); } path.Stroke(); }
public void Set(Polygon poly, ref Style style) { if (this.poly != poly) { //Console.WriteLine ($"({this.sx} == {sx} && {this.sy} == {sy} && {this.ex} == {ex} && {this.ey == ey})"); this.poly = poly; //Console.WriteLine (style.Transform); var ps = poly.Points; var n = ps.Count; if (n > 1) { var path = new NSBezierPath(); path.MoveTo(new CGPoint(ps[0].X, ps[0].Y)); for (var i = 1; i < n; i++) { path.LineTo(new CGPoint(ps[i].X, ps[i].Y)); } path.ClosePath(); var g = SCNShape.Create(path, 1); g.FirstMaterial = GetNativeMaterial(style.Color); Geometry = g; } else { Geometry = null; } Transform = style.Transform ; } if (ColorChanged(ref style)) { this.style.Color = style.Color; var g = Geometry; if (g is object) { g.FirstMaterial = GetNativeMaterial(style.Color); } } }
public static NSBezierPath SCArrowBezierPath (CGSize baseSize, CGSize tipSize, nfloat hollow, bool twoSides) { var arrow = new NSBezierPath (); var h = new nfloat[5]; var w = new nfloat[4]; w [0] = 0; w [1] = baseSize.Width - tipSize.Width - hollow; w [2] = baseSize.Width - tipSize.Width; w [3] = baseSize.Width; h [0] = 0; h [1] = (tipSize.Height - baseSize.Height) * 0.5f; h [2] = (tipSize.Height) * 0.5f; h [3] = (tipSize.Height + baseSize.Height) * 0.5f; h [4] = tipSize.Height; if (twoSides) { arrow.MoveTo (new CGPoint (tipSize.Width, h [1])); arrow.LineTo (new CGPoint (tipSize.Width + hollow, h [0])); arrow.LineTo (new CGPoint (0, h [2])); arrow.LineTo (new CGPoint (tipSize.Width + hollow, h [4])); arrow.LineTo (new CGPoint (tipSize.Width, h [3])); } else { arrow.MoveTo (new CGPoint (0, h [1])); arrow.LineTo (new CGPoint (0, h [3])); } arrow.LineTo (new CGPoint (w [2], h [3])); arrow.LineTo (new CGPoint (w [1], h [4])); arrow.LineTo (new CGPoint (w [3], h [2])); arrow.LineTo (new CGPoint (w [1], h [0])); arrow.LineTo (new CGPoint (w [2], h [1])); arrow.ClosePath (); return arrow; }
/// <summary> /// Add Line to path /// </summary> /// <param name="path">NS Bezier path</param> /// <param name="x">Target point X</param> /// <param name="y">Target point Y</param> public static void LineTo(this NSBezierPath path, double x, double y) => path.LineTo(new CGPoint(x, y));
public static void AddLineTo(this NSBezierPath bezierPath, CGPoint point) => bezierPath.LineTo(point);
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 StarPath (float innerRadius, float outerRadius) { var raysCount = 5; var delta = 2.0f * NMath.PI / raysCount; var path = new NSBezierPath (); for (var i = 0; i < raysCount; ++i) { var alpha = i * delta + NMath.PI / 2; if (i == 0) path.MoveTo (new CGPoint (outerRadius * NMath.Cos (alpha), outerRadius * NMath.Sin (alpha))); else path.LineTo (new CGPoint (outerRadius * NMath.Cos (alpha), outerRadius * NMath.Sin (alpha))); alpha += 0.5f * delta; path.LineTo (new CGPoint (innerRadius * NMath.Cos (alpha), innerRadius * NMath.Sin (alpha))); } return path; }
private NSBezierPath MosconeRooms() { var path = new NSBezierPath(); path.MoveTo(new CGPoint(553, -387)); path.LineTo(new CGPoint(426, -387)); path.LineTo(new CGPoint(426, -383)); path.LineTo(new CGPoint(549, -383)); path.LineTo(new CGPoint(549, -194)); path.LineTo(new CGPoint(357, -194)); path.LineTo(new CGPoint(357, -383)); path.LineTo(new CGPoint(411, -383)); path.LineTo(new CGPoint(411, -387)); path.LineTo(new CGPoint(255, -387)); path.LineTo(new CGPoint(255, -383)); path.LineTo(new CGPoint(353, -383)); path.LineTo(new CGPoint(353, -194)); path.LineTo(new CGPoint(175, -194)); path.LineTo(new CGPoint(175, -383)); path.LineTo(new CGPoint(240, -383)); path.LineTo(new CGPoint(240, -387)); path.LineTo(new CGPoint(171, -387)); path.LineTo(new CGPoint(171, -190)); path.LineTo(new CGPoint(553, -190)); path.LineTo(new CGPoint(553, -387)); path.MoveTo(new CGPoint(474, -141)); path.LineTo(new CGPoint(474, -14)); path.LineTo(new CGPoint(294, -14)); path.LineTo(new CGPoint(294, -141)); path.LineTo(new CGPoint(407, -141)); path.LineTo(new CGPoint(407, -145)); path.LineTo(new CGPoint(172, -145)); path.LineTo(new CGPoint(172, -141)); path.LineTo(new CGPoint(290, -141)); path.LineTo(new CGPoint(290, -14)); path.LineTo(new CGPoint(124, -14)); path.LineTo(new CGPoint(124, -141)); path.LineTo(new CGPoint(157, -141)); path.LineTo(new CGPoint(157, -145)); path.LineTo(new CGPoint(120, -145)); path.LineTo(new CGPoint(120, -10)); path.LineTo(new CGPoint(478, -10)); path.LineTo(new CGPoint(478, -145)); path.LineTo(new CGPoint(422, -145)); path.LineTo(new CGPoint(422, -141)); path.LineTo(new CGPoint(474, -141)); return(path); }
void AddPointToPath(CGPoint currentPoint) => currentPath.LineTo(currentPoint);
private NSBezierPath OutlineChamferProfilePath () { var path = new NSBezierPath (); path.MoveTo (new CGPoint (1, 1)); path.LineTo (new CGPoint (1, 0)); return path; }
private NSBezierPath MosconeRooms () { var path = new NSBezierPath (); path.MoveTo (new CGPoint (553, -387)); path.LineTo (new CGPoint (426, -387)); path.LineTo (new CGPoint (426, -383)); path.LineTo (new CGPoint (549, -383)); path.LineTo (new CGPoint (549, -194)); path.LineTo (new CGPoint (357, -194)); path.LineTo (new CGPoint (357, -383)); path.LineTo (new CGPoint (411, -383)); path.LineTo (new CGPoint (411, -387)); path.LineTo (new CGPoint (255, -387)); path.LineTo (new CGPoint (255, -383)); path.LineTo (new CGPoint (353, -383)); path.LineTo (new CGPoint (353, -194)); path.LineTo (new CGPoint (175, -194)); path.LineTo (new CGPoint (175, -383)); path.LineTo (new CGPoint (240, -383)); path.LineTo (new CGPoint (240, -387)); path.LineTo (new CGPoint (171, -387)); path.LineTo (new CGPoint (171, -190)); path.LineTo (new CGPoint (553, -190)); path.LineTo (new CGPoint (553, -387)); path.MoveTo (new CGPoint (474, -141)); path.LineTo (new CGPoint (474, -14)); path.LineTo (new CGPoint (294, -14)); path.LineTo (new CGPoint (294, -141)); path.LineTo (new CGPoint (407, -141)); path.LineTo (new CGPoint (407, -145)); path.LineTo (new CGPoint (172, -145)); path.LineTo (new CGPoint (172, -141)); path.LineTo (new CGPoint (290, -141)); path.LineTo (new CGPoint (290, -14)); path.LineTo (new CGPoint (124, -14)); path.LineTo (new CGPoint (124, -141)); path.LineTo (new CGPoint (157, -141)); path.LineTo (new CGPoint (157, -145)); path.LineTo (new CGPoint (120, -145)); path.LineTo (new CGPoint (120, -10)); path.LineTo (new CGPoint (478, -10)); path.LineTo (new CGPoint (478, -145)); path.LineTo (new CGPoint (422, -145)); path.LineTo (new CGPoint (422, -141)); path.LineTo (new CGPoint (474, -141)); return path; }
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; }
private NSBezierPath TextChamferProfile () { var profile = new NSBezierPath (); profile.MoveTo (new CGPoint (0, 1)); profile.LineTo (new CGPoint (1.5f, 1)); profile.LineTo (new CGPoint (1.5f, 0)); profile.LineTo (new CGPoint (1, 0)); return profile; }
public static NSImage ToTransformedCorners(NSImage source, double topLeftCornerSize, double topRightCornerSize, double bottomLeftCornerSize, double bottomRightCornerSize, CornerTransformType cornersTransformType, double cropWidthRatio, double cropHeightRatio) { double sourceWidth = source.CGImage.Width; double sourceHeight = source.CGImage.Height; double desiredWidth = sourceWidth; double desiredHeight = sourceHeight; double desiredRatio = cropWidthRatio / cropHeightRatio; double currentRatio = sourceWidth / sourceHeight; if (currentRatio > desiredRatio) { desiredWidth = (cropWidthRatio * sourceHeight / cropHeightRatio); } else if (currentRatio < desiredRatio) { desiredHeight = (cropHeightRatio * sourceWidth / cropWidthRatio); } topLeftCornerSize = topLeftCornerSize * (desiredWidth + desiredHeight) / 2 / 100; topRightCornerSize = topRightCornerSize * (desiredWidth + desiredHeight) / 2 / 100; bottomLeftCornerSize = bottomLeftCornerSize * (desiredWidth + desiredHeight) / 2 / 100; bottomRightCornerSize = bottomRightCornerSize * (desiredWidth + desiredHeight) / 2 / 100; float cropX = (float)((sourceWidth - desiredWidth) / 2); float cropY = (float)((sourceHeight - desiredHeight) / 2); var colorSpace = CGColorSpace.CreateDeviceRGB(); const int bytesPerPixel = 4; int width = (int)desiredWidth; int height = (int)desiredHeight; var bytes = new byte[width * height * bytesPerPixel]; int bytesPerRow = bytesPerPixel * width; const int bitsPerComponent = 8; using (var context = new CGBitmapContext(bytes, width, height, bitsPerComponent, bytesPerRow, colorSpace, CGBitmapFlags.PremultipliedLast | CGBitmapFlags.ByteOrder32Big)) { context.BeginPath(); using (var path = new NSBezierPath()) { // TopLeft if (cornersTransformType.HasFlag(CornerTransformType.TopLeftCut)) { path.MoveTo(new CGPoint(0, topLeftCornerSize)); path.LineTo(new CGPoint(topLeftCornerSize, 0)); } else if (cornersTransformType.HasFlag(CornerTransformType.TopLeftRounded)) { path.MoveTo(new CGPoint(0, topLeftCornerSize)); path.QuadCurveToPoint(new CGPoint(topLeftCornerSize, 0), new CGPoint(0, 0)); } else { path.MoveTo(new CGPoint(0, 0)); } // TopRight if (cornersTransformType.HasFlag(CornerTransformType.TopRightCut)) { path.LineTo(new CGPoint(desiredWidth - topRightCornerSize, 0)); path.LineTo(new CGPoint(desiredWidth, topRightCornerSize)); } else if (cornersTransformType.HasFlag(CornerTransformType.TopRightRounded)) { path.LineTo(new CGPoint(desiredWidth - topRightCornerSize, 0)); path.QuadCurveToPoint(new CGPoint(desiredWidth, topRightCornerSize), new CGPoint(desiredWidth, 0)); } else { path.LineTo(new CGPoint(desiredWidth, 0)); } // BottomRight if (cornersTransformType.HasFlag(CornerTransformType.BottomRightCut)) { path.LineTo(new CGPoint(desiredWidth, desiredHeight - bottomRightCornerSize)); path.LineTo(new CGPoint(desiredWidth - bottomRightCornerSize, desiredHeight)); } else if (cornersTransformType.HasFlag(CornerTransformType.BottomRightRounded)) { path.LineTo(new CGPoint(desiredWidth, desiredHeight - bottomRightCornerSize)); path.QuadCurveToPoint(new CGPoint(desiredWidth - bottomRightCornerSize, desiredHeight), new CGPoint(desiredWidth, desiredHeight)); } else { path.LineTo(new CGPoint(desiredWidth, desiredHeight)); } // BottomLeft if (cornersTransformType.HasFlag(CornerTransformType.BottomLeftCut)) { path.LineTo(new CGPoint(bottomLeftCornerSize, desiredHeight)); path.LineTo(new CGPoint(0, desiredHeight - bottomLeftCornerSize)); } else if (cornersTransformType.HasFlag(CornerTransformType.BottomLeftRounded)) { path.LineTo(new CGPoint(bottomLeftCornerSize, desiredHeight)); path.QuadCurveToPoint(new CGPoint(0, desiredHeight - bottomLeftCornerSize), new CGPoint(0, desiredHeight)); } else { path.LineTo(new CGPoint(0, desiredHeight)); } path.ClosePath(); context.AddPath(path.ToCGPath()); context.Clip(); } var drawRect = new CGRect(-cropX, -cropY, sourceWidth, sourceHeight); context.DrawImage(drawRect, source.CGImage); using (var output = context.ToImage()) { return(new NSImage(output, CGSize.Empty)); } } }
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(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(); }
public static XIR.Image RemoteRepresentation(this NSLineCapStyle obj) { // Customize the line cap style for the new object. var aPath = new NSBezierPath(); var lineWidth = 16; var sampleWidth = 100; // First we draw the presentation line aPath.LineWidth = lineWidth; aPath.MoveTo(new CGPoint(lineWidth, lineWidth)); aPath.LineTo(new CGPoint(lineWidth + sampleWidth, lineWidth)); switch ((NSLineCapStyle)obj) { case NSLineCapStyle.Square: aPath.LineCapStyle = NSLineCapStyle.Square; break; case NSLineCapStyle.Butt: aPath.LineCapStyle = NSLineCapStyle.Butt; break; case NSLineCapStyle.Round: aPath.LineCapStyle = NSLineCapStyle.Round; break; } // let's make sure we leave a little room for the line width drawing as well by adding the lineWidth as well var width = aPath.ControlPointBounds.Right + lineWidth; var height = aPath.ControlPointBounds.Bottom + lineWidth; var nsimage = new NSImage(new CGSize(width, height)); nsimage.LockFocus(); // We need to offset the image a little so it will not be cut off var transform = new NSAffineTransform(); transform.Translate(aPath.LineWidth / 2, aPath.LineWidth / 2); aPath.TransformUsingAffineTransform(transform); brush.Set(); aPath.Stroke(); // Second, we draw the inset line to demonstrate the bounds aPath.RemoveAllPoints(); lineWidth += lineWidth / 2; aPath.LineWidth = 2; aPath.MoveTo(new CGPoint(lineWidth, lineWidth)); aPath.LineTo(new CGPoint(lineWidth + sampleWidth, lineWidth)); pen.Set(); aPath.Stroke(); // Third, we draw the inset line endings which are two circles aPath.RemoveAllPoints(); var circleWidth = 2; aPath.LineWidth = circleWidth; aPath.LineCapStyle = NSLineCapStyle.Butt; aPath.AppendPathWithOvalInRect(new CGRect(lineWidth - (int)(circleWidth / 2), lineWidth - (int)(circleWidth / 2), circleWidth, circleWidth)); aPath.AppendPathWithOvalInRect(new CGRect(lineWidth + sampleWidth - (int)(circleWidth / 2), lineWidth - (int)(circleWidth / 2), circleWidth, circleWidth)); pen.Set(); aPath.Stroke(); nsimage.UnlockFocus(); return(nsimage.RemoteRepresentation()); }
public virtual void AddLineTo(CGPoint point) { path.LineTo(point); }