Skip to content

erikthalen/jigsaw-puzzle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published