jigsaw-puzzle

1.1.13 • Public • Published

demo

yarn add jigsaw-puzzle
import { puzzle } from 'jigsaw-puzzle'

const p = await puzzle({
  element: '#app',
  image: 'image.jpg',
  /* ...optionalParameters */
})

const optionalParameters = {
  pieces: { x: 6, y: 4 },
  attraction: 5,   // distance to snap pieces
  aligned: true,   // don't overlap pieces on start
  zoom: 0.5,       // initial zoom of context
  beforeInit: canvas => {},
  onInit: state => {},
  onChange: state => {},
  onComplete: state => {}
}

p.newGame()              // start over
let state = p.getState() // save game
p.setState(state)        // load game
p.destroy()              // kill puzzle
p.getZoom()              // current zoom
p.setZoom()              // set zoom
p.centralize()           // pan to center

Readme

Keywords

Package Sidebar

Install

npm i jigsaw-puzzle

Weekly Downloads

17

Version

1.1.13

License

none

Unpacked Size

38.4 kB

Total Files

6

Last publish

Collaborators

  • erikthalen