nannou
nannou copied to clipboard
How to set origin to lower left corner instead of center?
I have a huge list of coordinates describing different shapes and lines. But they all assume left corner as the 0,0 position. Is there a way to set origin to lower left corner? so that when drawing shapes or lines or anything I don't have to translate each shape and just draw normally.
e.g. this should draw the rectangle in lower left corner of the window after moving the origin there.
draw.rect().color(STEELBLUE).w(10).h(10).x_y(0,0);
You can translate the whole draw
once then all the following calls will be translated.
draw = draw.x_y(-width*0.5, -height*0.5);
Now if you want a coordinate system like processing, you'll also have to invert the y axis, with scale
.
Didn't know I could do this.
I recommend checking out the Window Coordinates tutorial in the guide too - hopefully it can give some tips for working comfortably with nannou's default coordinate system.