HTML5 canvas SVG Path Tutorial

To create an SVG path with Konva, we can instantiate a Konva.Path() object.

Paths are most commonly used when we want to export an SVG Path into an HTML5 Canvas path, or if we want to manifest complex drawings as a data string rather than creating a custom shape.

For a full list of attributes and methods, check out the Konva.Path documentation.

Konva Path Demoview raw
<!DOCTYPE html>

<script src="[email protected]/konva.min.js"></script>
<meta charset="utf-8">
<title>Konva Path Demo</title>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #F0F0F0;

<div id="container"></div>
var stage = new Konva.Stage({
container: 'container',
width: window.innerWidth,
height: window.innerHeight

var layer = new Konva.Layer();

var path = new Konva.Path({
x: 50,
y: 40,
data: 'M12.582,9.551C3.251,16.237,0.921,29.021,7.08,38.564l-2.36,1.689l4.893,2.262l4.893,2.262l-0.568-5.36l-0.567-5.359l-2.365,1.694c-4.657-7.375-2.83-17.185,4.352-22.33c7.451-5.338,17.817-3.625,23.156,3.824c5.337,7.449,3.625,17.813-3.821,23.152l2.857,3.988c9.617-6.893,11.827-20.277,4.935-29.896C35.591,4.87,22.204,2.658,12.582,9.551z',
fill: 'green',
scale: {
x: 2,
y: 2

// add the shape to the layer

// add the layer to the stage