p5 image() maps directly to 2 of 3 valid usages of drawImage() this pull request adds the thrid and final valid usage as defined here: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage
image(image, x, y);
image(image, x, y, width, weight)
image(image, sx, sy, sWidth, sHeight, x, y, width, height)
I've been using p5 to create some interactive games for the Kinect (https://github.com/mwcz/Kimotion), however one thing that p5 lacks that is essential for game creation is the ability to use sprite sheets for performance and efficiency. p5.play Sprites use image() to draw their image so the first step was adding the ability to use all the parameters of drawImage() in image(), and that's exactly what this Pull Request adds:
#941
See the live working examples here:
http://scripta.co/p5.js/examples/p5.Image/netherlandish_proverbs.html
http://scripta.co/p5.js/examples/p5.Image/animation.html
http://scripta.co/p5.js/examples/p5.Image/sprite-sheet.html
The new parameters are completely optional and follow the spec here: http://ow.ly/SDewA. Backward compatibility maintained and image() continues to work as it always has with default parameters, but you now also have the option to use the cropping parameters as well.




p5
image()maps directly to 2 of 3 valid usages ofdrawImage()this pull request adds the thrid and final valid usage as defined here: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImageI've been using p5 to create some interactive games for the Kinect (https://github.com/mwcz/Kimotion), however one thing that p5 lacks that is essential for game creation is the ability to use sprite sheets for performance and efficiency. p5.play Sprites use
image()to draw their image so the first step was adding the ability to use all the parameters ofdrawImage()inimage(), and that's exactly what this Pull Request adds:#941
See the live working examples here:
http://scripta.co/p5.js/examples/p5.Image/netherlandish_proverbs.html
http://scripta.co/p5.js/examples/p5.Image/animation.html
http://scripta.co/p5.js/examples/p5.Image/sprite-sheet.html
The new parameters are completely optional and follow the spec here: http://ow.ly/SDewA. Backward compatibility maintained and
image()continues to work as it always has with default parameters, but you now also have the option to use the cropping parameters as well.