We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone, I'm working on the project P_2_3_6_02 of the book Generative Design (http://www.generative-gestaltung.de/P_2_3_6_02). I'm using this free code for a university project, replacing original modules with modules designed by me and my classmates. (here an example: http://imageshack.com/a/img909/8080/HQx9py.png)
Now I'd like to "limit" each module in certain areas of my workspace, in order to have some grids in which draw certain shapes . For example I want to create a striped flag where the module A can be used only in the first strip and not in the other.
How can I say, for example, that modules A can't draw from pixel 200 to 300?
Thanks to anyone who can help me. (sorry for my english, I hope to be clear)
Answers
i don't understand
in the original I see 1,2,3 etc. Is this what you call module? you replaced it but still.
when you say you want to limit it, do you mean where they are placed On the grid? is the placing via random ?
or do you mean the construction of the modules itself?
;-)
You may find it more useful to think the other way around. Rather than trying to prevent a piece of code from drawing somewhere (which would be very hard), you might find it easier to tell your code where it is allowed to draw. Then it's your code's responsibility to respect that boundary.
It looks like you're using rectangles. So each time you want to draw something, you can pass your code the rectangle within which it can draw (you can structure the rectangle in a million ways - e.g., the coordinates of the upper-left and lower-right corners, the rectangle's center point and width and height, the center and half-width and half-height, and so on. Pick whichever one seems most convenient for you.) Then your program just sticks within those bounds.
For example, if you choose to pass in
(ulx, uly)
and(lrx, lry)
for the upper-left and lower-right points respectively, just never draw anything where thex
value is less thanulx
or greater thanlrx
, andy
is never less thanuly
or greater thanlry
. Of course, you could usePVector
objects rather than pairs of floats.