xxxxxxxxxx
int level = 0;
PImage imagem;
int azul = 180;
/* efeito 3 */
int circles = 20;
int steps = 120;
//efeito 5
int nblue = 50;
int larg= 500;
/*float theta,r; */
/* efeito 9 */
PImage blu;
PImage img2;
float offset = 0;
float easing = 0.05;
//´14
int px = 0;
int py = 0;
color[] cor;
/* efeito 15 */
int frames = 180;
float diameter, radius, theta, r;
/* efeito 22
float r, theta; */
/* efeito 23 */
int verde = 80;
int largura = 600;
void setup() {
size(600,600);
background(128);
/* efeito 9 */
blu = loadImage("blu.jpg");
// inicia uma caixa de diálogo, com o texto do primeiro parametro.
// o segundo string contém o nome da função a chamar quando o utilizador escolher:
selectInput("Por favor escolha uma imagem:", "abreImagem");
/* efeito 15 */
//blendMode(EXCLUSION);
diameter = height*.5;
radius = diameter/2;
/* efeito 22 */
rectMode(CENTER);
}
/*
Função abreImagem():
Função chamada ('callback') quando o utilizador escolhe um ficheiro -
gerando automaticamente um objecto de tipo File.
*/
void abreImagem(File ficheiro) {
if (ficheiro == null) {
// se o utilizador tiver cancelado, repete:
println("O utilizador cancelou.");
setup();
} else {
// senão, tudo ok:
// a função .getAbsolutePath() dá-nos a localização completa do ficheiro:
imagem = loadImage(ficheiro.getAbsolutePath());
// vamos redimensionar a imagem proporcionalmente para caber na janela:
if (imagem.width > width) {
imagem.resize(width, 0); // 0 = proporcional
}
if (imagem.height > height) {
imagem.resize(0, height); // 0 = proporcional
}
}
}
void draw() {
background(0);
if (level == 0) {inicio(); }
if (level == 1) {level1(); }
if (level == 2) {level2(); }
if (level == 3) {level3(); }
if (level == 4) {level4(); }
if (level == 5) {level5(); }
if (level == 6) {level6(); }
if (level == 7) {level7(); }
if (level == 8) {level8(); }
if (level == 9) {level9(); }
if (level == 10) {level10(); }
if (level == 11) {level11(); }
if (level == 12) {level12(); }
if (level == 13) {level13(); }
if (level == 14) {level14(); }
if (level == 15) {level15(); }
if (level == 16) {level16(); }
if (level == 17) {level17(); }
if (level == 18) {level18(); }
if (level == 19) {level19(); }
if (level == 20) {level20(); }
if (level == 21) {level21(); }
if (level == 22) {level22(); }
if (level == 23) {level23(); }
if (level == 24) {level24(); }
if (level == 25) {level25(); }
if (level == 26) {level26(); }
}
/* Efeitos do níveis = letras */
void inicio() {
background(0);
}
void level1() {
image(imagem, 0, 0, width, height);
tint(0, 153, 204); // Tint blue
}
void level2() {
background(0);
image(imagem, 0, 0, width, height);
frameRate(16);
rectMode(CENTER);
strokeWeight(10);
blendMode(EXCLUSION);
fill( 140, 31, 246);
if (largura > 0) {
stroke(0, azul, 0);
rect(width/2,height/2, largura,largura);
largura = largura - 10;
}
else {
background(0);
azul = 80;
largura = 600;
}
}
void level3() {
image(imagem, 0, 0, width, height);
blend(imagem, 0, 0, width, height, 10, 10, 600, 600, SUBTRACT);
}
void level4() {
image(imagem, 0, 0, width, height);
image(imagem, 0, 0);
float dx = (mouseX-imagem.width/2) - offset;
offset += dx * easing;
tint(255, 127); // Display at half opacity
image(imagem, offset, 0);
tint(213, 22, 174);
}
void level5() {
image(imagem, 0, 0, width, height);
blend(imagem, 0, 0, width, height, 10, 10, 600, 600, HARD_LIGHT);
}
void level6() {
image(imagem, 0, 0, width, height);
tint(23, 215, 24);
}
void level7() {
image(imagem, 0, 0, width, height);
image(imagem, 0, 0);
tint(255, 126); // Apply transparency without changing color
image(imagem, 50, 0);
}
void level8() {
image(imagem, 0, 0, width, height);
image(imagem, 0, 0);
float dx = (mouseX-imagem.width/2) - offset;
offset += dx * easing;
tint(255, 127); // Display at half opacity
image(imagem, offset, 0);
tint(13, 25, 124);
}
void level9() {
image( blu, 0,0 );
image( imagem, 0,0 );
copy ( blu, 0,0, 20,540, 0,0, 20,650 );
copy ( blu, 50,0, 20,540, 50,0, 20,650 );
copy ( blu, 100,0, 20,540, 100,0, 20,650 );
copy ( blu, 150,0, 20,540, 150,0, 20,650 );
copy ( blu, 200,0, 20,540, 200,0, 20,650 );
copy ( blu, 250,0, 20,540, 250,0, 20,650 );
copy ( blu, 300,0, 20,540, 300,0, 20,650 );
copy ( blu, 350,0, 20,540, 350,0, 20,650 );
copy ( blu, 400,0, 20,540, 400,0, 20,650 );
}
void level10() {
background(0);
image(imagem, 0, 0, width, height);
rectMode(CENTER);
strokeWeight(30);
blendMode(DIFFERENCE);
fill( 14, 231, 146);
if (0 < largura) {
stroke(0, 137, 0);
rect(width/2,height/2, largura,largura);
largura = largura + 5;
}
else {
background(0);
fill( 14, 131, 246);
largura = 2;
}
}
void level11() {
image(imagem, 0, 0, width, height);
blend(imagem, 0, 0, width, height, 10, 10, 600, 600, ADD);
}
void level12() {
image(imagem, 0, 0, width, height);
image(imagem, 0, 0);
float dx = (mouseX-imagem.width/2) - offset;
offset += dx * easing;
tint(255, 127); // Display at half opacity
image(imagem, offset, 0);
tint(13, 225, 174);
}
void level13() {
background(0);
image(imagem, 0, 0, width, height);
rectMode(CENTER);
rect(300, 300, width, height);
strokeWeight(30);
blendMode(DIFFERENCE);
fill( 214, 131, 16);
}
void level14() {
background(0);
image(imagem, 0, 0, width, height);
noStroke();
blendMode(DIFFERENCE);
blend(10, 30, width, height, 0, 0, 700, 800, ADD);
}
void level15() {
background(255);
float x1 = map(sin(theta), -1, 1, width/2, width/2-radius);
float x2 = map(sin(theta), -1, 1, width/2+radius, width/2);
float y = height/2;
float r1 = map(sin(theta), -1, 1, 0, diameter);
float r2 = map(sin(theta), -1, 1, diameter, 0);
fill(0);
noStroke();
ellipse(x1, y, r1, r1);
ellipse(x2, y, r2, r2);
//ellipse(width/2, height/2,radius*2, radius*2);
theta += TWO_PI/frames;
//if (frameCount<=frames) saveFrame("image-###.gif");
}
void level16() {
int x = 0;
int y = 0;
int a = 600;
int b = 50;
int d = 1;
int e = -1;
image(imagem, 0, 0, width, height);
noStroke();
fill(255, 10);
rect(0, 0, width, height);
x = x + d;
a = a + e;
if (x > width/2 || x < 0) {
d = -d;
}
if (a < width/2 || a > width) {
e = -e;
}
stroke(0);
for (int i =0; i<height+1; i = i + 100) {
for (int j = -width; j<width; j = j + 100) {
line(x+j, y+i, x+j, y+i+50);
// line(x, y+i, x, y+i+50);
}
}
for (int r = 0; r<height+1; r = r + 100) {
for (int q = -width; q < width; q = q + 100) {
line(a-q, b+r, a-q, b+r+50);
}
}
}
void level17() {
image(imagem, 0, 0, width, height);
blend(imagem, 0, 0, width, height, 250, 210, 600, 600, LIGHTEST);
tint(23, 215, 224);
}
void level18() {
image(imagem, 0, 0, width, height);
blend(imagem, 0, 0, width, height, 150, 150, 600, 600, DARKEST);
}
void level19() {
image(imagem, 0, 0, width, height);
image(imagem, 0, 0);
float dx = (mouseX-imagem.width/2) - offset;
offset += dx * easing;
tint(255, 127); // Display at half opacity
image(imagem, offset, 0);
}
void level20() {
image(imagem, 0, 0, width, height);
tint(230, 15, 24);
}
void level21() {
image(imagem, 0, 0, width, height);
tint(130, 115, 84);
}
void level22() {
background(0);
image(imagem, 0, 0, width, height);
drawLines(width/2, height/2,10);
blendMode(SOFT_LIGHT);
theta += 0.0523;
}
void drawLines(int _x, int _y, int _n) {
blendMode(SOFT_LIGHT);
fill(0);
int num=_n;
blendMode(SOFT_LIGHT);
translate(_x, _y);
pushMatrix();
rotate(r);
for (int i=0; i<num; i++) {
float w = map(sin(theta+(TWO_PI/num*i)),-1,1,width*.1,width*1.2);
float h = 60;
float x = 0;
float y = -(num*h*1.5/2)+i*h*1.5;
rect(x, y, w, h);
}
popMatrix();
r += 0.0523/2;
}
void level23() {
background(0);
image(imagem, 0, 0, width, height);
frameRate(16);
rectMode(CENTER);
strokeWeight(10);
blendMode(DIFFERENCE);
fill( 140, 231, 98);
if (largura > 0) {
stroke(0, verde, 0);
rect(width/2,height/2, largura,largura);
largura = largura - 10;
}
else {
background(0);
verde = 80;
largura = 600;
}
}
void level24() {
image(imagem, 0, 0, width, height);
}
void level25() {
int speed = 10;
int num = 60; // size of arrays
int w = 0;
int dir = +1;
float[] xdir = new float[num];
float[] ydir = new float[num];
float[] x = new float[num];
float[] y = new float[num];
int[] thecolors = new int[num*3];
image(imagem, 0, 0, width, height);
size(600, 600);
noStroke();
smooth();
blendMode(DIFFERENCE);
w = w + dir;
if (w > 300 || w < 0)
dir = -dir;
for(int i =0; i < num; i++){
x[i] = 0;
y[i] = 0;
// xdir[i] = random(1.1);
ydir[i] = random(1.2);
}
for(int i = 0; i < num * 3; i +=3) {
thecolors[i] = int(random(0, 255));
thecolors[i + 1] = int(random(0, 255));
thecolors[i + 2] = int(random(0, 255));
}
blendMode(DIFFERENCE);
fill(num);
for (int i = 0; i<num; i++) {
stroke(thecolors[i], thecolors[i+1], thecolors[i+2], 10);
//strokeWeight(random(100));
strokeWeight(20);
strokeCap(PROJECT);
line(x[i], y[i], x[i]+width, y[i]);
strokeWeight(50);
line(x[i], y[i], x[i]+width, y[i]);
x[i] = x[i] + xdir[i] * speed;
y[i] = y[i] + ydir[i] * speed;
if (x[i] > width || x[i] < 0) {
xdir[i] = -xdir[i];
}
if (y[i] > height || y[i] < 0) {
ydir[i] = -ydir[i];
}
}
}
void level26() {
image(imagem, 0, 0, width, height);
frameRate(1);
noStroke();
for(int i =0; i <60; i++){
int x = int(random (0,600));
int y = int (random (0,600));
int r = int (random (100,255));
blendMode(DIFFERENCE);
fill(r,0,0,int (random (0,50)));
rect(x,y,30,30);
for(int j = 0; j<20; j++){
fill(r,0,0,40-j*2);
rect(x + j*2,y +j*2,30,30);
}
}
}
/* controle por letras = escolha de letras= escolha do alteração */
void keyPressed() {
if (key == 'a') {
level = 1;
}
if (key == 'b') {
level = 2;
}
if (key == 'c') {
level = 3;
}
if (key == 'd') {
level = 4;
}
if (key == 'e') {
level = 5;
}
if (key == 'f') {
level = 6;
}
if (key == 'g') {
level = 7;
}
if (key == 'h') {
level = 8;
}
if (key == 'i') {
level = 9;
}
if (key == 'j') {
level = 10;
}
if (key == 'k') {
level = 11;
}
if (key == 'l') {
level = 12;
}
if (key == 'm') {
level = 13;
}
if (key == 'n') {
level = 14;
}
if (key == 'o') {
level = 15;
}
if (key == 'p') {
level = 16;
}
if (key == 'q') {
level = 17;
}
if (key == 'r') {
level = 18;
}
if (key == 's') {
level = 19;
}
if (key == 't') {
level = 20;
}
if (key == 'u') {
level = 21;
}
if (key == 'v') {
level = 22;
}
if (key == 'w') {
level = 23;
}
if (key == 'x') {
level = 24;
}
if (key == 'y') {
level = 25;
}
if (key == 'z') {
level = 26;
}
if (key == '0') {
saveFrame("i####.jpg");
}
}
/*
void keyReleased() {
level = 0;
}
*/
/* trabalhar com variaveis globais. chamar por exemplo a teclah a, b e f o mesmo nivel mas com variaveis diferente, no if press K level 1, if press f level 1 if press k level 1 */