Hi There,

We have a feature in our application wherein we have to draw a 1 pixel line. This drawing also varies relative to the zoom factor of our view. For example if we are drawing at a zoom factor of 200% we draw 0.5 pixel line. ( basically: 1/zoomfactor width of line; 1 if the zoomfactor < 100 ).

For most of the times we succeed in drawing the 1 pixel line. However after we change the zoom factor, our drawing fails. Our 1 pixel
line is now drawn in 2 pixels.
For example: On changing the zoom values from say 100% to 300% and back to 100% again, the single pixel line sometimes draw in 2 pixels. Even if the stroke width is set to 0.0 or 1.0, the stroked line will draw 2 pixels.

We have referred to the earlier posts in the mailing list and tried the alternatives mentioned there. We have used NSFrameRect of width or height equal to 1.
But on changing to zoom value to 66.7%, the line again draws 2 pixels.

Following is how our code looks like:
[NSGraphicsContext saveGraphicsState];
[[NSGraphicsContext currentContext] setShouldAntialias: FALSE];
NSRect rect = NSMakeRect(100.0, 100.0, 1.0, 200.0); //hardcoded for testing
NSFrameRect(rect);
[[NSGraphicsContext currentContext] setShouldAntialias: TRUE];//maybe this is not required.
[NSGraphicsContext restoreGraphicsState];

Following is the code used to change the zoom factor of the view:
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize

Can you please give some inputs on this?

Thanks in advance.
Regards,
Sahana A


-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to