Re: drawing 1 pixel wide lines
Re: drawing 1 pixel wide lines
- Subject: Re: drawing 1 pixel wide lines
- From: John Nestor <email@hidden>
- Date: Wed, 07 Aug 2002 18:50:43 -0400
If the line position is calculated as a float or double don't you need
to cast it to an integer before
adding the 0.5. That is what I have been doing and it works well. I
haven't tried it without the (int)
cast but I will shortly. I'll report results unless someone beats me to it.
Clark S. Cox III wrote:
>
On 08/07/2002 15:13, "Albert Russel" <email@hidden> wrote:
>
>
>How do you draw 1 pixel wide completely black vertical lines?
>
>
>
>[NSBezierPath setLineWidth: 0.0];
>
>[NSBezierPath setDefaultFlatness: 1.0];
>
>[NSBezierPath setLineCapStyle: NSButtLineCapStyle];
>
>[[NSColor blackColor] set];
>
>[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
>
>
>
>The above gives vertical lines that are more than 1 pixel wide, I believe to
>
>see 2, and the lines are a little transparent. I select the color black but
>
>the lines are gray. When I draw 2 lines at the same position it gets black.
>
>
>
>
Positions in Quartz refer to the grid *between* the pixels, so if you
>
stroke a line that lies completely on integer boundaries, it will actually
>
spill over in to two pixels, but with half the alpha. If you want to draw in
>
the pixels themselves (which it appears you do) offset your coordinates by
>
(0.5, 0.5)
_______________________________________________
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.