meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.55k stars 404 forks source link

Access to Progress Information #48

Closed bebraw closed 11 years ago

bebraw commented 11 years ago

Hi,

I need to crunch some pretty big images using Caman (think 5MP+). As this can take a while it would be nice to be able to provide some kind of progress information to the user. Currently I have a generic progress thinger (one of those animations) in place which I show while it's processing.

It would be nice if there was a way to provide more accurate information. I noticed you have a block renderer in place. Do you think it would make sense to expose some info related to it via some API? Basically I would like to have a callback that's triggered as a block has been finished. I guess it would be nice to pass the amount of currently finished blocks and the amount of total blocks to it. Those would get me started I think.

If you think this is something that should be added to Caman, I don't mind looking into it as far as we can agree on the API. Still got that curve thinger (#43) to finish (spent last week on vacation). :)

meltingice commented 11 years ago

There are now events that fire when a block starts and when it finishes. To use this, you can do:

Caman.Event.listen("blockFinished", function (info) {
  // info =>
  //    blockNum
  //    blocksFinished
  //    totalBlocks
});

The above will listen to all Caman instances. If you pass a Caman instance into the first argument, you can listen to events from only that instance.

bebraw commented 11 years ago

Awesome. Thanks. :)