TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

HTML 5 canvas graphics library

55 点作者 djd超过 13 年前

9 条评论

simonsarris超过 13 年前
I'm always glad to see more canvas libraries, but the performance of this one is pretty horrendous. I'm writing a comprehensive canvas diagramming library that is now up to 70K lines and its no where near this slow.<p>In case the author reads these comments I'll mention a few I see at first glance:<p>They are doing things like setting the font every on single draw unnecessarily (which takes a surprising amount of time, performance-wise). Actually they are resetting nearly all of the canvas state by hand on each draw, which can just as easily be done in the much faster way by doing "canvas.width = canvas.width". But even that they shouldn't do if they can avoid it.<p>Similarly the author should not set the globalCompositeOperation all the time unless he or she really needs to.<p>I'm sure there are a lot of other low-hanging fruit that can be fixed. I'll try send the author an email later tonight. I hope they keep at it.
评论 #3270673 未加载
评论 #3270650 未加载
评论 #3270666 未加载
shashashasha超过 13 年前
How does the performance of this compare to other libraries like PaperJS (<a href="http://paperjs.org" rel="nofollow">http://paperjs.org</a>) or EaselJS (<a href="http://easeljs.com" rel="nofollow">http://easeljs.com</a>) or ProcessingJS (<a href="http://processingjs.org/" rel="nofollow">http://processingjs.org/</a> though I understand Processing doesn't really have a display list)?
评论 #3271392 未加载
mcantelon超过 13 年前
I made something similar a ways back (a little rough, but some fun features like defining sprites using ASCII characters):<p><a href="https://github.com/mcantelon/grout" rel="nofollow">https://github.com/mcantelon/grout</a><p>Here's a game I made with it:<p><a href="http://mikecantelon.com/demo/demo_blood_funnel.html" rel="nofollow">http://mikecantelon.com/demo/demo_blood_funnel.html</a>
DanielRibeiro超过 13 年前
Interesting. But I wonder why I'd use this instead of EaselJS: <a href="http://easeljs.com/" rel="nofollow">http://easeljs.com/</a>.
评论 #3272196 未加载
kreek超过 13 年前
This is great, it's similar to Flash's display list. I actually think a display list should be part of the canvas spec. There's really no reason to have a bunch of competing display list libs and it could be optimized if it was part of the browser.
Turing_Machine超过 13 年前
Cool...other than the parts that need click or keyboard input, all the demos seem to work, more or less, on my iPhone 4S (Canvas Creatures is pretty sluggish, though) and Kindle Fire (both Canvas Creatures and Snake are sluggish there, and Canvas Creatures looks a little weird, like the maybe the alpha channel isn't quite working. This may be a limitation of the Kindle display or browser; I haven't had it long enough to judge).<p>How about adding support for touch events and gestures? :-)
AshleysBrain超过 13 年前
Something like this with an alternative WebGL renderer would be cool! It can make it a lot faster - see a blog post I wrote on it: <a href="http://www.scirra.com/blog/58/html5-2d-gaming-performance-analysis" rel="nofollow">http://www.scirra.com/blog/58/html5-2d-gaming-performance-an...</a>
daniel-warner-x超过 13 年前
I miss Flash. I know it had big issues but this stuff makes for some hard livin'.
noduerme超过 13 年前
Okay. I wrote StrikeDisplay.blogspot.com which does what this is trying to do. I haven't had much time to work on it for awhile, but I try to keep an eye on developments in this area.<p>I reviewed the code. I think it's a good effort and it's on the right track, as far as developing a seamless parent/child display chain coupled with event chain for the kind of things we take for granted in Flash. It gets some things right; like apparently re-scoping mouse events with target and currentTarget, which is good if you're expecting methods listening for the events to be scoped in some other way than window or document.<p>The two issues I see with this library are serious deficiencies in performance -- which could be improved upon, of course, although some of the architecture requiring redraws on every frame is just inefficient as has been pointed out -- and also issues with the way bounding boxes are implemented and how collision/rollover checks are implemented. First of all, it useless to have rollovers always based on rectangles, especially if there aren't careful z-ordering methods. Secondly, having an inner and outer bounding box is a very slow method for traversing the redraws and checking events (so are a lot of other bb methods in canvas. everything's slower in canvas than in Flash). The closer to native browser bone you can cut on this, the better; my solution to click collision checks in StrikeDisplay was to implement a hidden canvas on top of the visible one, that duplicated everything drawn in white, everything else in black, and check the pixel color value of that canvas when the mouse clicked or went over anything inside a bounding box. This turned out to be a hell of a lot faster.<p>I'm happy to see these kinds of libs come out, because if we do have to give up all the comforts of flash or unity or javafx to develop in this nightmare DOM with nothing but a raw canvas, the sooner we can bridge the gap between visual-oriented coders and everyone else, the better for everybody. This one needs work, but I'd rather see something along these lines than most of the other stuff I've seen come out that's DOM-centric rather than based on a display chain.