We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to use scale and I'm puzzle by the result of the following code:
void setup()
{
size(1000, 600);
noLoop();
}
void draw()
{
scale(width/2, height/4);
noFill();
rect(0,0,1,1);
}
I'm expecting a unfilled rectange taking half the width and quarter the height but I'm seeing a filled rectange with strange boundaries.
Is there any reason or is this a bug ? The same happens with shapes.
Answers
Scale values are specified as decimal percentages. For example, the function call scale(2.0) increases the dimension of a shape by 200%.
I understand that, it is exactly why I don't understand what is going on in the above example
@marc_nostromo --
If you comment out your call to
scale()
you will see that you have drawn a 1x1 pixel rect -- it has no fill, but the default stroke is black, so the result is a black dot in the upper-left corner of your sketch. You usescale()
to zoom in on that black dot with width of x500 and a height of x150. The zoomed in and distorted shape of that single pixel becomes a very big rectangle on the screen.Here is a simple sketch to show you this happening -- it zooms in x1, x2, x3, x4 etc. as the frameCount increases. When the count becomes higher than x400 (after about seven seconds) that 1 pixel rectangle will 400 pixels wide and will fill the sketch area.
To better understand how
scale()
works and why, check the reference page and read the Processing "Coordinate System and Shapes" tutorial for background:Regarding:
...the easiest way to do this is:
Haa... I get it. So I'm basically stroking with a huge pen. That make sense, thanks