//---------------------------------------------------- //BOX READER AI Export- Aaron Steed 2005 //Data is saved in 65536 byte file blocks. //Each file contains data on 8192 boxes (8 bytes each). //Order of file information: //screenCount (4 bytes), x location, size, colour, marker for data //---------------------------------------------------- /* Note: This code is as dirty as it gets. When loaded into Illustrator create a custom size document of 800x16000 pixels (Ctrl+Alt+P or Command +Alt+P). Then select all (Ctrl+A or Command+A) cut (Ctrl+X or Command+X) and paste into the new document (Ctrl+F or Command+F). Then with all selected use move (Ctrl+Shift+M or Command+Shift+M) and type 1000 into Vertical. Repeat until the lot is in place (Ctrl+D or Command+D) or near and use Shift+cursor keys to adjust to the page edges. */ //import processing.opengl.*; AIExport ai; Emitted [] emitted; byte [] tape; int boxNumber; int [] xTable; color [] cFill; int scrCount; int maxSize = 50; int yMin = 0; int yMax = 0; boolean ran = false; int saveCount = 0; void setup(){ //tape = new byte[65536];//131072 = 16384 8blocks, 65536 = 8192 8Blocks or boxes size(800,600,P3D);//OPENGL); ai = new AIExport( this, 1 ); ai.toggleContinuousRecording(); ai.turnTransparencyOn(); ai.setLineWeight( 0.25 ); ai.ai_stroke( 0,0,0 ); tape = loadBytes("log0.dat");//set file name of log file to be read here xTable = new int[(width/maxSize)]; emitted = new Emitted[tape.length/8]; cFill = new color[128]; for (int i = 0; i < cFill.length; i++){ cFill[i] = color(0,0,0,i*2); } for (int i = 0; i < emitted.length; i++){ int [] temp; temp = returnBox(i); //constructor for emitted: (int x, int y, int size, color c) emitted[i] = new Emitted(temp[1],temp[0],temp[2],temp[3]); println("scrCount:"+temp[0]+" x:"+temp[1]+" size:"+temp[2]+" color:"+temp[3]+" marker:"+temp[4]); if (temp[0] > yMax){ yMax = temp[0]; } //tape chopper for early cut files, reminder out if marker not present if (temp[4] == 0){ chopTape(i); break; } } for (int i = 0; i < xTable.length; i++){ xTable[i] = (i*maxSize)+(maxSize>>1); } println("length:"+yMax); println("boxes:"+emitted.length); ai.ai_rectMode(CENTER); background(0); } void draw(){ ai.run(); if(!ran){ ai.ai_fill(0); ai.ai_rect(400,4000,800,8000); for(int i = 0; i < emitted.length; i++){ emitted[i].draw(); } } if (!ran){ ai.toggleContinuousRecording(); ran = true; } } int [] returnBox(int number){ int [] returnArray = new int[5]; byte [] sendBytes = new byte[4]; System.arraycopy(tape, number*8, sendBytes, 0, 4); returnArray[0] = returnScrCount(sendBytes); returnArray[1] = int(tape[(number*8)+4]); returnArray[2] = int(tape[(number*8)+5]); returnArray[3] = int(tape[(number*8)+6]); returnArray[4] = int(tape[(number*8)+7]); return returnArray; } int returnScrCount (byte [] source){ int [] returnInt = new int[source.length]; for (int i = 0; i < source.length; i++){ returnInt[i] = int(source[i]); } return (returnInt[0] << 24) | (returnInt[1] << 16) | (returnInt[2] << 8) | returnInt[3]; } void chopTape(int boxNumber){ tape = contract(tape,boxNumber*8); Emitted [] tempEmitted = new Emitted[boxNumber]; System.arraycopy(emitted, 0, tempEmitted, 0, boxNumber); emitted = tempEmitted; println("tape cut at box:"+boxNumber+" bytes:"+boxNumber*8); } class Emitted{ int x,y,size,c; Emitted(int x, int y, int size, color c){ this.x = x; this.y = y; this.size = size; this.c = c; } void draw(){ ai.ai_noStroke(); ai.ai_fill(255,255,255,c * 2); ai.ai_rect(xTable[x],y,size,size); ai.ai_stroke(255); ai.ai_noFill(); ai.ai_rect(xTable[x],y,size,size); } }