On Jan 16, 2015, at 5:30 AM, Uli Kusterer <witness.of.teacht...@gmx.net> wrote:
> On 15 Jan 2015, at 07:58, Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: >> Putting those two ideas together leads to a better approach. Create the >> bezier path once, relative to an arbitrary bounding rect — say 1000 x 1000. >> (But any rect would do.) When you need to draw the path, set the CTM of the >> context to scale 1000 x 1000 (the reference bounds) to the context’s width x >> height (the view bounds). Then just draw the original path and AppKit will >> scale the bezier path for you. > > That's not the be-all end-all, though. Scaling the CTM scales line widths and > heights as well. So if you for example want to skew the path, you'd get lines > that are wider than they are tall (kind of calligraphic). Also, changing the > CTM means that mouse click coordinates will be in a different coordinate > system then your drawing, so if you’re e.g. implementing a graphics editor, > you'll have to manually translate the coordinates each time. > > A better idea might be to have a list of original objects and projected > objects. The list of projected objects is generated by transforming the > paths. Whenever your view's bounds change, you rebuild this list of projected > objects from the originals (thus keeping rounding errors etc. to a minimum as > they can't accumulate). The drawing code just draws this projected list. > > As I don't know where 'temp' comes from in N!K’s code, NSBezierPath* temp; is in the list of declarations. _path is created once, in -(id)initWithCoder:(NSCoder*)coder . _path is scaled to the new size and assigned to temp each time drawRect is called. Thus, there is no error buildup. > this may be what's already happening, in which case I find that a better > approach than mangling the CTM if your interest is in having a shape drawn > crisply in a window. If you're instead looking to scale a drawing (whether > vector or otherwise), where you want lines to be skewed, then Quincy.s > approach is preferrable. > > -- Uli Nick _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com