# Draw/“rasterize” irregular circle onto a 2D grid

I'm using the midpoint circle algorithm to choose cells on a 2D grid which outline a circle. However, I need to incorporate some random noise so that I get an irregular circle, and this method won't work anymore given how it works. Another stack exchange answer describes an equation (the "pink noise" example) I'd like to try but I'm not sure on the best approach to implement it.

I can replicate the equation via code, but I'll need to start choosing grid cells/coordinates differently and I'm not sure the best solution.

How can I "rasterize" an irregular circle like this?

You can pretty closely simulate this with Bresenham's line algorithm. Let's say we have a function called line(x1, y1, x2, y2) which draws a line between (x1, y1) and (x2, y2) and the noise function:

private double PinkNoise(double theta)
{
return 1 + 0.25 * (
0.883 * Math.Sin(theta + 2 * Math.PI * 0.468) +
0.159 / 2 * Math.Sin(2 * theta + 2 * Math.PI * 0.9) +
0.828 / 3 * Math.Sin(3 * theta + 2 * Math.PI * 0.464) +
0.021 / 4 * Math.Sin(4 * theta + 2 * Math.PI * 0.388) +
0.754 / 5 * Math.Sin(5 * theta + 2 * Math.PI * 0.443)
);
}


Then rasterizing this shape simply becomes iterating between 0 and 2pi, each time getting the radius for that angle and getting the to and from positions for the line function using trigonometr (x = cos(theta), y = sin(theta))

• To make sure I understand, are you suggesting that I used the Bresenham line algorithm to draw the line segments, chosen by iterating from 0-2pi and getting the radius for that angle, which when connected would form my circle? – BotskoNet Oct 17 '17 at 14:42
• @BotskoNet exactly – Bálint Oct 17 '17 at 15:51