import processing.pdf.*;
int character = 0; // A
String _charSetMode0[] = {
"DEL", "Y", "E", "I", "A", "U", "P", "O",
"SPC", "B", "G", "F", "J", "C", "H", "D",
" ", "S", "X", "W", "-", "T", "Z", "V",
".", "R", "M", "N", "K", "Q", "L", "RESET"
};
String alphabet[] = {
"A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U", "V", "W", "X",
"Y", "Z", ".", "-", " ", "DEL", "SPC"
};
PFont theFont;
PGraphics buffer;
// put in the material size in here
PVector materialSize = new PVector(594, 420);
// PVector materialSize = new PVector(300, 220);
int bits = 5; // how many bits are we encoding
PVector cardSize = new PVector(300,72);
PVector tabSize = new PVector(9, 12);
PVector binaryHoles = new PVector(30 , 20);
float offSetSides = 1.315;
float downOffSetSides = 15; // in mm
int howManyCards = 8;
float binaryStopSides = 6;
ArrayList<Punchcard> punchcards = new ArrayList<Punchcard>();
int qqq = 0;
int globalCounter = 24;
Punchcard card;
void setup(){
// size(mm2pixel(materialSize.x), mm2pixel(materialSize.y));
size(500, 500);
buffer = createGraphics(
mm2pixel(materialSize.x), mm2pixel(materialSize.y),
PDF, "tabLow_output"+ globalCounter +".pdf");
theFont = createFont("DIN Next LT Pro", 18);
// buffer.beginDraw();
buffer.beginDraw();
buffer.textFont(theFont);
buffer.textAlign(CENTER);
// start top-left corner
buffer.stroke(#ff0000);
buffer.noFill();
buffer.endDraw();
for(int i = 0; i<alphabet.length; i++) {
punchcards.add(new Punchcard(i));
}
card = punchcards.get(0);
}
void draw(){
buffer.beginDraw();
// buffer.background(255);
for(int i = 0; i<howManyCards; i++) {
buffer.resetMatrix();
buffer.translate(mm2pixel(5), mm2pixel(5));
// pushMatrix();
if(i < (howManyCards-3)) {
buffer.translate(0, mm2pixel(cardSize.y*i)+mm2pixel(i*3));
} else {
buffer.translate(mm2pixel(cardSize.y*(i-1))+mm2pixel(i*3), mm2pixel(cardSize.x));
buffer.rotate(radians(-90));
// buffer.translate(mm2pixel(72*i)+mm2pixel(i*1),0);
}
if(globalCounter < punchcards.size()) {
card = punchcards.get(globalCounter);
card.display(buffer);
globalCounter++;
}
else {
buffer.dispose();
exit();
}
// popMatrix();
}
// Punchcard card = punchcards.get(0);
// card.display();
// translate(0,mm2pixel(75));
// card = punchcards.get(1);
// card.display();
// delay(500);
// card.setCharacter(qqq);
// qqq++;
// if(qqq > 29) qqq = 0;
// for (Punchcard card : punchcard) {
// card.display();
// }
noLoop();
buffer.dispose();
exit();
// buffer.endDraw();
}
int inch2pixel(float f) {
return int(f*72);
}
int mm2pixel(float mm) {
// 72 = dpi
return int(round((mm/25.4)*72));
}
int getKey(int n) {
int c = 0;
for(int i = 0; i<_charSetMode0.length; i++) {
if(_charSetMode0[i].equals(alphabet[n])) {
break;
}
c++;
}
return c;
}
String getBinary(int i) {
String b = binary(i,bits);
return b;
}
String reverseString(String s) {
char[] c = new char[s.length()];
for(int i = 0; i<s.length(); i++) {
c[i] = s.charAt(i);
}
return new String(reverse(c));
}