Re: How to draw a 1 pixel line?
Re: How to draw a 1 pixel line?
- Subject: Re: How to draw a 1 pixel line?
- From: Janek Priimann <email@hidden>
- Date: Thu, 26 Dec 2002 13:01:33 +0200
>
Translating by 0.5 seems to be the general solution, but I'm at loss how
>
to explain why these to expressions produce the same graphical result:
>
>
[NSBezierPath strokeRect:NSMakeRect(xPos + 0.5, yPos + 0.5, 14, 14)];
>
>
NSFrameRect(NSMakeRect(xPos, yPos, 15, 15));
>
>
Is the optimized NSFrameRect() clever enough to make this adjustment by itself?
>
>
It is obviously essential always to test your interface on a TFT screen
>
at some point.
>
>
Regards,
>
Bertil
Its all very simple. All the drawing functions use Quartz to draw graphics, but NSFrameRect translates the rect by 0.5 points also before drawing. So if you call NSFrameRect(NSMakeRect(10.5, 10.5, 20, 20)) you will get 2 pixel wide rect.
BTW those functions are quite fast(compared with the NSBezierPath), but you can draw even faster, because those functions need to get the current graphics context everytime before the drawing.
ala: CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
I also recommend to read all the documention about Quartz2D at:
http://developer.apple.com/techpubs/macosx/CoreTechnologies/graphics/Quartz2D/quartz2d.html#//apple_ref/doc/uid/20001394
-----------------------------------------
Hot Mobiil - helinad, logod ja piltsunumid!
http://portal.hot.ee
_______________________________________________
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.