javascript raphael.js 与 paper.js
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7780118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
raphael.js vs paper.js
提问by fancy
What are the main differences between raphael.js and paper.js?
raphael.js 和 paper.js 之间的主要区别是什么?
Are there any other libs out there I should look at? Any like these that focus more on CSS3 then SVG?
我应该看看其他的库吗?有没有像这样更关注 CSS3 而不是 SVG 的?
Thanks!
谢谢!
回答by Spudley
Raphael uses SVG. Paper use Canvas.
拉斐尔使用 SVG。纸使用画布。
That's the major difference.
这是主要的区别。
In terms of what you can do with them, Canvas and SVG each have their own place, and are good for different things (although they are both capable of doing each other's thing as well if you ask them to). From a purely functional point of view, you need to consider what you want to do with the library before you decide which one you go with.
就您可以用它们做什么而言,Canvas 和 SVG 各有各的地方,并且适用于不同的事情(尽管如果您要求它们,它们也都能够做彼此的事情)。从纯粹的功能角度来看,在决定使用哪个库之前,您需要考虑要对库做什么。
Browser compatibility is going to be a big issue, whichever one you use. This will possibly be a bigger issue than functionality, in fact.
浏览器兼容性将是一个大问题,无论您使用哪个。事实上,这可能是一个比功能更大的问题。
Raphael has an advantage on the desktop because it detects older versions of IE (as far back as IE6) and falls back to using VML instead of SVG. This means it has excellent compatibility on virtualyl all desktop browsers. Canvas simply isn't supported on older IEs, and the Paper.js people don't really seem too worried about it.
Raphael 在桌面上有优势,因为它可以检测旧版本的 IE(最早可以追溯到 IE6)并回退到使用 VML 而不是 SVG。这意味着它在 virtualyl 的所有桌面浏览器上具有出色的兼容性。旧版 IE 根本不支持 Canvas,而Paper.js 的人们似乎并不太担心它。
But on mobiles, Paper.js may be better, because Canvas has much better support on mobiles than SVG. SVG isn't supported on most Android devices at all. This is changing: Android 3.0 introduced SVG support, but most Android devices being sold even now come with v2.x, so it'll be a while before you can rely on SVG working on a mobile.
但是在移动设备上,Paper.js 可能会更好,因为 Canvas 对移动设备的支持比 SVG 好得多。大多数 Android 设备根本不支持 SVG。这正在发生变化:Android 3.0 引入了 SVG 支持,但即使现在销售的大多数 Android 设备都带有 v2.x,因此您还需要一段时间才能依靠 SVG 在移动设备上工作。
For more info about browser support, see the CanIUse site:
有关浏览器支持的更多信息,请参阅 CanIUse 站点:
Hope that helps.
希望有帮助。
回答by doctorless
The most obvious difference is that Raphael targets SVG, and Paper targets the Canvas element. It also appears that Paper has far greater advanced features, whereas Raphael is just core SVG elements, which can then be expanded upon with plugins. Arguably, it depends more on your need, and which environments you wish to target. Canvas works well on some mobile browsers, SVG barely works on mobile environments at all.
最明显的区别是 Raphael 以 SVG 为目标,Paper 以 Canvas 元素为目标。看起来 Paper 具有更高级的功能,而 Raphael 只是核心 SVG 元素,然后可以通过插件对其进行扩展。可以说,这更多地取决于您的需要,以及您希望针对哪些环境。Canvas 在某些移动浏览器上运行良好,而 SVG 在移动环境中几乎不运行。
As another side note: SVG, as I'm aware of it, is not hardware-accelerated in IE (9) or Firefox, and, again if my memory isn't failing me, Canvas is, at least in IE (9). As for IE 8 and below, you need a browser plugin, which most have, but it is a dependency to expect.
另一边注:SVG,据我所知,在 IE (9) 或 Firefox 中不是硬件加速的,而且,如果我的记忆没有让我失望,Canvas 是,至少在 IE (9) 中. 对于 IE 8 及更低版本,您需要一个浏览器插件,大多数都有,但它是一个可以预期的依赖项。
回答by mnowotka
Are there any other libs out there I should look at?
我应该看看其他的库吗?
Yes, you should have a look at processing.js!
是的,你应该看看processing.js!
And by the way - here is an excellent comparison between raphael.js, paper.js and processing.js: http://coding.smashingmagazine.com/2012/02/22/web-drawing-throwdown-paper-processing-raphael/
顺便说一句 - 这是 raphael.js、paper.js 和 processing.js 之间的一个很好的比较:http://coding.smashingmagazine.com/2012/02/22/web-drawing-throwdown-paper-processing-raphael /
And even code comparison of the same effect: http://zgrossbart.github.com/3gears/
甚至相同效果的代码对比:http: //zgrossbart.github.com/3gears/
回答by metatron
Are there any other libs out there I should look at?
我应该看看其他的库吗?
If you have experience in Flash development you might consider easel.jswhich provides you with some of the flash display mechanisms. Easel looks like a really nice lib to me.
如果您有 Flash 开发经验,您可以考虑使用easel.js,它为您提供了一些Flash 显示机制。Easel 对我来说是一个非常好的库。
Another interesting library is processingjs, unlike the other libs processingjs also does 3d stuff. (It's also good at 2d.) Unlike paper, raphael and easel processing doesn't handle user interaction out of the box.
另一个有趣的库是 processingjs,与其他库不同,processingjs 也做 3d 的东西。(它也擅长 2d。)与纸张不同,raphael 和画架处理不处理开箱即用的用户交互。
Both libraries use canvas.
两个库都使用画布。