Hello, I’m currently having an error when rendering an ellipse, I have the code that checks if a pixel is within a region that creates an ellipse but when it runs, you can clearly see an ellipse but there are these empty lines every other pixel.
Heres an example of the problem:
Heres code:
_spriteBatch.Begin();
texBuffer = new Texture2D(_graphics.GraphicsDevice, element.X2 - element.X1, element.Y2 - element.Y1);
Color[] data = new Color[(element.X2 - element.X1) * (element.Y2 - element.Y1)];
for (int i = 0; i < data.Length; ++i)
{
Vector2 coord = new Vector2(i % (element.Y2 - element.Y1), i / (element.X2 - element.X1));
int x = (int)coord.X;
int y = (int)coord.Y;
int h = (element.X2 - element.X1) / 2;
int k = (element.Y2 - element.Y1) / 2;
int a = 0;
int b = 0;
if (h > k)
{
a = k;
b = h;
}
else
{
a = h;
b = k;
}
if ((Math.Pow(x-h, 2) / Math.Pow(a, 2)) + (Math.Pow(y-k, 2) / Math.Pow(b, 2)) <= 1)
{
data[i] = element.Color;
}
else
{
data[i] = Color.Transparent;
}
}
texBuffer.SetData(data);
Vector2 coor = new Vector2(element.X1, element.Y1);
_spriteBatch.Draw(texBuffer, coor, Color.White);
_spriteBatch.End();