drawOval method
Draws a filled oval (ellipse) centered at (x, y)
.
x
: The x-coordinate of the center of the oval.y
: The y-coordinate of the center of the oval.radiusX
: The radius along the x-axis.radiusY
: The radius along the y-axis.segments
: The number of line segments to use to approximate the oval. More segments result in a smoother oval. Defaults to 32.colors
: An optional list of Color objects.colors[0]
is for the center, subsequent colors apply to the perimeter vertices.
Implementation
void drawOval(double x, double y, double radiusX, double radiusY, {int segments = 32, ColorList? colors}) {
_prepareRenderState(_PrimitiveType.triangleFan, texture: Texture.white);
_transfromAndAddVertices(x, y, 0.5, 0.5, getColorFromList(colors, 0, _encodedColor));
for (int i = 0; i <= segments; ++i) {
final angle = i * (2 * pi / segments);
final vx = x + radiusX * cos(angle);
final vy = y + radiusY * sin(angle);
final uvX = 0.5 + 0.5 * cos(angle);
final uvY = 0.5 + 0.5 * sin(angle);
_transfromAndAddVertices(vx, vy, uvX, uvY, getColorFromList(colors, 1 + i, _encodedColor));
}
}