Skip to content Skip to sidebar Skip to footer

Android - Trying To Gradually Fill A Circle Bottom To Top

I'm trying to fill a round circle (transparent other than the outline of the circle) in an ImageView. I have the code working: public void setPercentage(int p) { if (this.perce

Solution 1:

pseudo would look something like this.

    for each pixel inside CircleBitmap {

        if (pixel.y is < Yboundary && pixelIsInCircle(pixel.x, pixel.y)) {
           CircleBitmap .setPixel(x, y, Color.rgb(45, 127, 0));
        }
    }

that may be slow, but it would work, and the smaller the circle the faster it would go.

just know the basics, bitmap width and height, for example 256x256, the circles radius, and to make things easy make the circle centered at 128,128. then as you go pixel by pixel, check the pixels X and Y to see if it falls inside the circle, and below the Y limit line.

then just use:

    CircleBitmap .setPixel(x, y, Color.rgb(45, 127, 0));

edit: to speed things up, don't even bother looking at the pixels above the Y limit.


Solution 2:

in case if you want to see another solution (perhaps cleaner), look at this link, filling a circle gradually from bottom to top android


Post a Comment for "Android - Trying To Gradually Fill A Circle Bottom To Top"