Dette er Java, men du kan nok lave det om til C#:
- public void drawEllipse(double centerX, double centerY, double horizontalRadius, double verticalRadius, double steps) {
- double lastX = centerX + horizontalRadius,
- lastY = centerY, nextX, nextY;
- for (int i = 1; i <= steps; i++) {
- nextX = centerX + Math.cos(Math.PI * 2 / steps * i) * horizontalRadius;
- nextY = centerY + Math.sin(Math.PI * 2 / steps * i) * verticalRadius;
- drawLine((int)lastX, (int)lastY, (int)nextX, (int)nextY);
- lastX = nextX;
- lastY = nextY;
- }
- }
Du skal bare implementere drawLine
Indlæg senest redigeret d. 10.01.2012 16:47 af Bruger #2695