Questions tagged [nsbezierpath]

NSBezierPath is a class responsible for constructing and drawing paths in Cocoa.

150 questions
5
votes
1 answer

Is there an iOS equivalent of appendBezierPathWithArcWithCenter

I'm trying to draw a quarter circle in iOS. In Mac OS, it seems you can use appendBezierPathWithArcWithCenter but this doesn't seem to work in iOS. Does anyone know how to simply draw a quarter circle in iOS? Thanks
beev
  • 1,197
  • 2
  • 16
  • 33
5
votes
1 answer

Create NSBezierPath from bitmap outline

I would like to create a NSBezierPath object which corresponds to the outline of an arbitrary bitmap image. All my images are png solid monochrome shapes with transparent backgrounds. Here is an examplee: I want the bezier path of the outline of…
Nick Moore
  • 15,547
  • 6
  • 61
  • 83
5
votes
2 answers

How to determine if NSBezierPaths intersect in Cocoa?

I'm having a hard time figuring out how to determine the intersection of two NSBezierPath closed objects in cocoa. I did some research online and couldn't find the answer so far. Here is what I have. I need to write some kind of a method that would…
Eugene Gordin
  • 4,047
  • 3
  • 47
  • 80
5
votes
2 answers

Is there a way to get the x,y co-ordinates of all points of a NSBezierPath object?

If I have an NSBezierPath object, is there a way to get coordinates(x,y) of all the points drawn? I want to move an NSRect along the path.
Rakesh
  • 3,370
  • 2
  • 23
  • 41
4
votes
1 answer

What is the difference between NSRectFill and NSBezierPath(rect).fill

I know I can fill a rect using NSRectFill(bounds). However I wanted to preserve transparency for PDF output and I discovered that I can do that only with NSBezierPath(rect: bounds).fill() What is the difference (behind the scenes) of those two? func…
Marek H
  • 5,173
  • 3
  • 31
  • 42
4
votes
3 answers

How to create NSBitmapImageRep from scratch?

First off: I want to use NSBezierPath to draw some simple button artwork in my app, so I figure I should create an NSBitmapImageRep, get the CGImage, create an NSImage from that, and then call setImage: on the button. Correct me if I'm wrong. So I…
PopKernel
  • 4,110
  • 5
  • 29
  • 51
4
votes
1 answer

NSBezierPath with transparent fill

I've got a NSBezierPath that needs to have a semi-transparent fill. When I fill it with a solid color, I get the expected result. However, when filled with a semi-transparent color I get a path with a rounded stroke but an odd, rectangular fill. It…
nosedive25
  • 2,477
  • 5
  • 30
  • 45
3
votes
1 answer

NSString drawing vs. String as NSBezierPath drawing

I need to perform efficient hit testing against a (potentially huge) number of components so I've represented all my primitives as NSBezierPath instances. All working great so far. Now I'm having trouble converting NSString objects, in particular…
Jay
  • 6,572
  • 3
  • 37
  • 65
3
votes
1 answer

Cocoa: "Random" line between two points?

In my Cocoa hobby project (on OSX), I have a view with some points identified. Something like this: NSPoint pt1 = NSMakePoint(20,100); NSPoint pt2 = NSMakePoint(100,30); I would like to create a meandering line (that never crosses itself) between…
Clay
  • 2,949
  • 3
  • 38
  • 54
3
votes
1 answer

NSBezierPath Graph

I cannot figure out how to optimize the drawing of an NSView that contains a NSBezierPath. Let me try to explain what I mean. I have a line graph, made by about 40K points, that I want to draw. I have all the points and it's easy for me to draw once…
3
votes
1 answer

iPhone core animation - animate a NSBezierPath

I want to animate the drawing of a path as it is being drawn on the screen I am assuming Core Animation is the best way with a NSBezierPath however I am not sure on how to implement this. Basically the idea is to have a path from point A to point B…
Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
3
votes
2 answers

How to get pixel perfect drawing with cocoa

I'm trying to draw some of my UI elements in Cocoa, mainly icons for buttons, but I'm having great difficulty getting the kind of precision I'd like. I'm using super simple code like this to draw rectangles: [[NSColor redColor] set]; [NSBezierPath…
BenL0
  • 277
  • 1
  • 9
3
votes
1 answer

Convert CGPathRef to NSBezierPath

In Apple docs they give you code of how to convert NSBezierPath to CGPathRef. I need to convert the other way around, from CGPathRef to NSBezierPath. UIBezierPath has a property called cgPath so if I was working on iPhone that would not be a…
Bob Ueland
  • 1,804
  • 1
  • 15
  • 24
3
votes
0 answers

macOS Screen drawing on top of Keynote presentation mode

I have a Swift app for macOS that successfully draws on the desktop and other apps using a transparent view that is rendered on top: self.view.window!.level = Int(CGWindowLevelForKey(.maximumWindow)) and subclassed NSBezierPath. However when I try…
MikeGC
  • 31
  • 2
3
votes
2 answers

Using NSBezierPath addClip - How to invert clip

Using NSBezierPath addClip only limits drawing to inside the path used for clipping. I'd like to do the opposite - Only draw outside. - (void)drawRect:(NSRect)dirtyRect { NSBezierPath *dontDrawInThis = ...; //We want an opposite mask of…
Avishay Cohen
  • 2,418
  • 1
  • 22
  • 40
1
2
3
9 10