Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to fill circle in Eric5h5's TextureDrawCircle function

$
0
0
**Hi,** well I'm make a new version of that http://wiki.unity3d.com/index.php?title=TextureDrawCircle function Circle (tex : Texture2D, cx : int, cy : int, r : int, col : Color) { for(i = 0; i <= r; i++) { var y = r - i; 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--; } } } } I have a circumference, and I want to fill it for make a circle... I only have to substract one from the radius, and I will fill it, but: ![Weird circle fill][1] It fills in a weird way... so what can I do? **Thanks in advance. Bye.** [1]: http://gyazo.com/e8124f9d62efebb6d18d8de0b938c8e3.png

Viewing all articles
Browse latest Browse all 171066