I need help with Processing (objects are cut off the screen)

[Hello! I am new to processing and this forum, srry if I’m messing up the format. I am trying to have an array of 100 random objects on my canvas but I don’t want the objects to be cut off the screen. Can someone help me with this? thx]

PShape honeycomb;
int x,y;

void setup () {
  size (600,400);
  background (240,248,255);  
  honeycomb = createShape ();
  honeycomb.beginShape ();
  honeycomb.fill (255,215,0);
  honeycomb.stroke(255,255,0);
  honeycomb.vertex (15,0);
  honeycomb.vertex (30,0);
  honeycomb.vertex (45,22.5);
  honeycomb.vertex (30,45);
  honeycomb.vertex (15,45);
  honeycomb.vertex (0,22.5);
  honeycomb.vertex (15,0);
  honeycomb.endShape (CLOSE);

for (int i = 0; i < 80; i ++) {
   shape(honeycomb,random(width),random(height));
}
}




void draw () {
 
}

Hello,

Take a look at these references and the Related references:

:)

Thankyou for replying! Currently the width of my shape is 45, so from the centre to the edge should be about 22.5. If I set a high and low for the random command, would I have to subtract the radius from it? Like width-radiusofshape?

1 Like

yes,

......random(23,width-23),random(23,height-23)

Remark

it will look more sharp / crisp with this in draw() (and with background() before it)

ShapeMode() is one of the related references.

These are all things you can try yourself.

:)