dynamically change circle size held in NSBezierPath
Posted in Apple, Uncategorized on July 26th, 2010 by Saba – Be the first to commentWhen a user decides to display a scatter plot, I iterate through all my points and add the x,y points to an NSBezierPath as such with a fixed width and height.
- (void) addCoord:(double) xval yCoord:(double) yval { NSRect rect = NSMakeRect(xval, yval, 1, 1);
[circlePath appendBezierPathWithOvalInRect:rect]; }
Then drawRect: gets called which draws my scatter plot coordinates. The problem is that, my circles are already drawn to a certain size and I need to scale my circles proportionately with my screen size and I don’t know what size this will be till drawRect: gets called (e.g. the user may be resizing the window).
…
NSBezierPath *copyPath = [circlePath copy];
// Move to center of screen. NSAffineTransform *xform = [NSAffineTransform transform]; [xform translateXBy:(bounds.size.width * 0.50) yBy:(bounds.size.height * 0.50)];
// Scale proportionately to screen size. [xform scaleBy:(xFactor / 2)];
[copyPath transformUsingAffineTransform:xform];
[[NSColor yellowColor] setStroke];
[copyPath stroke];
Anyone have suggestions on how to dynamically change my circle size for the points which are all held within an NSBezierPath?