/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.iT0yavdkugG/rev.566
*
* authors:
* frederic.vernier
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/* @pjs preload="/static/uploaded_resources/p.2418/Ferme_St_Auban.jpg"; */
int i = 0;
PImage img, img0;
boolean mouin = false;
void setup() { // this is run once.
// set the background color
background(255);
// canvas size (Variable aren't evaluated. Integers only, please.)
size(640, 480);
// smooth edges
smooth();
// limit the number of frames per second
frameRate(30);
img = loadImage("/static/uploaded_resources/p.2418/Ferme_St_Auban.jpg");
img0 = createImage(width, height, ARGB);
img0.loadPixels();
float ra = img.height/img0.height;
for (int j=0; j < img0.height; j++) {
for (int i=0; i < img0.width; i++) {
int c = img.pixels[int(i*ra)+int(j*ra)*img.width];
byte a = (c&0xff000000)>>24;if (a<0) a+=256;
byte r = (c&0x00ff0000)>>16;if (r<0) a+=256;
byte g = (c&0x0000ff00)>>8;if (g<0) a+=256;
byte b = (c&0x000000ff)>>0;if (b<0) a+=256;
byte l = max(max(r, g), b);
if (dist(i, j, img0.width/2, img0.height/2)<5) l=0;
img0.pixels[i+j*img0.width] = (255<<24)+(l<<16)+(l<<8)+(l<<0);
}
}
img0.updatePixels();
img1 = createImage(width, height, ARGB);
img1.loadPixels();
colorMode(HSB);
float ra = img.height/img1.height;
for (int j=0; j < img1.height; j++) {
for (int i=0; i < img1.width; i++) {
int c = img.pixels[int(i*ra)+int(j*ra)*img.width];
color c0 = color((128+hue(c))%255, 255, brightness(c));
if (dist(i, j, img1.width/2, img1.height/2)<5) c0=color(0);
img1.pixels[i+j*img0.width] = c0;
}
}
colorMode(RGB);
img1.updatePixels();
noLoop();
}
void draw() { // this is run repeatedly.
if (mouin)
image(img0, 0, 0);
else
image(img1, 0, 0);
text("Look at the black point in the image for 30sec then move the mouse over the image without looking at somewhere else", 2, 30);
}
void mouseOver() {
mouin = true;
redraw();
}
void mouseOut() {
mouin = false;
redraw();
}