How to draw a 1 pixel line?
How to draw a 1 pixel line?
- Subject: How to draw a 1 pixel line?
- From: Ted Lowery <email@hidden>
- Date: Wed, 25 Dec 2002 11:47:16 -0500
Hi all-
I'm struggling trying to draw a one-pixel line. I've experimented with
different values of lineWidth, and seems that I get a 2 pixel line.
What am I doing wrong? Documentation suggests: A width of 0 is
interpreted as the thinnest line that can be rendered on a particular
device. I've interrogated my points during the drawing, and though
they are floats, they are whole numbers.
- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];
[[NSGraphicsContext currentContext] setShouldAntialias:NO];
[NSBezierPath setDefaultLineWidth:0];
if (tracking) {
[[NSColor redColor] set];
[NSBezierPath strokeLineFromPoint:NSMakePoint(trackPoint.x,
bottom) toPoint:NSMakePoint(trackPoint.x, top)];
[NSBezierPath strokeLineFromPoint:NSMakePoint(left,
trackPoint.y) toPoint:NSMakePoint(right, trackPoint.y)];
}
if (dragging) {
NSRect r = [self convertToRect];
[[NSColor greenColor] set];
[NSBezierPath strokeRect:r];
}
}
What am I doing wrong? I'm viewing on a 17" flatscreen (Apple) monitor.
Also, is my usage of NSGraphicsContext ok here? Or should I put the
current context in a local variable, and then bracket the drawing by
save and restore?
Thanks.
And Merry Christmas to those who celebrate.
Cheers, Ted
_______________________________________________
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.