Re: NSAffineTransform scaleBy not scaling
Re: NSAffineTransform scaleBy not scaling
- Subject: Re: NSAffineTransform scaleBy not scaling
- From: Shane <email@hidden>
- Date: Mon, 30 Nov 2009 22:21:31 -0600
> But the order of operations you apply to the transform is the reverse of what you might think will happen. One way to simplify the maths slightly is to generate the graph path using a fixed reference bounds of 1 x 1, located at the origin. Then you can directly use your view's size and position to scale and translate.
>
I've got it down to this which actually does what I want, even when I
resize the window, with the exception that it's also scaling the
stroke path, which I don't want. I'm trying to keep the stroke path
the same size, even thought I resize and scale the entire NSBezierPath
to the view size. Having a little trouble figuring out how to do this.
- (void) drawRect:(NSRect) rect
{
float realBoundFactor = 0.9;
NSRect bounds = [self bounds];
float xFactor = (bounds.size.width * realBoundFactor) / (pointCount);
float yFactor = (bounds.size.width * realBoundFactor) / (pointCount);
[[NSColor blackColor] setFill];
[NSBezierPath fillRect:bounds];
NSAffineTransform *newTransform = [NSAffineTransform transform];
[newTransform translateXBy:20.0 yBy:20.0];
[newTransform scaleXBy:xFactor yBy:yFactor];
[newTransform concat];
[self drawAxes:rect];
[self drawError:rect];
return;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden