npm install @joemaddalone/path
import Path from 'path';
const square = ({ x, y, size }) => {
return new Path()
.moveTo(x, y) // move pen to x, y
.right(size) // draw line right to relative "size" px
.down(size) // draw line down to relative "size" px
.left(size) // draw line left to relative "size" px
.close() // draw line back to first point
};
For every svg path command there is an equivalent command available in path.
And then for most of these is there is a semantically named helper method. Not required, but for complex paths it may be easier to read for those not familiar with path commmands.
Some additional path command helpers: