[whatwg] Antialiasing of line widths < 1 (was Re: Blurry lines in 2D Canvas (and SVG))

Stephen White senorblanco at chromium.org
Sat Aug 10 05:42:42 PDT 2013


On Sat, Aug 10, 2013 at 1:07 AM, Glenn Maynard <glenn at zewt.org> wrote:

> On Fri, Aug 9, 2013 at 11:07 PM, Rik Cabanier <cabanier at gmail.com> wrote:
>
>>
>>  Chrome seems ignore stroke widths that are smaller than 1 (which is
>>>> reasonable).
>>>>
>>>
>>> (That seems wrong to me--it should continue to draw based on pixel
>>> coverage--but that's a separate issue...)
>>>
>>
>>  Is it? Obviously you can't draw less than a pixel, but the user did
>> specify that he wants it too look black.
>>
>
> strokeStyle = "black" doesn't mean "every pixel in the stroke should be
> black".  It's the color of the pen.  If you draw over half of a pixel with
> a black pen, you get 50% grey.
>
> It'd be one thing if Chrome didn't antialias at all, but if Chrome is
> antialiasing a stroke with a lineWidth of 1.5, it doesn't make sense that
> it's not antialiasing a stroke with a lineWidth of 0.75.  I don't think
> this is strictly specified; the only mention of anti-aliasing is an example
> of how to do it (oversampling).
>

Chrome (well, Skia actually) uses a "hairline" mode for line widths < 1. It
draws a line of width 1, and uses the width to modulate the alpha.  I think
the idea is to prevent blotchiness/unevenness caused by undersampling or
missed coverage (Skia uses 16 samples of AA).

Here's an example: hairline on the left, .2 width path on the right:
http://jsfiddle.net/FWLZt/

Stephen

>
> This is tangental, though.  Might want to start another thread if you want
> to go over this more, or we'll derail this one...
>

Done.

>
>
> --
> Glenn Maynard
>
>


More information about the whatwg mailing list