• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to draw a 1 pixel line?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Question about document controlling
  • Next by Date: Re: Preference file for all the users
  • Previous by thread: Question about document controlling
  • Next by thread: Re: How to draw a 1 pixel line?
  • Index(es):
    • Date
    • Thread