Created
March 5, 2015 21:05
-
-
Save robynitp/f9f00e80c90034334d1a to your computer and use it in GitHub Desktop.
Pixel manipulation in P5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var img; | |
function preload(){ | |
img = loadImage("lisa.png"); | |
} | |
function setup(){ | |
createCanvas(500,382); | |
image(img,0,0); | |
loadPixels(); | |
for (var i = 0; i < (width*height); i++) { | |
var index = i*4; | |
pixels[index] = 255; // red | |
pixels[index+1] = 255; // green | |
pixels[index+2] = 255; // blue | |
pixels[index+3] = 100; //alpha | |
// Note: you don't have to change ALL of the RGBA values. | |
// You could only change alpha to make the image more transparent | |
// or change only the blue to make it more or less blue | |
// Try commenting out some of the 4 lines for setting pixels and see what results you get. | |
} | |
updatePixels(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment