HI Guys,
i am relativ new to programming and I have a question.
I am trying to fade in an object by using a for loop that increases the alpha value of the object. But it does not fade in, it only appears.
int[] red = new int[4];
int[] blue = new int[4];
int[] green = new int[4];
// Step 1. Import the video library
import processing.video.*;
// Step 2. Declare a Capture object
Capture video;
void setup() {
size(595, 842);
background(255);
//Initialize Capture object via Constructor
video = new Capture(this, 320, 240);
video.start();
}
// An event for when a new frame is available
void captureEvent(Capture video) {
// Read the image from the camera.
video.read();
}
void draw() {
loadPixels();
video.loadPixels();
// Get Colors
color c1 = video.get(50, 50);
color c2 = video.get(200, 50);
color c3 = video.get(50, 200);
color c4 = video.get(200, 200);
//Process Colors
//Get Int Value of Red
int redValue1 = int(red(c1));
int redValue2 = int(red(c2));
int redValue3 = int(red(c3));
int redValue4 = int(red(c4));
//safe redValue in Array
red[0] = redValue1;
red[1] = redValue2;
red[2] = redValue3;
red[3] = redValue4;
//Get Int Value of Blue
int blueValue1 = int(blue(c1));
int blueValue2 = int(blue(c2));
int blueValue3 = int(blue(c3));
int blueValue4 = int(blue(c4));
//safe blueValue
blue[0] = blueValue1;
blue[1] = blueValue2;
blue[2] = blueValue3;
blue[3] = blueValue4;
//Get Int Value of Green
int greenValue1 = int(green(c1));
int greenValue2 = int(green(c2));
int greenValue3 = int(green(c3));
int greenValue4 = int(green(c4));
//safe greenvalue
green[0] = greenValue1;
green[1] = greenValue2;
green[2] = greenValue3;
green[3] = greenValue4;
//Get Random Number for color selection of differnt pixels
int randomColor = int(random(3));
int randomX = int(random(width));
int randomY = int(random(height));
int randomShape = int(random(50));
int randomSizeX = int(random(20, 150));
int randomSizeY = int(random(20, 150));
for (float i = 1; i<10; i++) {
noStroke();
fill(red[randomColor], blue[randomColor], green[randomColor],10*i);
rect(randomX, randomY, randomSizeX, randomSizeY, randomShape, randomShape, randomShape, randomShape);
delay(10);
}
delay(100);
}