I am trying to draw a bunch of objects in a constrained area, they are being translated so that they form interesting shapes together but I cannot figure out how to constrain these shapes to one area and not the entire screen.
I want two sets of bubble one set constrained to the left side the other on the right. I was able to get that picture after a while but i want it to happen more often and less random
void setup {
//size of canvas
size(420, 520);
//background is black
//stroke color is white
stroke(255);
//stroke is smooth and not pixelated
smooth();
}
void draw()
{
background(0);
BubbleDraw();
}
void BubbleDraw()
{
//displacing the circles in a group in the middle
translate(width/2, height/2);
for (int i = 0; i < 30; i++)
{
for (int j = 0; j < 15; j++)
{
//circles have no fill (press picture before page turns white)
fill(0);
//the angles in which the circles rotate are from -90 to 90
float angle = random (-180, 180);
//changes degrees to radians
rotate (radians (angle));
//circles made at 0,0 progressively get larger
ellipse(0, 0, i+j, i+j);
//moves the circles individually
translate(0, 30);
}
noLoop();
}
}
Comments
Can you post an MCVE?
I want two sets of bubble one set constrained to the left side the other on the right. I was able to get that picture after a while but i want it to happen more often and less random
go back, edit your post please
select the entire code, hit ctrl-o
@chrisir what would be a way to constrain these circles in a specific area (like in a rectangle area or some other crazy shape)
It's not easy the way you were doing it because you surrendered control of the coordinate system to randomness. This approach is better.