Hey all,
I'm drawing a graphing line, looks like a wave within an NSView. The line looks fine, except that it's not scaled to the size of the window. So my problem is trying to figure out how to scale it to the window size and every time that the window is resized.
I currently have something like this, but my scaleXBy, yBy on the NSAffineTransform isn't working out so well.
Anyone know how to get the NSBezierPath to take up 90% of my NSView (leaving 10% bank for borders)?
Code:
- (void) drawRect:(NSRect) rect
{
NSRect bounds = [self bounds];
float xAxis = bounds.size.width * 0.9;
float yAxis = bounds.size.height * 0.9;
[[NSColor blackColor] setFill];
[NSBezierPath fillRect:bounds];
NSAffineTransform *newTransform = [NSAffineTransform transform];
[newTransform translateXBy:40.0 yBy:30.0];
[newTransform concat];
// can't seem to get this transform to work as expected.
[newTransform scaleXBy:xAxis yBy:yAxis];
[self drawAxes:rect width:xAxis height:yAxis];
[self drawGraph:rect];
return;
}