HDrawablePool pool, pool2; HColorPool colors; float theta; float sz, _sz; int _cols, _rows; int numElem; void setup() { size(1136, 640); H.init(this).background(#ffffff).autoClear(true); smooth(); colors = new HColorPool() .add(#F1B710,9) .add(#F28F15,9) .add(#F25C0A,9) .add(#BF2705,3) .add(#730502,2) ; sz = 50; //float cell = sz + 10; float cell = sz*1.25; float _startX = cell; float _startY = cell; _cols = int(width/cell)-1; _rows = int(height/cell)-1; numElem = int(_cols*_rows); pool = new HDrawablePool(numElem); pool.autoAddToStage() .add ( new HRect() .rounding(3) ) .layout ( new HGridLayout() .startX(cell) .startY(cell) .spacing(cell, cell) .cols(_cols) ) .onCreate ( new HCallback() { public void run(Object obj) { _sz = sz; HDrawable d = (HDrawable) obj; d //.noStroke() .strokeWeight(2) .stroke(#000000,100 ) .noFill() //.fill( #ECECEC ) .anchorAt(H.CENTER) .size( _sz ) ; } } ) .requestAll() ; pool2 = new HDrawablePool(numElem); pool2.autoAddToStage() .add ( new HRect() .rounding(5) ) .layout ( new HGridLayout() .startX(cell) .startY(cell) .spacing(cell, cell) .cols(_cols) ) .onCreate ( new HCallback() { public void run(Object obj) { _sz = sz ; HDrawable d = (HDrawable) obj; d .noStroke() .fill( colors.getColor(),200) .anchorAt(H.CENTER) .size(_sz+ random(-10,10), _sz+ random(-10,10)) ; } } ) .requestAll() ; H.drawStage(); //noLoop(); } void draw() { } void mouseClicked() { setup(); }