Hi, mates. I am kinda really new in Processing, but some things I already know and try to use it. Recently found an example
of changing brightness of camera's pixels (it's like a flashlight). The code works, all fine and nice. But when I try to change the size of window(not camera), it ruins evething (photo).
And don't know what to do. And one more thing what i saw. First we load all pixels, then cam.pixels. And in (loop in loop) we work with camera's pixels, but when we update Pixels, we update all pixels, not only from camera. And when i try to write cam.pixels[loc] = c; or cam.updatePixels(); it doesn't work, just gray screen. Could you help me or if know( i didn't found) links with similar problems. Thanks in advance. 
import processing.video.*;
// Step 2. Declare a Capture object
Capture video;
void setup() {
size(500, 500);
video = new Capture(this, 320, 240,30);
video.start();
}
// An event for when a new frame is available
void captureEvent(Capture video) {
// Step 4. Read the image from the camera.
video.read();
}
void draw() {
loadPixels();
video.loadPixels();
for (int x = 0; x < video.width; x++) {
for (int y = 0; y < video.height; y++) {
// Calculate the 1D location from a 2D grid
int loc = x + y*video.width;
// Get the R,G,B values from image
float r, g, b;
r = red (video.pixels[loc]);
g = green(video.pixels[loc]);
b = blue (video.pixels[loc]);
// Calculate an amount to change brightness based on proximity to the mouse
float d = dist(x, y, mouseX, mouseY);
float adjustbrightness = map(d, 0, 100, 4, 0);
r *= adjustbrightness;
g *= adjustbrightness;
b *= adjustbrightness;
// Constrain RGB to make sure they are within 0-255 color range
r = constrain(r, 0, 255);
g = constrain(g, 0, 255);
b = constrain(b, 0, 255);
// Make a new color and set pixel in the window
color c = color(r, g, b);
pixels[loc] = c;
}
} updatePixels();
}