Initial Commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Linear Image.
|
||||
*
|
||||
* Click and drag mouse up and down to control the signal.
|
||||
* Press and hold any key to watch the scanning.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
int direction = 1;
|
||||
|
||||
float signal;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
stroke(255);
|
||||
img = loadImage("sea.jpg");
|
||||
img.loadPixels();
|
||||
loadPixels();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
if (signal > img.height-1 || signal < 0) {
|
||||
direction = direction * -1;
|
||||
}
|
||||
if (mousePressed == true) {
|
||||
signal = abs(mouseY % img.height);
|
||||
}
|
||||
else {
|
||||
signal += (0.3*direction);
|
||||
}
|
||||
|
||||
if (keyPressed == true) {
|
||||
set(0, 0, img);
|
||||
line(0, signal, img.width, signal);
|
||||
}
|
||||
else {
|
||||
int signalOffset = int(signal)*img.width;
|
||||
for (int y = 0; y < img.height; y++) {
|
||||
arrayCopy(img.pixels, signalOffset, pixels, y*width, img.width);
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 185 KiB |
Reference in New Issue
Block a user