nsbezierpath

Drawing varying line widths with NSBezierPath?

雨燕双飞 提交于 2020-07-18 05:16:33
问题 I would like to create a vector object that can be drawn with a pen tablet and will honor the pressure information from the pen (by increasing/decreasing line width appropriately). Now I know how to get the pressure info out of the NSEvent, but of course NSBezierPath doesn't support varying line widths. So I'm trying to generate a Bezier path that is the outline of my line, by calculating the perpendicular lines at the ends of the curve and connecting those with the very same curve. It nearly

Convert CGPathRef to NSBezierPath

可紊 提交于 2020-01-14 19:00:07
问题 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 problem, but I'm working on MacOS. This must be an old question, and I was sure to find an answer on Internet but no luck. Could be I'm missing something. Any help appreciated. 回答1: Old question but I'm sure this will still be helpful for others. (You

Is there an iOS equivalent of appendBezierPathWithArcWithCenter

ぃ、小莉子 提交于 2020-01-13 12:04:12
问题 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 回答1: There are two iOS equivalents, one for UIBezierPath and one for CGPath : UIBezierPath equivalent UIBezierPath *path = [UIBezierPath bezierPath]; [path addArcWithCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; CGPath equivalent

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

若如初见. 提交于 2019-12-31 09:43:30
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . 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

Turn a BezierPath into an SVG file

久未见 提交于 2019-12-25 00:59:51
问题 I have a NSBezierPath produced from code below, and I want to turn this path into a svg file (see the svg code below) that I can import into Adobe Illustrator. Any ideas how to do this? BezierPath description NSColor* color0 = [NSColor colorWithCalibratedRed: 0 green: 0 blue: 0 alpha: 1]; { //// Bezier Drawing NSBezierPath* bezierPath = [NSBezierPath bezierPath]; [bezierPath moveToPoint: NSMakePoint(2, 30.41)]; [bezierPath curveToPoint: NSMakePoint(8.41, 1.91) controlPoint1: NSMakePoint(5.73,

Redrawed inset NSShadow on a Custom View using -setClip method

和自甴很熟 提交于 2019-12-22 13:59:10
问题 I have and odd problem, related with the answer of this question: Draw an Inset NSShadow and Inset Stroke I use this code into the drawRect method of a custom view. I have exactly this: - (void)drawRect:(NSRect)rect { // Create and fill the shown path NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:4.0f yRadius:4.0f]; [[NSColor colorWithCalibratedWhite:0.8f alpha:0.2f] set]; [path fill]; // Save the graphics state for shadow [NSGraphicsContext

Can I use CALayer to speed up view rendering?

会有一股神秘感。 提交于 2019-12-21 02:31:10
问题 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

Rounded rect on NSView that clips all containing subviews

ε祈祈猫儿з 提交于 2019-12-20 17:41:12
问题 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

Rounded rect on NSView that clips all containing subviews

百般思念 提交于 2019-12-20 17:40:03
问题 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

Filter on CALayer except for a shape which is an union of (non necessarily distinct) rectangles

a 夏天 提交于 2019-12-12 15:11:19
问题 I want to apply a CIFilter to a CALayer except for an area which is an union of rectangles. I post my not working code, it does exactly the opposite, i.e. the filter is applied only in the rectangles and not outside! func refreshTheFrameWithEffect() { self.layer!.masksToBounds = true self.layerUsesCoreImageFilters = true self.layer!.needsDisplayOnBoundsChange = true let filter = CIFilter(name: "CICircleSplashDistortion") filter!.setDefaults() self.layer!.backgroundFilters = [filter!] var