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!