87 points · by neya · 14y ago · 20 comments
It's a shame that so much effort is put into an HTML5 page that is obviously trying to demonstrate the frameworks it is promoting and yet get the experience so awfully wrong on a touch screen device like the iPad.
However the page itself doesn't seem to use any of the frameworks it is promoting, and doesn't seem to do a lot of demonstrating as of yet. The full site is apparently coming soon though...
http://blogs.adobe.com/creativelayer/2012/02/28/html5-flash-...
the effects math is fine and all that, but...
the big mistake they are all doing is to work directly on the canvas instead of just taking a canvas as input and deliver another canvas as output (optional async to a callback).
said that, i'm currently working on a solution, a simple functional canvas lib, one canvas goes in, another canvas comes out. no side effects.
update: if somebody is interested, it's shared here https://github.com/franzenzenhofer/canwaste/blob/master/main... ... but it's explorative programming (meaning: i coded it drunk) so don't expect to much at this point.
...
var blurFilter = new BoxBlurFilter(32, 2, 2);
var margins = blurFilter.getBounds();
bmp = bmp.clone();
bmp.filters = [blurFilter];
// filters are only displayed when the display object is cached
// later, you can call updateCache() to update changes to your filters
bmp.cache(margins.x,margins.y,img.width+margins.width,img.height+margins.height);
bmp.x += bmp.x+img.width;
stage.addChild(bmp);
...
should be var blurcanvas = boxBlurFilter(originalcanvas,32,2,2);
and then, if we want to see it on the page (i.e. instead of the original canvas) $(originalcanvas).replaceWith(blurcanvas) //or any other jQuery mumbo jumbo
canvas are cheap. we must start wasting them.var s:Sprite = new Sprite();
s.graphics.beginFill("#000000",1);
s.graphics.drawRect(0,0,100,100);
root.stage.addChild(s);
s.filters = [new BlurFilter(4), new DropShadowFilter(2,2,4,"#000000",.8)]
And that's it. It's now automatically drawn to a hidden canvas, which becomes the only item on the Sprite's draw list, retaining the position and transform properties, parent and event hierarchy of the original Sprite. If you modify the Sprite later, re-filtering and re-caching happens automatically. And if you remove the filters, the original vector draw list is restored and the hidden canvas that fed the filtered version is emptied and deleted.
[Edit] Lol, oops. I just realized this is your site Grant...? so there's probably no way that's gonna happen, huh. Ah well.