import processing.pdf.*;
HDrawablePool pool;
HColorPool colors;
void setup(){
size(600,600);
H.init(this).background(#0e65e5);
smooth();
colors = new HColorPool(#0e65e5, #ffffff);
pool = new HDrawablePool(200);
pool.autoAddToStage()
.add(new HShape("multiply.svg"))
.layout(
new HGridLayout()
.startX(30)
.startY(20)
.spacing(50,50)
.cols(5)
)
.onCreate(
new HCallback() {
public void run(Object obj) {
HShape d = (HShape) obj;
d
.enableStyle(false)
.strokeJoin(ROUND)
.strokeCap(ROUND)
.strokeWeight(1)
.stroke(#ffffff)
.anchorAt(H.CENTER)
// .rotate((int)random(4)*45)
.size( (int)random(10,100) )
.loc( (int)random(width), (int)random(height) )
;
d.randomColors(colors.fillOnly());
}
}
)
.requestAll()
;
saveVector();
noLoop();
}
void draw() {
H.drawStage();
}
void saveVector() {
PGraphics tmp = null;
tmp = beginRecord(PDF, "render.pdf");
if(tmp == null) {
H.drawStage();
} else {
H.stage().paintAll(tmp, false, 1); //PGraphics, uses3D, alpha
}
endRecord();
}