nsbezierpath

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

感情迁移 提交于 2019-12-03 20:21:38
If i have a NSBezierPath object , is there a way to get co-ordinates(x,y) of all the points drawn. I want to move a NSRect along the path. An NSBezierPath doesn't define exactly which points it draws in, but it does contain the points needed to define its pieces. You can use the elementAtIndex:associatedPoints: method to get the points for each vector element in the path. To get each point in the path you would have to iterate over all of the elements and get the associated points. For straight lines, this method will give you the endpoint, but if you keep track of the previous point you can

How can i convert NSBezierPath to CGPath

放肆的年华 提交于 2019-12-03 08:14:45
问题 How can i convert between NSBezierPath to CGPath . Thanks. 回答1: Right from Apple documentation: Creating a CGPathRef From an NSBezierPath Object Here is the relevant code. @implementation NSBezierPath (BezierPathQuartzUtilities) // This method works only in OS X v10.2 and later. - (CGPathRef)quartzPath { int i, numElements; // Need to begin a path here. CGPathRef immutablePath = NULL; // Then draw the path elements. numElements = [self elementCount]; if (numElements > 0) { CGMutablePathRef

Can I use CALayer to speed up view rendering?

别来无恙 提交于 2019-12-03 08:01:29
I am making a custom NSView object that has some content that changes often, and some that changes much more infrequently. As it would turn out, the parts that change less often take the most time to draw. What I would like to do is render these two parts in different layers, so that I can update one or the other separately, thus sparing my user a sluggish user interface. How might I go about doing this? I have not found many good tutorials on this sort of thing, and none that talk about rendering NSBezierPaths on a CALayer. Ideas anyone? Your hunch is right, this is actually an excellent way

Rounded rect on NSView that clips all containing subviews

半世苍凉 提交于 2019-12-03 05:21:30
I am creating a NSView subclass that has rounded corners. This view is meant to be a container and other subviews will be added to it. I am trying to get the rounded corners of the NSView to clip all of the subview's corners as well, but am not able to get it. - (void)drawRect:(NSRect)dirtyRect { NSRect rect = [self bounds]; NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:self.radius yRadius:self.radius]; [path addClip]; [[NSColor redColor] set]; NSRectFill(dirtyRect); [super drawRect:dirtyRect]; } The red is just for example. If I add a subview to the rect, The

How to import/parse SVG into UIBezierpaths, NSBezierpaths, CGPaths? [closed]

和自甴很熟 提交于 2019-12-02 19:25:49
I am trying to import paths from a vector drawing program into the ios environment. I would like to get them into CGpaths or UIbezierpaths. I am most interested in importing paths from adobe illustrator. The best way seems to save as an svg and then import. I have found some resources for parsing exported SVG files that describe the paths. However, everything I have found only deals with absolute paths and not relative paths. The path below has capital C's and lowercase C's. I know how to parse the capital C (absolute paths) but I have no idea how to parse the lowercase c's (relative paths) I

How can I get NSScrollView to respect a clipping path

走远了吗. 提交于 2019-12-01 01:35:25
I am trying to make a NSScrollView with clipped corners, similar to the Twitter app: I have a NSScrollView subclass which I added the following code: - (void)drawRect:(NSRect)dirtyRect { NSBezierPath *pcath = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:kDefaultCornerRadius yRadius:kDefaultCornerRadius]; [path setClip]; [super drawRect:dirtyRect]; } I expected the content of the NSScrollView to have rounded corners, but it is not respecting the clipped path. How can I do this? UPDATE & CLARIFICATION I know how to make a custom NSScroller , I know how to make it transparent

How can I get NSScrollView to respect a clipping path

随声附和 提交于 2019-11-30 19:36:07
问题 I am trying to make a NSScrollView with clipped corners, similar to the Twitter app: I have a NSScrollView subclass which I added the following code: - (void)drawRect:(NSRect)dirtyRect { NSBezierPath *pcath = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:kDefaultCornerRadius yRadius:kDefaultCornerRadius]; [path setClip]; [super drawRect:dirtyRect]; } I expected the content of the NSScrollView to have rounded corners, but it is not respecting the clipped path. How can I do this

How to get a 1 pixel line with NSBezierPath?

孤者浪人 提交于 2019-11-28 22:57:22
问题 I'm developing a custom control. One of the requirements is to draw lines. Although this works, I noticed that my 1 pixel wide lines do not really look like 1 pixel wide lines - I know, they're not really pixels but you know what I mean. They look more like two or three pixels wide. This becomes very apparent when I draw a dashed line with a 1 pixel dash and a 2 pixel gap. The 1 pixel dashes actually look like tiny lines in stead of dots. I've read the Cocoa Drawing documentation and although

IOS : Animate transformation from a line to a bezier curve

南楼画角 提交于 2019-11-28 16:35:24
I would like to animate a straight line curving into a bezier curve (from "_" to "n"), is there a library somewhere that can help me to do it ? I know how to draw a Bezier curve with UIBezierPath, I could redraw rapidly and progressively do the transformation, but if something already does that it would be cool :-) I might do something with a CADisplayLink . For example, you could do this in your view controller using a CAShapeLayer , e.g.: #import "ViewController.h" #import <QuartzCore/QuartzCore.h> @interface ViewController () @property (nonatomic) CFTimeInterval firstTimestamp; @property

NSBezierPath drawing

喜夏-厌秋 提交于 2019-11-28 04:35:51
I want to do a rounded rectangle outline on an NSImage and I figured that using NSBezierPath would be the best way. However, I ran into a problem: instead of drawing a nice curve, I get this: For reasons I can't understand, NSBezierPath is drawing the rounded part with a darker color than the rest. Here's the code I'm using (inside a drawRect: call on a custom view): NSBezierPath* bp = [NSBezierPath bezierPathWithRoundedRect: self.bounds xRadius: 5 yRadius: 5]; [[[NSColor blackColor] colorWithAlphaComponent: 0.5] setStroke]; [bp stroke]; Any ideas? Edit: If I inset the path by 0.5 everything