HeinrichApfelmus/threepenny-gui — pull request #69 by kfl (2014-01-13 15:16:44+00:00)
Title: First cut at and API for Canvas

Hi

I have made a direct, and thus low-level and highly stateful, API to the HTML `canvas` element.

Currently are the parts for drawing (filled or stroked) straight lines, arcs, and text implemented, documented, and (somewhat) tested.

The currently implemented API should be enough for implementing tic-tac-toe (as mentioned in issue #22). At least it is enough for making a pie chart (see `Pie.hs`).

Let me know if you have any comments or changes you would like to see before merging. I don't have strong opinions regarding the API "design".

Some somewhat open questions are:

* Rather than having a bunch on setter functions (like `setFont`, `setFillStyle`, ...), would it be better to have a general `set` function for setting properties on the context object. (If so, how can we avoid conflict with the `Core.set` function?).

* I tried to follow the API style you had started for `drawImage` using the `Vector` type for (x, y) coordinates. But I'm sure I like it for the full API.

* In general how should JS optional arguments be handled. See for example `arc` and `arcAC` functions that both bind to the JS function [`arc`][1].

[1]: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arc