private void drawShape() {
int i = 0;
shape = new RShape();
for (int y = 0; y < img.height; y++) {
RShape s = new RShape();
s.addMoveTo(new RPoint(0*TILE_SIZE, y*TILE_SIZE));
for (int x = 0; x < img.width; x++) {
pushMatrix();
int c = img.pixels[i++];
int r = (c >> 16) & 0xff;
int g = (c >> 8) & 0xff;
int b = c & 0xff;
// 76.5 + 150.45 + 28.05 = 255;
//float bright = (float)(0.3F * r + 0.59F * g + 0.11F * b);
float bright = (r + g + b) / 768F;
bright = 1 - (bright);
bright *= brightScale;
// bright = circleSize - bright;
// println(bright);
translate(x*TILE_SIZE, y*TILE_SIZE);
if (bright < 0.2) {
s.addMoveTo(new RPoint((x+1)*TILE_SIZE, y*TILE_SIZE+4));
}
else if (bright < 0.4) {
line(0, 3, TILE_SIZE, 3);
s.addLineTo(new RPoint((x+1)*TILE_SIZE, y*TILE_SIZE+4));
}
else if (bright < 0.6) {
line(0, 4, 2, 1);
line(2, 1, 4, 5);
line(4, 5, 8, 4);
s.addLineTo(new RPoint(x*TILE_SIZE+2, y*TILE_SIZE+1));
s.addLineTo(new RPoint(x*TILE_SIZE+4, y*TILE_SIZE+5));
s.addLineTo(new RPoint(x*TILE_SIZE+8, y*TILE_SIZE+4));
}
else if (bright < 0.8) {
line(0, 4, 2, 1);
line(2, 1, 4, 8);
line(4, 8, 8, 4);
s.addLineTo(new RPoint(x*TILE_SIZE+2, y*TILE_SIZE+1));
s.addLineTo(new RPoint(x*TILE_SIZE+4, y*TILE_SIZE+8));
s.addLineTo(new RPoint(x*TILE_SIZE+8, y*TILE_SIZE+4));
}
else {
line(0, 4, 2, 0);
line(2, 0, 3, 7);
line(3, 7, 4, 1);
line(4, 1, 6, 7);
line(6, 7, 8, 4);
s.addLineTo(new RPoint(x*TILE_SIZE+2, y*TILE_SIZE+0));
s.addLineTo(new RPoint(x*TILE_SIZE+3, y*TILE_SIZE+7));
s.addLineTo(new RPoint(x*TILE_SIZE+4, y*TILE_SIZE+1));
s.addLineTo(new RPoint(x*TILE_SIZE+6, y*TILE_SIZE+7));
s.addLineTo(new RPoint(x*TILE_SIZE+8, y*TILE_SIZE+4));
}
popMatrix();
}
shape.addChild(s);
}