Advanced GUI

Developer
Jan 4, 2011 at 11:55 PM

Hey guys how do you draw a Circle in pixels without arrays.

I have a Method to Draw Squares,Rectangles  and Triangles but none for a circle.

Coordinator
Jan 5, 2011 at 12:33 AM
On 1/4/2011 7:55 PM, forest201 wrote:
> Hey guys how do you draw a Circle in pixels without arrays.

You're going to need floating point or at least decimal support to do that.
Jan 5, 2011 at 10:30 AM

lol u dont need decimals if ur me use this code:

use it well it was a b*tch to figure out

public static void drawCircle(uint X, uint Y, int radius, uint SPE)
    {
        int i, j;
        uint x, y, z = 0;
        radius--;
        for (y = Y + 1, i = radius; i > 0; i--, y++)
        {
            for (x = X + 1, j = radius; j > 0; j--, x++, z++)
            {
                if (i * i + j * j < radius * radius)
                    circledraw[z] = VGAScreen.GetPixel320x200x8(x, y);
            }
            for (j = 0; j < radius; j++, x++, z++)
            {
                if (i * i + j * j < radius * radius)
                    circledraw[z] = VGAScreen.GetPixel320x200x8(x, y);
            }
        }
        for (i = 0; i < radius; i++, y++)
        {
            for (x = X + 1, j = radius; j > 0; j--, x++, z++)
            {
                if (i * i + j * j < radius * radius)
                    circledraw[z] = VGAScreen.GetPixel320x200x8(x, y);
            }
            for (j = 0; j < radius; j++, x++, z++)
            {
                if (i * i + j * j < radius * radius)
                    circledraw[z] = VGAScreen.GetPixel320x200x8(x, y);
            }
        }
        radius++;
        for (y = Y, i = radius; i > 0; i--, y++)
        {
            for (x = X, j = radius; j > 0; j--, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
            for (j = 0; j < radius; j++, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
        }
        for (i = 0; i < radius; i++, y++)
        {
            for (x = X, j = radius; j > 0; j--, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
            for (j = 0; j < radius; j++, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
        }
    }
Jan 5, 2011 at 10:33 AM

accualy part of that was for an experimental feature i was working on use this instead

public static void drawCircle(uint X, uint Y, int radius, uint SPE)
    {
        int i, j;
        uint x, y, z = 0;
        for (y = Y, i = radius; i > 0; i--, y++)
        {
            for (x = X, j = radius; j > 0; j--, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
            for (j = 0; j < radius; j++, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
        }
        for (i = 0; i < radius; i++, y++)
        {
            for (x = X, j = radius; j > 0; j--, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
            for (j = 0; j < radius; j++, x++)
            {
                if (i * i + j * j < radius * radius)
                    VGAScreen.SetPixel320x200x8(x, y, SPE);
            }
        }
    }