Re: erasing, redrawing NSBezierPath into and NSImage problem
Re: erasing, redrawing NSBezierPath into and NSImage problem
- Subject: Re: erasing, redrawing NSBezierPath into and NSImage problem
- From: Scott Thompson <email@hidden>
- Date: Tue, 6 Jul 2004 22:44:31 -0500
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.