Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svgbuild

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgbuild

Chainable SVG builer

  • 0.3.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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()

Keywords

FAQs

Package last updated on 12 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc