Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 797 Bytes

README.md

File metadata and controls

34 lines (29 loc) · 797 Bytes

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