snapsvg--关于用来操作svg的js库(1)
来源:互联网 发布:linux 中文字体 ttf 编辑:程序博客网 时间:2024/05/16 14:29
apsvg.js 是干嘛的?
这个是一个通过js来操作svg元素的javascript库,它的官网是:http://snapsvg.io/,他可以动态的获取元素并修改元素属性等,下面来看下官网给出的示例。
// First lets create our drawing surface out of existing SVG element// If you want to create new surface just provide dimensions// like s = Snap(800, 600);var s = Snap("#svg");
那么这就是创建一个最简单的Snap元素了,它会在html页面中id为svg的标签中创建一个svg元素。
而用过svg的都知道,对于svg的操作,基本就是对图元在操作,例如:矩形、圆、椭圆、线条、多边形、折现、路径等这些基本的图形。
再来看几个例子吧。
1.创建一个圆
var s = Snap("#svg");var bigCircle = s.circle(150, 150, 100);
2.创建圆并设置填充和边线的颜色
// First lets create our drawing surface out of existing SVG element// If you want to create new surface just provide dimensions// like s = Snap(800, 600);var s = Snap("#svg");// Lets create big circle in the middle:var bigCircle = s.circle(150, 150, 100);// By default its black, lets change its attributesbigCircle.attr({ fill: "#bada55", stroke: "#000", strokeWidth: 5});
// First lets create our drawing surface out of existing SVG element// If you want to create new surface just provide dimensions// like s = Snap(800, 600);var s = Snap("#svg");// Lets create big circle in the middle:var bigCircle = s.circle(150, 150, 100);// By default its black, lets change its attributesbigCircle.attr({ fill: "#bada55", stroke: "#000", strokeWidth: 5});// Now lets create another small circle:var smallCircle = s.circle(100, 150, 70);// Lets put this small circle and another one into a group:var discs = s.group(smallCircle, s.circle(200, 150, 70));// Now we can change attributes for the whole groupdiscs.attr({ fill: "#fff"});
来自搞起博客搞起博客 - snapsvg--关于用来操作svg的js库(1)
0 0
- snapsvg--关于用来操作svg的js库(1)
- svg的js库
- 关于H5标签SVG的了解和说明,以及svg.js库的使用
- svg DOM的一些js操作
- js操作svg
- js操作svg旋转
- 基于svg.js实现可编辑的图像(1)
- 使用Hammer.js操作svg
- js操作svg整体缩放
- JavaScript操作SVG画图库:基于jquery的插件jquery.svgmagic.js
- JavaScript操作SVG画图库:基于jquery的插件jquery.svgmagic.js
- Study JavaScript《JS操作SVG的一些知识》
- svg.js的使用
- js svg的事例
- SVG的字体操作
- 关于SVG的中文
- 关于SVG的中文
- 关于SVG的viewBox
- 要想提高工作效率,请拒绝做这7种事
- 关于memset函数
- c++实现字符串复制函数strcpy()
- 指针数组和数组指针
- textAppearance字体大小
- snapsvg--关于用来操作svg的js库(1)
- MyEclipse 10.7.1 最新版官网下载地址
- char a[100]数组指定大小必须用常量
- Japan(树状数组)
- C语言realloc,malloc,calloc的区别
- 求一个字符串中连续出现次数最多的子串
- 打开 EBS Form 的时候报错: Unable to authenticate session.
- 用excel解析wireshark log中的TCP发送窗口
- 马士兵struts2视频教程第十九集