Tests

These are the tests of the library. All tests before "Drawing tests on JsOfOCairo" should pass. The drawing tests compare an image generated by Cairo with a drawing made on an HTML5 canvas, pixel-wise. It's expected that some will fail with a few different pixels. It depends heavily on implementation details, for example the browser used to run the tests, and the version of Cairo used to generate the reference images.

Limitations

This is a demonstration of things that behave differently in JsOfOCairo and Cairo. They are due to different behavior of the underlying CanvasRenderingContext2D API. If you have concrete ideas on how to improve that, please open an issue.

Please see the ReadMe for rules to follow to avoid them.

Arcs on more than a full turn

If an arc spans more than a full turn, HTML5 reduces it to exactly one turn. The current point exposed through Path.get_current_point is inconsistent with the internal state of the canvas. The HTML5 and Cairo behaviors are different, and the HTML5 canvas interface doesn't expose the current point. This inconsistency is exposed if you use a function like line_to after an arc of more than one full turn.

Text and font extents

The HTML5 canvas interface doesn't expose functions to measure text and fonts, so this library contains approximations of get_text_extents and get_font_extents.

Text

Text is displayed differently according to available fonts.

Use two contexts targeting a single canvas

There is only one context associated with an HTML5 canvas. getContext always returns the same object. Thus, if you create two JsOfOCairo.contexts on the same canvas, changes made on one are replicated on the other. And because JsOfOCairo keeps some state to mirror the internal state of the HTML5 canvas, this leads to inconsistencies.

The transformation made on the first HTML5 context impacts the second:

The line cap set on the first HTML5 context impacts the second. Same goes for other settings: