macos - stroke a UIBezierPath creating another UIBezierPath with capStyle and lineThickness & friends baked in? - Stack

admin2025-05-01  2

I seem to recall an API I can’t locate, so maybe it was a fever dream and not something that exists.

I have a NSBezierPath and I want to convert it into a new NSBezierPath that “traces” the original including things like cap style and line thickness into a new NSBezierPath . (this is macOS not iOS, but to be honest if a iOS API exists and no macOS API let me know, maybe I can build an XPCService or something to get what I want...)

My ultimate goal is to use the bezier path to drive a laser cutter. So I want things like the cap style rendered into the bezier path not something I “have to set” because I don’t get to render into a CGContext and say “hey laser, do that!” I get to give it a series of line segments so cut between.

I’m 100% fine with “well you have to use a CGPath” or “you get a CGPath as output”.

(ok, so that is an intermediate goal, my actual goal is to cut a specific crescent like shape with rounded edges that a particular miniature base fits into...and I can dink around with bezier curves and try to get a pair that align more or less with what I want, but I can get all the way there right now with a single curve and rounded end caps...except I can merely turn that into pixels in a bit map, what I need is a vector including the rounded endocarps and line thickness...and if I’m right that there is some API that basically gives me all the power of stroking into a CGContext with some sort of vector output I’m sure I can use that for a lot of other shapes I’m doing “the hard way” right now)

转载请注明原文地址:http://www.anycun.com/QandA/1746104436a91728.html