import processing.pdf.*;

HDrawablePool pool;
HColorPool colors;

void setup(){
	size(600,600);
	H.init(this).background(#000000);
	smooth();

	colors = new HColorPool(#ffffff);

	pool = new HDrawablePool(121);
	pool.autoAddToStage()
		 .add(new HShape("multiply.svg"))

		
		.layout(
			new HGridLayout()
			.startX(50)
			.startY(50)
			.spacing(50,50)
			.cols(11)
		)

		.onCreate(
			new HCallback() {
				public void run(Object obj) {
					HShape d = (HShape) obj;
					d
						.enableStyle(false)
						.strokeJoin(ROUND)
						.strokeCap(ROUND)
						.strokeWeight(2)
						.stroke(#000000)
						.anchorAt(H.CENTER)
						// .rotate((int)random(4)*45)
						.size( (int)random(5,200) )
						// .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();
}
@