SVG.js v3.2
SVG.js v3.2

原始链接: https://svgjs.dev/docs/3.2/

## SVG.js:一个轻量级的 SVG 操作库 SVG.js 是一个快速且小型的 JavaScript 库,旨在创建和动画化可缩放矢量图形 (SVG)。它几乎完全覆盖了 SVG 规范,*无需*任何外部依赖。 主要优点包括**速度**——明显快于许多竞争库,虽然不如纯 JavaScript 快——以及**简洁明了的语法**。与冗长的原生 JavaScript SVG 创建相比,SVG.js 显著减少了代码长度和重复,使开发更轻松、更易读。 例如,使用 SVG.js 创建一个简单的填充正方形只需要两行代码,而使用标准 JavaScript 则需要十行。它也适用于复杂的动画。 SVG.js 是开源的,并采用 MIT 许可证。

``` Hacker News新版 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交登录SVG.js v3.2 (svgjs.dev)14 分,作者 eustoria 56 分钟前 | 隐藏 | 过去 | 收藏 | 讨论 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索: ```
相关文章

原文

The lightweight library for manipulating and animating SVG.

Star

Why choose SVG.js?

SVG.js has no dependencies and aims to be as small as possible while providing close to complete coverage of the SVG spec. If you're not convinced yet, here are a few highlights.

It's speedy.

SVG.js is fast. Obviously not as fast as vanilla js, but many times faster than the competition:

Index:

  • rects: generate 10000 rects
  • fill: generate 10000 rects with fill color
  • gradient: generate 10000 rects with gradient fill

Less is better. Tested on an Intel Core i7-4702MQ @ 2.2GHz.

Easy readable, uncluttered syntax.

Creating and manipulating SVG using JavaScript alone is pretty verbose. For example, just creating a simple pink square requires quite a lot of code:

SVG.js provides a syntax that is concise and easy to read. Doing the same as the vanilla js example above:

// SVG.js
var draw = SVG().addTo('#drawing')
  , rect = draw.rect(100, 100).fill('#f06')

That's just two lines of code instead of ten! And a whole lot less repetition.

Go crazy with animations

There is more...

License

SVG.js is licensed under the terms of the MIT License.

Changelog

Wondering what has changed in the latest releases? Have a look at the change log.

联系我们 contact @ memedata.com