Files
FreeJ/scripts/processing/topics/linearimage.pde
Jaromil ae7b1ad056 progresses on processing script
processing-js 0.4 has been merged in some relevant parts
basic and topic scripts added for test
color handling fixed, more scripts show up now
2010-02-12 18:36:54 +01:00

52 lines
885 B
Plaintext

PImage a;
boolean onetime = true;
int[] aPixels = new int[200*200];
int direction = 1;
float signal;
void setup()
{
size(33, 33);
stroke(255);
a = loadImage("data/cait.jpg", null, function(){
for(int i=0; i<width*height; i++) {
aPixels[i] = a.pixels[i];
}
});
frameRate(30);
}
void draw()
{
if (signal > width-1 || signal < 0) {
direction = direction * -1;
}
if(mousePressed) {
signal = abs(mouseY%height);
} else {
signal += (0.3*direction);
}
if(keyPressed) {
image(a, 0, 0);
/*
loadPixels();
for (int i=0; i<width*height; i++) {
pixels[i] = aPixels[i];
}
updatePixels();
*/
line(0, signal, width, signal);
} else {
loadPixels();
for (int i=0; i<width*height; i++) {
pixels[i] = aPixels[int((width*int(signal))+(i%width))];
}
updatePixels();
}
}