class LDrawColor{ String name; int code; color value; color edgevalue; LDrawColor(String aName, int aCode, color aColor, int aEdgeValue){ name = aName.toUpperCase(); code = aCode; value = aColor; edgevalue = aEdgeValue; }; int getCode(){ return code; }; void setColorFill(){ fill( value); }; void setColorEdge(){ stroke( edgevalue); }; color getColor(){ return value; }; String getName(){ return name; }; void readln( String in){ }; }; class ColorLibrary{ Hashtable colorByName; Hashtable colorByCode; ColorLibrary(String configFilePath){ colorByName = new Hashtable(); colorByCode = new Hashtable(); String lines[] = loadStrings(configFilePath); for (int i=0; i < lines.length; i++) { String[] t = splitTokens( lines[ i].trim(), " "); if( t.length >= 9){ if( t[0].equals( "0") && t[ 1].equals( "!COLOUR")){ int edgeColor; int baseColor; int r, g, b; int eColor; if( t[ 8].startsWith( "#")){ eColor = Integer.valueOf( t[ 8].substring( 1), 16); r = (eColor >> 16) & 0xFF; g = (eColor >> 8) & 0xFF; b = eColor & 0xFF; edgeColor = color( r, g, b); }else{ edgeColor = color( 0, 0, 0); }; eColor = Integer.valueOf( t[ 6].substring( 1), 16); r = (eColor >> 16) & 0xFF; g = (eColor >> 8) & 0xFF; b = eColor & 0xFF; if( t.length >= 11 && t[ 9].toUpperCase().equals( "ALPHA")){ baseColor = color( r, g, b, Integer.valueOf( t[ 10])); }else{ baseColor = color( r, g, b); }; LDrawColor col = new LDrawColor( t[ 2], Integer.valueOf( t[ 4]), baseColor, edgeColor); colorByName.put( col.getName(), col); colorByCode.put( col.getCode(), col); }; }; }; }; LDrawColor findByName( String name){ LDrawColor ldc = (LDrawColor)colorByName.get( name.toUpperCase()); return ldc; }; LDrawColor findByCode( int code){ LDrawColor ldc = (LDrawColor)colorByCode.get( code); if( ldc == null){ ldc = (LDrawColor)colorByCode.get( 13); }; return ldc; }; };