How to limit drawing into grid - Generative Design P_2_3_6_02

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 the x value is less than ulx or greater than lrx, and y is never less than uly or greater than lry. Of course, you could use PVector objects rather than pairs of floats.

Sign In or Register to comment.