path

API

Install

npm install @joemaddalone/path

Basic Usage

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
};

Primitives

For every svg path command there is an equivalent command available in path.

Friendly

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.

Helpers

Some additional path command helpers: