float BLOCKSIZE = 30; float BS = BLOCKSIZE; float HBS = BS/2; ArrayList therms = new ArrayList(); void setup(){ size(300,450); smooth(); therms.add(new Therm(0,5,UP,6)); therms.add(new Therm(0,6,RIGHT,3)); therms.add(new Therm(0,7,RIGHT,4)); therms.add(new Therm(0,8,RIGHT,6)); therms.add(new Therm(0,12,UP,4)); therms.add(new Therm(1,12,UP,4)); therms.add(new Therm(2,12,UP,4)); therms.add(new Therm(3,13,LEFT,4)); therms.add(new Therm(0,14,RIGHT,5)); therms.add(new Therm(1,2,UP,3)); therms.add(new Therm(2,0,RIGHT,5)); therms.add(new Therm(7,0,RIGHT,3)); therms.add(new Therm(2,2,UP,2)); therms.add(new Therm(3,1,DOWN,2)); therms.add(new Therm(4,3,UP,3)); therms.add(new Therm(5,1,DOWN,3)); therms.add(new Therm(6,1,DOWN,4)); therms.add(new Therm(7,1,DOWN,3)); therms.add(new Therm(8,5,UP,5)); therms.add(new Therm(9,1,DOWN,3)); therms.add(new Therm(1,3,RIGHT,3)); therms.add(new Therm(1,5,UP,2)); therms.add(new Therm(5,4,LEFT,4)); therms.add(new Therm(2,5,RIGHT,2)); therms.add(new Therm(6,5,LEFT,3)); therms.add(new Therm(7,5,UP,2)); therms.add(new Therm(9,5,UP,2)); therms.add(new Therm(3,6,RIGHT,4)); therms.add(new Therm(7,6,RIGHT,3)); therms.add(new Therm(4,7,RIGHT,3)); therms.add(new Therm(7,7,DOWN,3)); therms.add(new Therm(8,9,UP,3)); therms.add(new Therm(9,10,UP,4)); therms.add(new Therm(6,10,UP,3)); therms.add(new Therm(5,9,LEFT,3)); therms.add(new Therm(3,10,DOWN,3)); therms.add(new Therm(4,10,DOWN,4)); therms.add(new Therm(5,12,UP,3)); therms.add(new Therm(5,13,DOWN,2)); therms.add(new Therm(8,10,LEFT,2)); therms.add(new Therm(9,11,LEFT,4)); therms.add(new Therm(6,13,UP,2)); therms.add(new Therm(9,12,LEFT,3)); therms.add(new Therm(7,13,RIGHT,2)); therms.add(new Therm(9,13,DOWN,2)); therms.add(new Therm(8,14,LEFT,3)); //ellipseMode(CORNER); stroke(0);strokeWeight(1); for(int x = 0 ; x < 10; x++){ line(x*BLOCKSIZE,0,x*BLOCKSIZE,15*BLOCKSIZE); } for(int y = 0 ; y < 15; y++){ line(0,y*BLOCKSIZE,10*BLOCKSIZE,y*BLOCKSIZE); } int p =0; for(Therm t : therms){ t.draw(); t.print(p); p++; } } class Therm{ int x,y,dir,sz,ex,ey; Therm(int px, int py, int pdir,int psz){ x = px; y = py; dir = pdir; sz = psz; ex =x ; ey = y; if(dir == UP) ey -= (sz-1); if(dir == DOWN) ey += (sz-1); if(dir == LEFT) ex -= (sz-1); if(dir == RIGHT) ex += (sz-1); } void draw(){ fill(200,50,50,128);stroke(0); strokeWeight(1); ellipse(x*BLOCKSIZE+HBS,y*BLOCKSIZE+HBS,BLOCKSIZE,BLOCKSIZE); stroke(255,255,255);strokeWeight(12); line(x*BS +HBS,y*BS+HBS,ex*BS+HBS,ey*BS+HBS); } void print(int p){ // println("t.len = "+sz+";"); println("//thermo "+p+" length "+sz); int mx = x; int my = y; println("grid->th["+p+"].len="+sz+";"); for(int i = 0; i < sz; i++){ println("grid->th["+p+"].x["+i+"]="+mx+";"); println("grid->th["+p+"].y["+i+"]="+my+";"); if(dir == UP) my--;// -= (sz-1); if(dir == DOWN) my++;// += (sz-1); if(dir == LEFT) mx--;// -= (sz-1); if(dir == RIGHT) mx++;// += (sz-1); } p++; } }