High resolution rendering hack
in
Share your Work
•
2 years ago
For printing purposes, I needed to re-render one of my sketches in high-resolution. I've searched for ways to do this, but the only one I found was overly complicated and required me to re-write my whole script (for the purposes of tile-by-tile rendering).
That was not what I wanted - I wanted a simple way to switch between high-res and normal rendering, without a need to rewrite anything in the actual code.
After bit more research I come with a hack. It allows me, by appending it's code at the beginning of any script (which produces its result dynamically depending on width/height properties), to render the result in any resolution*.
* - Up to the java memory limit. Last time I checked, it was about 1.2 GB, even when machine I'm using has much more than that.
I have used this only twice, so I'm not aware about any other limitations, or side effects of this technique.
Finally, example script:
My questions are:
- Is there a non-hackish, 'proper' yet still simple way to do this?
- Are there any obvious disadvantages to this solution?
That was not what I wanted - I wanted a simple way to switch between high-res and normal rendering, without a need to rewrite anything in the actual code.
After bit more research I come with a hack. It allows me, by appending it's code at the beginning of any script (which produces its result dynamically depending on width/height properties), to render the result in any resolution*.
* - Up to the java memory limit. Last time I checked, it was about 1.2 GB, even when machine I'm using has much more than that.
I have used this only twice, so I'm not aware about any other limitations, or side effects of this technique.
Finally, example script:
- int sx = 5000;
int sy = 5000;
/* THE HACK */
g = createGraphics(sx,sy,JAVA2D);
this.height = sy;
this.width = sx;
g.beginDraw();
/* THE HACK end */
/* Example sketch start */
color c1 = #AFA786;
color c2 = #000000;
for (int y=0; y<=height; y++) {
stroke(lerpColor(c1,c2,float(y)/height));
line(0,y,width,y);
}
stroke(#FFFFFF);
fill(#BBBBBB);
ellipse(width/2, height/2, width/2, height/2);
line(0, 0, width, height);
/* Example sketch end */
g.endDraw(); /* THE HACK tail */
save("result.png");
My questions are:
- Is there a non-hackish, 'proper' yet still simple way to do this?
- Are there any obvious disadvantages to this solution?
2