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

svg.js

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg.js

A lightweight library for manipulating and animating SVG.

  • 2.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
924K
decreased by-1.25%
Maintainers
3
Weekly downloads
 
Created

What is svg.js?

svg.js is a lightweight library for manipulating and animating SVG (Scalable Vector Graphics) elements. It provides a simple and intuitive API for creating, modifying, and animating SVG elements, making it easier to work with SVGs in web applications.

What are svg.js's main functionalities?

Creating SVG Elements

This feature allows you to create SVG elements such as rectangles, circles, and lines. The code sample demonstrates how to create an SVG canvas and add a rectangle to it.

const draw = SVG().addTo('body').size(300, 300);
const rect = draw.rect(100, 100).attr({ fill: '#f06' });

Animating SVG Elements

This feature enables you to animate SVG elements. The code sample shows how to animate the fill color of a rectangle over a duration of 1000 milliseconds.

rect.animate(1000, '<>').attr({ fill: '#0f9' });

Transformations

This feature allows you to apply transformations such as moving, rotating, and scaling to SVG elements. The code sample demonstrates how to move, rotate, and scale a rectangle.

rect.move(50, 50).rotate(45).scale(1.5);

Event Handling

This feature lets you attach event handlers to SVG elements. The code sample shows how to change the fill color of a rectangle when it is clicked.

rect.on('click', function() { this.fill({ color: '#f93' }); });

Other packages similar to svg.js

Keywords

FAQs

Package last updated on 27 Mar 2017

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