 # How to change multiple oval sizes at one time

Hi so I am trying to draw 3 circles on an image in a ratio format ( for example: 1st circle is 1 cm, then 2nd is 3x that, and 3rd is 6x the first). I know how to draw the circles but is there a way to make the circles bigger or smaller all at once (like the 3 circles would be a template and then according to the image if I line up circle 1 then the other 2 change size in ratio to the 1st circle change)

Hi @ashin,

You can accomplish that in several ways, but if you want exact circles, drawing the first circle and running a script like this should work:

``````getSelectionBounds(x, y, width, height);
//the following is true for a perfectly round circle:
diam = (width+height)/2;
cx = x + width/2;
cy = y + height/2;

makeOval(cx-diam/2, cy-diam/2, diam, diam);
makeOval(cx-diam, cy-diam, diam*2, diam*2);
makeOval(cx-diam/2*3, cy-diam/2*3, diam*3, diam*3);
roiManager("Show All without labels");

//restore original:
roiManager("select", roiManager("count")-4);
roiManager("delete");
run("Restore Selection");
``````

Best,
Nico

ah I see. If I want to change the ratio to make the circles smaller than the initial circle where would I change in the script. also if I wanted to use this to make with not perfectly round circles would that be possible?

The command that creates the ovals is:

``````makeOval(x, y, width, height);
``````

You can take a look at the macro language documentation to learn about this and other functions.

So, to make this more general, we could modify the code to:

``````getSelectionBounds(x, y, width, height);

ratio_1 = 0.75;
ratio_2 = 0.5;
cx = x + width/2;
cy = y + height/2;

makeOval(cx-width/2, cy-height/2, width, height); // draw original
makeOval(cx-width/2*ratio_1, cy-height/2*ratio_1, width*ratio_1, height*ratio_1); // draw scaled by ratio1_1
makeOval(cx-width/2*ratio_2, cy-height/2*ratio_2, width*ratio_2, height*ratio_2); // draw scaled by ratio_2
roiManager("Show All without labels");

//restore original:
roiManager("select", roiManager("count")-4);
roiManager("delete");
run("Restore Selection");
``````

Cheers!
Nico

1 Like

thank you!! lots of help