import processing.pdf.*;
HDrawablePool pool;
HColorPool colors;
void setup(){
size(600,600);
H.init(this).background(#383838);
smooth();
colors = new HColorPool(#627f70);
pool = new HDrawablePool(5);
pool.autoAddToStage()
.add(new HShape("multiply.svg"))
.layout(
new HGridLayout()
.startX(5)
.startY(5)
.spacing(5,5)
.cols(5)
)
.onCreate(
new HCallback() {
public void run(Object obj) {
HShape d = (HShape) obj;
d
.enableStyle(false)
.strokeJoin(ROUND)
.strokeCap(ROUND)
.strokeWeight(2)
.stroke(#ffffff)
.anchorAt(H.CENTER)
.rotate((int)random(4)*45)
.size( (int)random(50,400) )
.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();
}