Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void MidPoint(int x0, int y0, int a, int b, Color FrontClr)
- {
- int a2 = a * a;
- int b2 = b * b;
- int Twoa2 = 2 * a2;
- int Twob2 = 2 * b2;
- int p;
- int x = 0;
- int y = b;
- int px = 0;
- int py = Twoa2 * y;
- DrawPoint(x0 + x, y0 + y, FrontClr);
- DrawPoint(x0 - x, y0 + y, FrontClr);
- DrawPoint(x0 - x, y0 - y, FrontClr);
- DrawPoint(x0 + x, y0 - y, FrontClr);
- /* For Region 1 */
- p =(int) Math.Round(b2 - (a2 * b) + (0.25) * a2);
- while (px < py)
- {
- DrawPoint(x0 + x, y0 + y, FrontClr);
- DrawPoint(x0 - x, y0 + y, FrontClr);
- DrawPoint(x0 - x, y0 - y, FrontClr);
- DrawPoint(x0 + x, y0 - y, FrontClr);
- x++;
- px += Twob2;
- if (p < 0)
- {
- p += b2 + px;
- }
- else
- {
- y--;
- py -= Twoa2;
- p += b2 + px - py;
- }
- }
- /* For Region 2*/
- p = (int)Math.Round(b2 * (x + 0.5) * (x + 0.5) + a2 * (y - 1) * (y - 1) - a2 * b2);
- while (y>0)
- {
- DrawPoint(x0 + x, y0 + y, FrontClr);
- DrawPoint(x0 - x, y0 + y, FrontClr);
- DrawPoint(x0 - x, y0 - y, FrontClr);
- DrawPoint(x0 + x, y0 - y, FrontClr);
- y--;
- py -= Twoa2;
- if (p > 0)
- {
- p += a2 - py;
- }
- else
- {
- x++;
- px += Twob2;
- p += a2 - py + px;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement