Clique na imagem para mudar a quantidade
int n = 2;
float p = 0;
void setup()
{
size(600, 600);
colorMode(HSB);
noStroke();
}
void draw()
{
background(127,0);
fill(0);
textSize(32);
text(n, 10, 30);
translate(width/2, height/2);
Board(n, 150);
}
void Board(int p, float s) {
rotate(PI/p);
for (int i = 0; i < p*2; i++) {
Quarter(s, PI/p, (i%2==0), i, p);
rotate(PI/p);
}
}
void Quarter(float r, float d, boolean b, int c, int p)
{
pushMatrix();
float a = HALF_PI - d;
for (int i = 0; i<4; i++) {
for (int j = 0; j<4; j++) {
float y = j*r/4;
float x = 0;
if ((i+j)%2 == 0)
fill(b ? color(map(round(c/2)*2, 0, p*2, 0, 255), 255, 255) : 255);
else
fill(b ? 255 : color(map(round(c/2)*2, 0, p*2, 0, 255), 255, 255));
beginShape();
vertex(x, y);
vertex(x+r/4*cos(a), y+r/4*sin(a));
vertex(x+r/4*cos(a), y+r/4+r/4*sin(a));
vertex(x, y+r/4);
endShape(CLOSE);
if (j==3) {
translate(r/4*cos(a), r/4*sin(a));
}
}
}
popMatrix();
}
void mouseClicked() {
if (mouseButton == LEFT) {
if (mouseX < width/2 && n > 2) {
n--;
} else if (mouseX > width/2) {
n++;
}
}
if (mouseButton == RIGHT) {
save(n+"-Chess.png");
}
}
Nenhum comentário:
Postar um comentário
Pode falar, eu não mordo... Pelo menos não através da internet