Subversion Repositories PlanixRsrch.SVN

Rev

Rev 105 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/* ---------------------------------------------------------------
SETPATT.C
(c) 1992 by Tobias Herre
part of DISPLAY.LIB version 1.0
----------------------------------------------------------------*/


#include "display.h"
/*----------------------------------------------------------------------------
 Ellipse zeichnen  (bei x,y mit Radius a und b)
*/

void Ellipse(int x,int y,int a,int b)
{
 int x1,y1;
 long ref,xan,yan,xann,yann;

 x1=0;y1=b;

 xan=(long)b*(long)b;      /* Anstieg fr X berechnen */
 xann=2L*(long)b*(long)b; /* Anstieg fr X-Anstieg berechnen */

 yan=-2L*(long)y1*(long)a*(long)a+(long)a*(long)a; /* Anstieg fr Y */
 yann=2L*(long)a*(long)a;       /* Anstieg des Y-Anstieges */

 ref=xan/2;

 while (y1>=0){
  PutPixel(x+x1,y+y1);
  PutPixel(x-x1,y+y1);
  PutPixel(x+x1,y-y1);
  PutPixel(x-x1,y-y1);

  if(ref+yan<0){
   ref+=xan; xan+=xann; x1++;
   if(ref+ref+yan>=0){
    ref+=yan; yan+=yann; y1--;
   }
  }
  else{
   ref+=yan; yan+=yann; y1--;
   if (ref+ref+xan<0){
    ref+=xan; xan+=xann; x1++;
   }
  }
 }
 y1++;
 while(x1<=a){
  PutPixel(x+x1,y+y1);
  PutPixel(x-x1,y+y1);
  PutPixel(x+x1,y-y1);
  PutPixel(x-x1,y-y1);
  x1++;
 }
}