description
Inspired by a d3.js project ImageMap, I created a canvas version of it, which supports PC and mobile devices.
demo
Here is the online demo, select an image and move or touch screen
install
npm i circle-split
or include the source JS file directly
usage
initiate
var cs = '#mountNode' size: 300 minDiameter: 4 imageCenterType: 'cover' eventEnabled: true;
default options
var defaultOptions = size: 'auto' // will set mininum value of mountNode's width and height minDiameter: 2 // the circle can split until the diameter reaches to 2 px imageCenterType: 'contain' // designate the center type when put the image of the square box eventEnabled: true // enable touchmove and mouseove event;
public methods
// you can set image by path or an already loaded image elementcscs // set pure colorcs; // splitcs // split all circles into next levelcs // split all circles into target levelcs // split hit circle into next levelcs // split hit circle into target level, target level should be higher than circle's current level // you can bind and unbind event any timecscs // if you don't need this, please call destroy methodcs