Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: erasing, redrawing NSBezierPath into and NSImage problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: erasing, redrawing NSBezierPath into and NSImage problem



On Jul 6, 2004, at 2:28 AM, Wilhelm Phillips wrote:

Hi,

The drawing code uses 6 regular points and 8 control points which are
calculated to fit with cell height and width while creating my desired
shape.

// points and control points established

[bezierPath moveToPoint:p1];
[bezierPath curveToPoint:p2 controlPoint1:c1 controlPoint2:c2];
[bezierPath curveToPoint:p3 controlPoint1:c3 controlPoint2:c4];
[bezierPath lineToPoint:p4];
[bezierPath curveToPoint:p5 controlPoint1:c5 controlPoint2:c6];
[bezierPath curveToPoint:p6 controlPoint1:c7 controlPoint2:c8];
[bezierPath closePath];

Depending on what kind of calculations you have to do to come up with your curve points, one option you might consider. Instead of recalculating the control points each time based on the new size of the label, calculate the points once and then, before you draw your label, use an NSAffineTransform to scale the drawing context to the size that is appropriate for the label.

That is to say, assume that your drawing is going to go to a label that is 100 x 100 and calculate the points for your bezier path. Then, instead of calculating a new set of points use an NSAffineTransform with a to scale the coordinate system by (actualWidth / 100, actualHeight / 100)

Is that clear as mud?

The point is that using this technique you should be able to eliminate the calculations of the coordinates because you only ever do them once. If they are right at one size then they should work at all sizes.

Scott
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: erasing, redrawing NSBezierPath into and NSImage problem (From: Wilhelm Phillips <email@hidden>)
 >Re: erasing, redrawing NSBezierPath into and NSImage problem (From: Yann Bizeul <email@hidden>)
 >Re: erasing, redrawing NSBezierPath into and NSImage problem (From: Wilhelm Phillips <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.