Skip to content

Svg for the puzzle pieces #86

Answered by flbulgarelli
Kanchana-Sara asked this question in Q&A
Discussion options

You must be logged in to vote

👋 Hi!

Please have a look at #76 - headbreaker does not offer explicit support for drawing pieces using svg, but using its custom outline interface.

However, if you want to add additional SVG components to the canvas, you could use Konva primitives: https://konvajs.org/docs/sandbox/SVG_On_Canvas.html.

Before doing that, you'll need to access the Konva's layer object provided with the default canvas: Canvas#__konvaLayer__.

const canvas = new headbreaker.Canvas('my-canvas', {
  width: 800, height: 800
});
canvas.autogenerate();
canvas.shuffle(0.7);
canvas.__konvaLayer__ // here you can start talking directly with Konva
canvas.draw();

Hope that helps!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by flbulgarelli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants