Drawing a solid circle onto texture

Has anyone modified Eric Haines’ (Eric5h5) TextureDrawCircle script to draw a solid circle? It currently draws only the perimeter. Any suggestions on how a solid circle drawing algorithm would go?

Here’s a link to Eric’s lovely script: TextureDrawCircle - Unify Wiki

and here’s a snippet:

static function Circle (tex : Texture2D, cx : int, cy : int, r : int, col : Color) {
	var y = r;
	var d = 1/4 - r;
	var end = Mathf.Ceil(r/Mathf.Sqrt(2));
 
	for (x = 0; x <= end; x++) {
		tex.SetPixel(cx+x, cy+y, col);
		tex.SetPixel(cx+x, cy-y, col);
		tex.SetPixel(cx-x, cy+y, col);
		tex.SetPixel(cx-x, cy-y, col);
		tex.SetPixel(cx+y, cy+x, col);
		tex.SetPixel(cx-y, cy+x, col);
		tex.SetPixel(cx+y, cy-x, col);
		tex.SetPixel(cx-y, cy-x, col);
 
		d += 2*x+1;
		if (d > 0) {
			d += 2 - 2*y--;
		}
	}
}

Thank you very much!

Problem solved! Below is a modified function for creating a solid circle!

public void Circle(Texture2D tex, int cx, int cy, int r, Color col)
	{
		int x, y, px, nx, py, ny, d;
		
		for (x = 0; x <= r; x++)
		{
			d = (int)Mathf.Ceil(Mathf.Sqrt(r * r - x * x));
			for (y = 0; y <= d; y++)
			{
				px = cx + x;
				nx = cx - x;
				py = cy + y;
				ny = cy - y;

				tex.SetPixel(px, py, col);
				tex.SetPixel(nx, py, col);

				tex.SetPixel(px, ny, col);
				tex.SetPixel(nx, ny, col);

			}
		}	
	}

@pajamajama @Bunny83 I want to draw rectangles in the same way . I dont know how to do that? I also would like to know that how can I draw rectangles with round edges or maybe add some more shapes. I’m currently stuck here and any help would be great. Thanks in advance.