Escolhi uma série de imagens da Yayoi Kusama de salas com bolinhas e com a presença da própria:
Dentre várias coisas, notei que o tamanho das bolinhas e a distância entre elas é diretamente proporcional. As obras são compostas por vários círculos de tamanhos variados posicionados de uma forma orgânica e dentre essas obras, a cor do fundo e dos círculos é escolhida entre as cores Amarelo, Preto, Branco e Vermelho assim como os vestidos dela. As distâncias entre os elementos pode ser desde quase nenhuma até um tanto mais que o próprio diâmetro das bolinhas.
A seguir pode-se ver o código, infelizmente não pode ser colocado "vivo" aqui como os outros inclusive por ser renderizado em P3D e incluir arquivos externos. (Dropbox)
IntList colors = new IntList(color(255, 255, 0), color(0), color(255), color(255, 0, 0));
int d;
int rm;
color c1;
color c2;
void setup() {
colors.shuffle();
c1 = colors.pop();
c2 = colors.pop();
d = int(random(4));
rm = int(7.5*(d+1));
d = d*10+3;
size(750, 500, P3D);
noStroke();
pointLight(255, 255, 255, width/2, 100, 0);
cubo();
save("test"+(hour()*3600+minute()*60+second())+".jpg");
exit();
}
void drawCircle(PImage img, float x, float y, float r, color c) {
for (int i = 0; i<=img.width; i++) {
for (int j = 0; j <= img.height; j++) {
if (dist(i, j, x, y)<=r) {
img.set(i, j, c);
}
}
}
}
float dist(int x1, int y1, int x2, int y2) {
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
PImage generate(int w, int h, color c1, color c2) {
ArrayList<pvector> list = new ArrayList<pvector>();
int x, y, r;
PImage img = createImage(w, h, RGB);
for (int i = 0; i < img.pixels.length; i++) {
img.pixels[i] = c1;
}
img.updatePixels();
for (int i = 0; i <= w; i++) {
for (int j = 0; j <= h; j++ ) {
boolean test = true;
r = int(random(rm/3,rm));
x = int(i+cos(random(TAU))*r);
y = int(j+sin(random(TAU))*r);
for (PVector circle : list) {
if (dist(circle.x, circle.y, x, y) < r + circle.z + d) {
test = false;
}
}
if (test) {
drawCircle(img, x, y, r, c2);
list.add(new PVector(x, y, r));
}
}
}
return img;
}
void cubo() {
PImage YK;
PImage textura = generate(width*3, height*3, c1, c2);
PImage yayoi = loadImage("Yayoi Kusama.jpg");
PImage mask1 = loadImage("Vestido Mask.jpg");
yayoi.mask(loadImage("Rosto Mask.jpg"));
if (random(4)>=3) {
YK = generate(303, 711, colors.pop(), colors.pop());
} else if (random(2)>=1) {
YK = generate(303, 711, c1, c2);
} else {
YK = generate(303, 711, c2, c1);
}
YK.resize(101, 237);
YK = YK.get(0, 0, 101, 237);
YK.mask(mask1);
YK.blend(yayoi, 0, 0, 101, 237, 0, 0, 101, 237, BLEND);
//Frente
beginShape();
texture(textura);
vertex(0, 0, -width/2, width, height);
vertex(width, 0, -width/2, width*2, height);
vertex(width, height, -width/2, width*2, height*2);
vertex(0, height, -width/2, width, height*2);
endShape(CLOSE);
//Esquerda
beginShape();
texture(textura);
vertex(0, 0, width/2, 0, height);
vertex(0, 0, -width/2, width, height);
vertex(0, height, -width/2, width, height*2);
vertex(0, height, width/2, 0, height*2);
endShape(CLOSE);
//Direita
beginShape();
texture(textura);
vertex(width, 0, -width/2, width*2, height);
vertex(width, 0, width/2, width*3, height);
vertex(width, height, width/2, width*3, height*2);
vertex(width, height, -width/2, width*2, height*2);
endShape(CLOSE);
//Baixo
beginShape();
texture(textura);
vertex(0, height, -width/2, width, height*2);
vertex(width, height, -width/2, width*2, height*2);
vertex(width, height, width/2, width*2, height*3);
vertex(0, height, width/2, width, height*3);
endShape(CLOSE);
//Cima
beginShape();
texture(textura);
vertex(0, 0, -width/2, width, 0);
vertex(width, 0, -width/2, width*2, 0);
vertex(width, 0, width/2, width*2, height);
vertex(0, 0, width/2, width, height);
endShape(CLOSE);
//Yayoi Kusama
beginShape();
texture(YK);
vertex(width/2-75, height-237, -width/4, 0, 0);
vertex(width/2+26, height-237, -width/4, 101, 0);
vertex(width/2+26, height, -width/4, 101, 237);
vertex(width/2-75, height, -width/4, 0, 237);
endShape(CLOSE);
}
Primeiramente criei uma função que desenhava um círculo numa imagem e utilizei a imagem com círculo em uma textura para planos 3D
Completei a forma 3D e com um conjunto de máscaras e uma foto da Yayoi, pude gerar uma imagem que foi recortada como o vestido dela e adicionei o rosto, mãos e pés da imagem original e usei como textura em um plano mais a frente
Criei uma função que fazia uma imagem com várias bolinhas
Adicionei luzes e reposicionei a Kusama
Aumentei o tamanho do Ambiente
Adicionei as cores a serem utilizadas colocando-as em uma lista, embaralhando e puxando as duas últimas
Fiz um "crossover" com o código da Joaninha sendo que ao invés de escolher posições aleatórias, vai-se fazendo testes com todas as posições de cima pra baixo, da esquerda pra direita
Visualizando distâncias diferentes
Eliminando de forma não conveniente o problema de bolinhas cortadas nos cantos e comparando com obras dela
Adicionada possibilidade de vestido diferente do ambiente. Nesse caso, usa-se as cores que sobraram da escolha de cores
Retirada das bordas inconvenientes
Não mais gerada uma imagem pra cada parede, apenas uma gigante imagem e mapeamento UV
Ops, mapeamento UV é um tanto mais complicado do que parece
Resultado quase final, a partir daqui foram feitos apenas pequenos ajustes.
E é basicamente isso, no link do Dropbox existem vários exemplos da versão final e já que demora muito a "renderizar" a obra, foi adaptado para salvar o resultado e fechar a aplicação. Have fun!
Nenhum comentário:
Postar um comentário
Pode falar, eu não mordo... Pelo menos não através da internet
Nenhum comentário:
Postar um comentário
Pode falar, eu não mordo... Pelo menos não através da internet