How to update background color when doing loadPixels

Hi another question about the update the background color after i loadPixels and updatePixels. Its looks like some glitches about the background or loadPiexls function. here is my project look like right now Screenshot 2015-05-26 20.39.04

each line of the vertical pixels were random move up and down but it did not update the background so the pixels overlay on top of the last time update; compare to processing version: Screenshot 2015-05-26 20.39.44 or the video https://vimeo.com/84565395

and my code is like this var img; var noiseOff = 0.0; function preload() { img = loadImage("assets/OriginalPic_small.jpg"); } var halfimage; function setup() { //frameRate(30); createCanvas(1920, 371*2); cimage = createImage(1920, 371*4); img.loadPixels(); } function draw() { noiseOff = noiseOff +0.1; var offsetY = 100; cimage.loadPixels(); for (var x=0; x<cimage.width; x++) { var n = int(offsetY*noise(noiseOff+x)); for (var y=0; y<cimage.height; y++) { var r = x + (y+n*4)*cimage.width; cimage.pixels[r]=img.pixels[x + y*cimage.width]; } } cimage.updatePixels(); background(0); image(cimage, 0, 0); }

any idea? big thanks to you guys!

Answers

Sign In or Register to comment.