class DrillBlock { DrillPt[] points = new DrillPt[10]; int value; int numpoints; boolean transpose; DrillBlock() { this.points = new DrillPt[10]; for(int i=0; i<10; i++) { this.points[i] = new DrillPt(); this.points[i].set(0.0,0.0); } this.numpoints=0; this.value=-1; this.transpose=false; } DrillBlock(int _val) { this.points = new DrillPt[10]; for(int i=0; i<10; i++) this.points[i].set(0.0,0.0); this.numpoints=0; this.set(_val); this.transpose=false; } void set(int _val) { this.value = (int)map(_val, 0, 255, 9, 0); this.numpoints=this.value; //println(_val+" "+this.value); switch(this.value) { case 0: break; case 1: this.points[0].set(0.5, 0.5); break; case 2: this.points[0].set(0.25, 0.25); this.points[1].set(0.75, 0.75); break; case 3: this.points[0].set(0.5, 0.25); this.points[1].set(0.25, 0.75); this.points[2].set(0.75, 0.75); break; case 4: this.points[0].set(0.25, 0.25); this.points[1].set(0.75, 0.25); this.points[2].set(0.75, 0.75); this.points[3].set(0.25, 0.75); break; case 5: this.points[0].set(0.25, 0.25); this.points[1].set(0.75, 0.25); this.points[2].set(0.75, 0.75); this.points[3].set(0.25, 0.75); this.points[4].set(0.5, 0.5); break; case 6: this.points[0].set(0.25, 0.25); this.points[1].set(0.25, 0.5); this.points[2].set(0.25, 0.75); this.points[3].set(0.75, 0.25); this.points[4].set(0.75, 0.5); this.points[5].set(0.75, 0.75); break; case 7: this.points[0].set(0.25, 0.25); this.points[1].set(0.25, 0.5); this.points[2].set(0.25, 0.75); this.points[3].set(0.75, 0.25); this.points[4].set(0.75, 0.5); this.points[5].set(0.75, 0.75); this.points[6].set(0.5, 0.5); break; case 8: this.points[0].set(0.25, 0.25); this.points[1].set(0.25, 0.5); this.points[2].set(0.25, 0.75); this.points[3].set(0.75, 0.25); this.points[4].set(0.75, 0.5); this.points[5].set(0.75, 0.75); this.points[6].set(0.5, 0.33); this.points[7].set(0.5, 0.67); break; case 9: this.points[0].set(0.25, 0.25); this.points[1].set(0.25, 0.5); this.points[2].set(0.25, 0.75); this.points[3].set(0.75, 0.25); this.points[4].set(0.75, 0.5); this.points[5].set(0.75, 0.75); this.points[6].set(0.5, 0.25); this.points[7].set(0.5, 0.5); this.points[8].set(0.5, 0.75); break; default: this.numpoints=0; break; } } void draw(int x, int y) { fill(this.value*25.5); rect(x, y, 5, 5); } void draw(int x, int y, int w, int h) { this.draw(x, y, w, h, 2, 2); } void draw(int x, int y, int w, int h, int r_x, int r_y) { //println(this.value*25.5+" "+this.numpoints); for(int i=0; i < this.numpoints; i++) { if(this.transpose) { ellipse(x+(round(this.points[i].gety()*w)), y+(round(this.points[i].getx()*h)), r_x, r_y); } else { ellipse(x+(round(this.points[i].getx()*w)), y+(round(this.points[i].gety()*h)), r_x, r_y); } } this.transpose= !this.transpose; } }