Skip to main content

HTML5 canvas Spline Tutorial

To create a spline (curved line) with Konva, we can instantiate a Konva.Line() object with the tension property.

For full list of properties and methods, see the Line API Reference.

import Konva from 'konva';

const stage = new Konva.Stage({
  container: 'container',
  width: window.innerWidth,
  height: window.innerHeight
});

const layer = new Konva.Layer();
stage.add(layer);

const line = new Konva.Line({
  points: [5, 70, 140, 23, 250, 60, 300, 20],
  stroke: 'red',
  strokeWidth: 15,
  lineCap: 'round',
  lineJoin: 'round',
  tension: 1
});

layer.add(line);