We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Scaling (Read 429 times)
Scaling
Aug 20th, 2008, 12:20am
 
I often get to a point where my canvas is getting to small. For example, most of the time I start with creating on element and it may looks the following image:

These are not my pictures! These are from LennyJPG. i just choose them because they describe my problem quite well...

http://farm1.static.flickr.com/157/405067398_388d2f1c08.jpg?v=0

but at the end it should look more like

http://farm1.static.flickr.com/172/404915028_9b8b819a00.jpg?v=0

so what is the best way for that? i used to do that by scaling with scale() but when i use it i often have to adjust alot like (width/2,height/2) cause these things dont work anymore. Or can i create a cam and just zoom out? dont know is there an easy way of "zooming out"?

Thanks!

Re: Scaling
Reply #1 - Aug 20th, 2008, 4:01pm
 
You are not limited to integer values when specifying coordinates for drawing commands (rect, ellipse, strokeWeight etc.). This means you could always specify coordinates as a fraction of width and height to ensure that even the largest shapes get shrunk down to fit in the display space. Many of the pretty sketches you see around will use non-integer coordinates, especially when determining line thickness.

Alternatively, as you suggest, the scale command can be used to shrink coordinates into the display space (see my posting on zooming and panning for an example of this).

One thing to watch out for when scaling down coordinates is that you don't inadvertently perform an integer divide. If the numerator and denominator of a division are both integers, the result is also an integer. So, for example, if width is 450, width/100 will be evaluated as 5, not 4.5.  To ensure decimal division use (float)width/100 instead.
Page Index Toggle Pages: 1