DEV Community

Discussion on: The JavaScript Iteration Protocols and How They Fit In

Collapse
 
riscie profile image
riscie

Hi Ken. This is a remarkable article. Really enjoyed reading it and I learned a lot about iterator and generator usage in js. It's a concept I was aware of but did not use in daily coding yet.

I personally love messing around with image manipulation using the HTML5 Canvas element. You can load up an image using the native Image object, then paint it to the canvas, grab its ImageData object, and directly manipulate pixel values.

So this sounds very interesting! Can you maybe point me to an example of yours where the whole process (loading the image, manipulating it etc.) is visible?

kindly, matthias

Collapse
 
kenbellows profile image
Ken Bellows • Edited

Just whipped one up real quick, here you go! It adds a bunch of extra blue to each pixel in an image.

I used an expanded version of the generator function in the post that persists changes made to each pixel back to the original ImageData object for easier image manipulation.

Collapse
 
riscie profile image
riscie

Very cool! Thank you for the example!