0.3.5 • Published 4 years ago

svgbuild v0.3.5

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

SVG utils

This is a simple module that provides a basic API to create SVG documents.

The module is currently WIP and doesn't support all functionalities provided by SVG.

Installation

npm i svgbuild

Usage

The API is chainable and every operation mutates the internal state of the SVG object, so you can create multiple shapes in one go or add shapes in different steps.

Invoke the .toString() method to get a full SVG document that you can save to a file or display in a browser.

const svgBuild = require('svgbuild');

// create svg object
const svg = svgBuild(400, 400);

// add a polygon
svg.polygon([
    { x: 10, y: 20 },
    { x: 20, y: 20 },
    { x: 20, y: 10 }
], { stroke: 'rgb(100, 100, 200)' });

// add a circle and create the SVG string
const svgString =
    .circle({ x: 10, y: 20 }, 5, { stroke: 'rgb(100, 100, 200)' })
    .toString();

Methods

polygon

svg.polygon(points[, style[, props]])

circle

svg.circle(point, radius[, style[, props]])

text

svg.text(text, position[, style[, props]])

line

svg.line(point1, point2[, style[, props]])

add

svg.add(content)

el (generic element)

const x = el(type[, style[, props[, content]]])

toString

toString()

0.3.5

4 years ago

0.3.4

4 years ago

0.3.2

4 years ago

0.3.3

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago