// chrono paint (2005. 1. 1.) // by SeungJoon Choi // erucipe@hanmail.net // // http://processing.org int[] digit0 = {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0}; int[] digit1 = {0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0}; int[] digit2 = {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1}; int[] digit3 = {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0}; int[] digit4 = {0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}; int[] digit5 = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0}; int[] digit6 = {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0}; int[] digit7 = {1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}; int[] digit8 = {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0}; int[] digit9 = {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}; class Block { public Block() { size = 3; } public void boom(float power, float _decay) { decay = _decay; fx = (1.0 - random(2.0))*power; fy = (1.0 - random(2.0))*power; opacity = 0; } public void draw(float _x, float _y, int ccc) { x = _x; y = _y; fill(ccc, ccc, ccc, opacity); rect(x+fx, y+fy, size, size); if(opacity < 256) opacity += 16; fx *= decay; fy *= decay; } int opacity = 255; float decay = 0.9; float fx = 0; float fy = 0; public float size; public float x, y; } class Digit { public Digit() { value = new int[5*7]; blocks = new Block[5*7]; for(int i = 0; i < 5*7; i++) { blocks[i] = new Block(); } } public void make(int n) { switch(n) { case 0 : value = digit0; break; case 1 : value = digit1; break; case 2 : value = digit2; break; case 3 : value = digit3; break; case 4 : value = digit4; break; case 5 : value = digit5; break; case 6 : value = digit6; break; case 7 : value = digit7; break; case 8 : value = digit8; break; case 9 : value = digit9; break; } } public void boom(float power, float decay) { for(int i = 0; i < 5*7; i++) { blocks[i].boom(power, decay); } } public void draw() { for(int y = 0; y < 7; y++) { for(int x = 0; x < 5; x++) { Block block = blocks[y*5+x]; if(value[y*5+x] > 0) { block.draw(x*5, y*5, 0); } else { block.draw(x*5, y*5, 255); } } } } int[] value; Block[] blocks; } Digit[] d_s1; Digit[] d_s2; int n_s1 = 0; int n_s2 = 0; color cpin1; float[] clearZ; void setup() { size(400, 300); background(255); clearZ = new float[width * height]; System.arraycopy(g.zbuffer,0,clearZ,0,clearZ.length); rectMode(CENTER_DIAMETER); noStroke(); d_s1 = new Digit[10]; for(int i = 0; i < 10; i++) { d_s1[i] = new Digit(); d_s1[i].make(i); } d_s2 = new Digit[10]; for(int i = 0; i < 10; i++) { d_s2[i] = new Digit(); d_s2[i].make(i); } g.depthTest = false; noCursor(); } float bsize = 0; void mouseMoved() { bsize = 20; } void loop() { System.arraycopy(g.zbuffer,0,clearZ,0,clearZ.length); int s = second(); if(n_s1 != (int)((float)s/10)) { fill(255-red(cpin1), 255-green(cpin1), 255-blue(cpin1), 16); rect(200, 150, 400, 300); } fill(255, 255, 255, 64); rect(200, 150, 60+random(40), 300); if(random(1.0) > 0.85) { fill(255, 255, 255, 1); rect(200, 150, 60+random(90), 300); } push(); translate(200, 150); rotateZ((float)(second() / 10) / 6.0 * PI + (1-random(2.0))*0.1); fill(255, 255, 255, 10); rect(0, 0, 1, 500); pop(); push(); translate(200, 150); rotateZ(-(float)(second()) / 59.0 * PI); fill(red(cpin1) + (1-random(2.0))*64, green(cpin1) + (1-random(2.0))*64, blue(cpin1) + (1-random(2.0))*64, 64); rect(0, 0, 10, 200); pop(); push(); translate(mouseX, mouseY); rotateZ((float)millis() * 0.005); if(abs(mouseX - 200) < 50) { bsize = 20; } fill(red(cpin1), green(cpin1), blue(cpin1), 10); rect(0, 0, bsize, bsize*5); bsize *= 0.99; pop(); push(); beginCamera(); perspective(60, (float)width / (float)height, 1, 1000); lookat(400 - mouseX*2, 300 - mouseY*2, 300, 0, 0, 0, 0, 1, 0); endCamera(); pop(); smooth(); push(); translate(-63, -15, 0); if(s > 9) { int s1 = (int)(s / 10); int s2 = s % 10; if(n_s1 != s1) { d_s1[s1].boom(20, 0.8); cpin1 = color(random(255), random(255), random(255)); } if(n_s2 != s2) { d_s2[s2].boom(20, 0.75); } translate(35, 0, 0); d_s1[s1].draw(); translate(35, 0, 0); d_s2[s2].draw(); n_s1 = s1; n_s2 = s2; } else { if(n_s2 != s) { d_s2[s].boom(20, 0.75); } translate(70, 0, 0); d_s2[s].draw(); n_s2 = s; } pop(); noSmooth(); } void mousePressed() { /* for(int i = 0; i < 10; i++) { d_s2[i].boom(50, 0.5); } */ }