lmccart/p5.js — pull request #114 by tafsiri (2014-02-15 06:25:29+00:00)
Title: PImage improvements

Hi All,

Here is a pull request for some changes i've made to PImage to improve structure and add functionality (trying to mirror the processing PImage spec). Give a look / try and let me know what you think. Hopefully it fits with the direction you wanted PImage to go. Check out examples/pimages to see it in operation.

Improves #43. One note regarding that discussion is that in this version, the pixels[] array is not automatically filled. There wasn't really any need to from what i could tell. If this is what automatic pixel loading refers to in #92, then this disables it. Let me know if you think it needs a flag to enable it (or vice versa); I just didn't see a need while implementing it to fill that array without the user doing an operation that explicitly requests it (most don't).

I've included the message from the main commit below, that summarizes the changes.

```
Effectively a rewrite/refactor of PImage. PImage's are now backed by a (non-rendered) canvas. Greater coverage of the PImage api.

PImages now use a backing canvas as their primary image representation, This change allows for more flexible manipulation of PImages,
and most of the PImage api is now implemented. Organizationally, the global drawing functions that handle drawing images were also
moved to the image.js file. The filter operation is still not implemented, and the mask function is not complete as per the processing's
original spec (though it supports similar functionality). The save functionality also does not support naming the downloaded file and probably
bears articulating out how we want this to work in the context of the web. It also only supports jpg and png formats.

One thing that has been removed at the moment is preloadImage(). I couldn't quite figure out how that was supposed to work
or if we want to keep it around.

I've added some examples in examples/pimage, they appear part way between a test suite and a set of user facing examples and could
probably be cleaned up in future.
```