jakubfiala / atrament

A small JS library for beautiful drawing and handwriting on the HTML Canvas.
http://fiala.space/atrament/demo
MIT License
1.56k stars 115 forks source link

32 accept options #42

Closed dethe closed 5 years ago

dethe commented 5 years ago

Change Atrament constructor (and function) to accept either (selector, width, height, color) or (selector, config).

Fixes: jakubfiala#32

dethe commented 5 years ago

In case it isn't obvious I used @raphinesse's suggestion for making this a non-breaking change, so atrament() and new Atrament() work with either the old API or with a new options object. I did use rest and spread operators, but I figured we were already using let and const so it should work in the same browsers.

jakubfiala commented 5 years ago

@dethe amazing, thanks for this! I'm actually much more in favour of the config object, I wrote this library when I finished university so the current API isn't quite to my liking, too.

Doing it this way is ideal as it won't break compatibility.

dethe commented 5 years ago

Glad you liked it. I'd be interested in hearing how you would prefer the API to look, as I'm digging in now to add zoom / pan / rotate.