W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2013

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

From: Stephen White <senorblanco@chromium.org>
Date: Sat, 10 Aug 2013 08:42:42 -0400
Message-ID: <CAPeKFTjiznMfTCSY-kJTB1CHYmh5SdU=kt8uZW0TuxyWuX1m_w@mail.gmail.com>
To: Glenn Maynard <glenn@zewt.org>
Cc: WHAT Working Group <whatwg@whatwg.org>, bdahl@mozilla.com, Rik Cabanier <cabanier@gmail.com>, w3c@junglecode.net
On Sat, Aug 10, 2013 at 1:07 AM, Glenn Maynard <glenn@zewt.org> wrote:

> On Fri, Aug 9, 2013 at 11:07 PM, Rik Cabanier <cabanier@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:


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


> --
> Glenn Maynard
Received on Saturday, 10 August 2013 12:43:08 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:23 UTC