I'm trying to design a new chess set in Processing and I have run into a problem with the first piece (the knight). At the top of the knight there is an arc that goes around the knight's head and there are internal lines from the beginShape that I don't want inside that arc (I need to hide them somehow. The lines I'm talking about look like the left, top, and right of a box). I can't find an elegant way to hide these lines. Any help / suggestions would be appreciated.
On a different note, can anyone think of an easier way to design something that looks like this in Processing? This method is not exactly the easiest way to create 2D work.
- boolean[] toggle = new boolean[8];
- float unit = 800;
- void setup() {
- size((int)unit, (int)unit);
- strokeWeight(3);
- smooth();
- toggle[2] = true;
- //toggle[6] = true;
- }
- void draw() {
- if (toggle[7]) {
- background(64);
- fill(255);
- stroke(0);
- }
- else {
- background(192);
- fill(0);
- stroke(255);
- }
- if (toggle[0]) pawn();
- if (toggle[1]) rook();
- if (toggle[2]) knight();
- if (toggle[3]) bishop();
- if (toggle[4]) queen();
- if (toggle[5]) king();
- if (toggle[6]) grid();
- }
- void pawn() {
- }
- void rook() {
- }
- void knight() {
- arc(unit*0.5, unit*0.375, unit*0.75, unit*0.75, 3.93, 7.064);
- if (toggle[7]) fill(64);
- else fill(192);
- arc(unit*0.5, unit*0.375, unit*0.625, unit*0.625, 3.927, 7.068);
- if (toggle[7]) fill(255);
- else fill(0);
- beginShape();
- vertex(unit*0.375, unit);
- vertex(unit*0.375, unit*0.6875);
- vertex(unit*0.4375, unit*0.625);
- vertex(unit*0.375, unit*0.5625);
- vertex(unit*0.375, unit*0.5);
- vertex(unit*0.4375, unit*0.4375);
- vertex(unit*0.5, unit*0.4375);
- vertex(unit*0.5625, unit*0.375);
- vertex(unit*0.5, unit*0.3125);
- vertex(unit*0.4375, unit*0.375);
- vertex(unit*0.25, unit*0.375);
- vertex(unit*0.46875, unit*0.125);
- vertex(unit*0.46875, unit*0.03125);
- vertex(unit*0.53125, unit*0.03125);
- vertex(unit*0.53125, unit*0.125);
- vertex(unit*0.75, unit*0.375);
- vertex(unit*0.5625, unit*0.625);
- vertex(unit*0.625, unit*0.6875);
- vertex(unit*0.625, unit);
- endShape(CLOSE);
- arc(unit*0.4375, unit*0.5, unit*0.125, unit*0.125, PI, PI+HALF_PI);
- arc(unit*0.5, unit*0.375, unit*0.5, unit*0.5, PI, 4.59);
- arc(unit*0.5, unit*0.375, unit*0.5, unit*0.5, 4.84, 7.5);
- if (toggle[7]) fill(64);
- else fill(192);
- arc(unit*0.375, unit*0.625, unit*0.125, unit*0.125, PI+HALF_PI, TWO_PI+HALF_PI);
- arc(unit*0.5, unit*0.375, unit*0.125, unit*0.125, PI, TWO_PI+HALF_PI);
- arc(unit*0.625, unit*0.625, unit*0.125, unit*0.125, HALF_PI, PI+HALF_PI);
- line(unit*0.625, unit*0.5625, unit*0.625, unit*0.591);
- }
- void bishop() {
- }
- void queen() {
- }
- void king() {
- }
- void grid() {
- stroke(255, 0, 0);
- int numAreas = 8;
- for (int i = 1; i < numAreas; i++) {
- line(unit/numAreas*i, 0, unit/numAreas*i, unit);
- line(0, unit/numAreas*i, unit, unit/numAreas*i);
- }
- }
- void keyPressed() {
- if (key == '1') {
- for (int i = 0; i < 6; i++) toggle[i] = false;
- toggle[0] = true;
- }
- if (key == '2') {
- for (int i = 0; i < 6; i++) toggle[i] = false;
- toggle[1] = true;
- }
- if (key == '3') {
- for (int i = 0; i < 6; i++) toggle[i] = false;
- toggle[2] = true;
- }
- if (key == '4') {
- for (int i = 0; i < 6; i++) toggle[i] = false;
- toggle[3] = true;
- }
- if (key == '5') {
- for (int i = 0; i < 6; i++) toggle[i] = false;
- toggle[4] = true;
- }
- if (key == '6') {
- for (int i = 0; i < 6; i++) toggle[i] = false;
- toggle[5] = true;
- }
- if (key == '7') toggle[6] = !toggle[6];
- if (key == '8') toggle[7] = !toggle[7];
- }
1