Hello Everyone,
I am trying to recreate a basic poster with some randomness on the triangles and arcs (on key pressed).
The range in which the shapes can move is the full length of the screen’s width and height/2. However, I would like to keep the shapes within a custom range (Blue stroke on the attached image)
My code is using the width and height range to place the shapes:
//PShape mask;
void setup() {
size(630, 800);
noLoop();
//mask = createShape(ELLIPSE, width/2, height/2, 150);
}//closing setup
void draw() {
background(#dddddd);
//drawing 6 arcs and triangles from origin and then translating
for (int i= 0; i < 6; i++) {
fill(0);
noStroke();
pushMatrix();
**translate(random(width), random(height/2));**
rotate(random(-PI/10, PI/10));
triangle(0, 0, 50, 100, -50, 100);
popMatrix();
fill(#eeeeee);
pushMatrix();
**translate(random(width), random(height/2));**
rotate(random(TWO_PI));
arc( 0, 0, 100, 100, 0, PI+QUARTER_PI, CHORD);
popMatrix();
}
}//close draw function
void keyPressed() {
redraw();
}
I was thinking of creating a customised shape, using createShape() and then proceeding to draw the shape with vertex. However, such variable would be a PShape, which can’t be used within the random() function.
Is it possible to draw the shape and then extract the values that I need for my range? or would I need to manually set every coordinate to create the range in which I want my shapes to appear?
Thank you !