Re: How do you draw a single pixel line?
Re: How do you draw a single pixel line?
- Subject: Re: How do you draw a single pixel line?
- From: "Clark S. Cox III" <email@hidden>
- Date: Thu, 15 Aug 2002 19:09:57 -0400
On 08/15/2002 18:16, "Paul Fox" <email@hidden> wrote:
>
>> From: Paul Fox <email@hidden>
>
>>
>
>> Are you guessing at the answer or do you know this works for sure?
>
>>
>
>> I tried 0.25, 0.20, 0.0 and same results each time.
>
>
>
> Okay, just dug out my good old test app again:
>
>
>
> There are more or less two possible ways to get thin diagonal lines with
>
> Quartz:
>
>
>
> 1) With anti-aliasing turned on, set the line width to 0.8 or 0.75. Setting
>
> the line width to a greater value will result in thick lines. Setting it to
>
> a smaller value will result in a barely visible line. The latter happens
>
> because the area covered by the line becomes smaller and smaller compared to
>
> the area of a single pixel, thus the pixels along the line are assigned a
>
> small coverage value which translates into a small alpha value.
>
>
>
> 2) With anti-aliasing turned off, set the line width to 0.1 or even 0.01.
>
>
>
> You may also try to play around with the context's stroke adjust value:
>
>
>
> void CGContextSetStrokeAdjust(CGContextRef ctx, int zeroOrOne)
>
>
>
> If this doesn't help, then I think nothing will...
>
>
>
> BTW: Quartz doesn't support zero-width lines like (D)PS. So, setting the
>
> line width to 0.0 in the anti-aliased case results in an invisible line and
>
> in the aliased case in a 1 pixel width line.
>
>
>
>
>
> Regards,
>
>
>
> Dietmar Planitzer
>
>
Thanks Dietmar - interesting and closer. Before I would get lines
>
with about 3 pixels on each row (this for an approx diagonal line, e.g.
>
from top-left of a window to bottom-right). Setting line width
>
to 0.1 or 0.01 reduces this to 'about' 2 pixels, e.g.
>
>
***
>
***
>
**
>
**
>
***
>
**
>
**
>
***
>
>
(copied from Pixie!)
>
>
CGContextSetStrokeAdjust seems to be undocumented on Apples web site
>
and on Google. I tried zeroOrOne set to zero and 1 and that made no
>
difference. I will play a bit more but it seems doomed to failure.
>
>
FYI - I am trying to draw a 'wavy' line like Microsoft Spell checking:
>
>
* *
>
* * * *
>
* * *.....
>
>
It needs to be this skinny to avoid 'standing' out too much. I could
>
do it with some form of bitmap or point by point drawing. For line drawing
>
I need fine grained control because any errors at this level of resolution
>
make it look awful.
I would think that this would be pretty wasy using an image of such a
wavy line, setting the color like so:
[[NSColor colorWithPatternImage: image] set];
and then drawing a 3-pixel tall, horizontal line.
--
Clark S. Cox III
_______________________________________________
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.