
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
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.
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' }); });
D3.js is a powerful library for creating data-driven documents using HTML, SVG, and CSS. It provides extensive capabilities for data visualization and manipulation, making it more complex but also more versatile compared to svg.js.
Two.js is a lightweight 2D drawing library for modern web browsers. It supports SVG, Canvas, and WebGL renderers. Compared to svg.js, Two.js offers a broader range of rendering options but may be less specialized in SVG manipulation.
A lightweight library for manipulating and animating SVG, without any dependencies.
SVG.js is licensed under the terms of the MIT License.
npm install svg.js
yarn add svg.js
bower install svg.js
https://cdnjs.com/libraries/svg.js
Check https://svgjs.com/ to learn more.
FAQs
A lightweight library for manipulating and animating SVG.
We found that svg.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.