Patch for better rendering of lines

5 views
Skip to first unread message

revulo

unread,
Oct 6, 2008, 12:55:17 PM10/6/08
to google-excanvas
Hi,

I have added some modifications to the VML version of excanvas.

* Changed the calculation method of line width.
An averaged line width is calculated from the determinant of matrix,
which is valid even when transform() method is implemented someday.

* Improved the rendering of lines.
Lines with the width less than 1px look better now.

* Fixed the bug that stroke() ignored lineCap, lineJoin and miterLimit
when fillStyle attribute was set.

* Removed the settings of strokeweight, strokecolor and fillcolor.
They are
unnecessary since they are overridden by the weight and color
attributes
in <v:stroke> and <v:fill>.

You can download the modified file and patch for trunk from my site:
http://download.revulo.com/Canvas/excanvas_linewidth.zip

It would be nice if this patch would be adopted.

Regards,

--
revulo

Steve Clay

unread,
Oct 6, 2008, 1:33:14 PM10/6/08
to google-...@googlegroups.com
revulo wrote:
> You can download the modified file and patch for trunk from my site:
> http://download.revulo.com/Canvas/excanvas_linewidth.zip

Revulo,
Could you create demonstration page of the fixed bugs, or are they
evident with the included demos?

--
Steve Clay
http://mrclay.org/

revulo

unread,
Oct 6, 2008, 3:00:35 PM10/6/08
to google-excanvas
Steve Clay wrote:
> Could you create demonstration page of the fixed bugs, or are they
> evident with the included demos?

OK. I prepared demo pages.

These testcases are examples of line width:

* http://sample.revulo.com/Canvas/testcases/arc.html
* http://sample.revulo.com/Canvas/testcases/quadraticcurve.html

And an example of which lineCap was ignored:

* http://sample.revulo.com/Canvas/clock/rev.37.html
* http://sample.revulo.com/Canvas/clock/trunk.html (Patched)

--
revulo

Erik Arvidsson

unread,
Oct 8, 2008, 3:02:24 AM10/8/08
to google-...@googlegroups.com
Thank you Revulo. The patch looks good and I applied it. We are now
at revision 38.

--
erik

revulo

unread,
Oct 19, 2008, 11:13:31 AM10/19/08
to google-excanvas
I noticed my patch might decrease the performance of stroke() command.
So I optimized my code and created a new patch.

http://download.revulo.com/Canvas/excanvas_linewidth_2.zip

In my previous patch, a scale factor for line width was calculated in
every stroke() command. That approach was not clever because the
factor remains constant unless scale() command is executed.

The new code, on the other hand, calculates the factor in the scale()
method along with arcScaleX_ and arcScaleY_. I think this code would
be faster in most cases.

--
revulo

Erik Arvidsson

unread,
Oct 20, 2008, 1:22:17 AM10/20/08
to google-...@googlegroups.com
Patched and submitted.

I inlined the method getLineScale_ since it was only used in one place.

--
erik

Chris Tan

unread,
Oct 23, 2008, 3:11:48 AM10/23/08
to google-excanvas
Great work revulo!

This really helps with one of my projects which uses quadratic curves.

Chris
Reply all
Reply to author
Forward
0 new messages