Raphaël 介绍
Raphaël.js 是一个小型的 JavaScript
库,用来简化在页面上显示向量图的工作。你可以用它在页面上绘制各种图表、并进行图片的剪切、旋转等操作。
Raphaël.js 使用SVG
W3C推荐标准和VML作为创建图形的基础。这意味着你创建的每一个图形对象也是一个DOM对象,所以你可以附加JavaScript事件处理程序或以后
对其进行修改。Raphaël.js目标是提供一个适配器,绘制矢量图兼容大部分浏览器。目前支持的浏览器 Firefox 3.0+, Safari 3.0+,
Chrome 5.0+, Opera 9.5+ and Internet Explorer 6.0+。
示例代码:
// Creates canvas 320 × 200 at 10, 50 var paper = Raphael(10, 50, 320, 200); // Creates circle at x = 50, y = 40, with radius 10 var circle = paper.circle(50, 40, 10); // Sets the fill attribute of the circle to red (#f00) circle.attr("fill", "#f00"); // Sets the stroke attribute of the circle to white (#fff) circle.attr("stroke", "#fff");
在线效果演示:http://raphaeljs.com/pie.html