Hey all
I’m trying to write a script, where you can leave marks on texture in a specific color. I already found a script from Eric
which is able to draw circles on a texture:
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 += 2x+1;
if (d > 0) {
d += 2 - 2y–;
}
}
}
The problem is, that they are just circles and I would like to fill them.
He said a flood-fill algorithm would work, but it’s my first time working
with unity, so I would be very pleased if anybody could tell me how to
translate this algorithm to unity, particularly to the code above…
Thanks a lot for any kind of help.
Lena