I am trying to implement a canvas image that will contain a circle and a number of rectangles inside the circle. The circle will be generated according to the given diameter (user input) and the rectangles will be generated according to the given height and width (user inputs). The number of rectangles will be created according to the formula shown below.
Rectangles per Circle = d * pi * ((d / 4 * S) - (1 / sqrt(2 * S))) d – Circle Diameter S – Rectangle Size
For a 300px diameter circle, and 10px width with a 10px height rectangle, there will be 641 rectangles inside the circle.
But I need to place the rectangles properly inside the circle something like below.