14

我在网上找到了一个甚至可以和IE6一起使用的向量库!

http://raphaeljs.com/index.html

太奇妙了。

现在我的问题是它比即将到来的 HTML5 <canvas> 更好吗?我问的唯一原因是,Microsoft 实现不需要插件即可运行的 <canvas> 可能需要数年时间。

直到互联网上的所有 IE 用户都摆脱他们的旧浏览器,我们甚至可以证明使用 HTML5 <canvas> 的时间更长。

我一直在坚持标准,但是由于 MS 浏览器开发缓慢,这将花费太长时间。

想法?

4

5 回答 5

20

Raphael is a vector graphics library, done using SVG, whereas HTML5 canvas is bitmap graphics.

If you want to do vector graphics, I think going with Raphael is probably a good choice over "just" canvas. As you say, canvas does not quite work with IE and it will probably be a while before it's natively supported. If Raphael does what you need, there is no particular reason not to use it.

Do note that there are also other libraries for this: Excanvas, which emulates canvas for IE using VML (as far as I know), and also some others which do the same with Silverlight and Flash but I forgot their names.

There's also Dojo, which has a component for abstracting canvas usage behind an easy to use interface, which also supports IE.

Having native canvas in all browsers will not make the libraries obsolete, since the libraries usually abstract some of the canvas complexities away, making the usage easier.

于 2009-09-17T21:43:46.663 回答
5

Google 的SVGWeb ( http://code.google.com/p/svgweb/ ) 是您想要的。它使 IE 与标准 SVG 兼容,所有其他主流浏览器都已支持该标准。换句话说,正如 google 所说,“使用库和原生 SVG 支持,您可以立即定位现有已安装 Web 库的约 95%。”

于 2009-09-17T22:07:15.700 回答
5

您可以使用http://code.google.com/p/explorercanvas/在 IE 中实现 HTML5 Canvas 标准。你要做的就是添加:

<head>
<!--[if IE]><script src="excanvas.js"></script><![endif]-->
</head>

Canvas 和 SVG 的区别解释如下:

SVG 和画布并不是真正可互换的技术。SVG 是一种保留模式图形,其中所有内容都来自一个相当抽象的模型(SVG 文档)。另一方面,画布是一种即时模式图形,没有模型,客户端(JavaScript)必须负责重绘、动画等。

于 2009-12-24T17:39:24.480 回答
4

答案取决于您需要什么:

  • 如果您需要向图形对象添加事件处理程序:您需要使用 SVG。其他帆布。

  • 如果不需要事件,则性能很重要:如果是,则 Canvas 5。

请注意,与其他浏览器相比,IE 9 支持 Canvas 并提供更多 HTML 5 支持!

于 2011-05-20T15:24:09.980 回答
0

正在搜索“raphael vs canvas”,这里的帖子已有 5 年历史。从那以后有什么改变吗?拉斐尔过时了吗?

于 2015-01-28T22:51:35.280 回答