Commits

Anonymous committed a4783d9

- #50, add gdImageEllipse (test to come)

  • Participants
  • Parent commits c0f943e
  • Branches GD-2.0

Comments (0)

Files changed (1)

     }
 }
 
+BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
+{
+	int x=0,mx1=0,mx2=0,my1=0,my2=0;
+	long aq,bq,dx,dy,r,rx,ry,a,b;
+
+	a=w>>1;
+	b=h>>1;
+	gdImageSetPixel(im,mx+a, my, c);
+	gdImageSetPixel(im,mx-a, my, c);
+	mx1 = mx-a;my1 = my;
+	mx2 = mx+a;my2 = my;
+
+	aq = a * a;
+	bq = b * b;
+	dx = aq << 1;
+	dy = bq << 1;
+	r  = a * bq;
+	rx = r << 1;
+	ry = 0;
+	x = a;
+	while (x > 0){
+		if (r > 0) {
+			my1++;my2--;
+			ry +=dx;
+			r  -=ry;
+		}
+		if (r <= 0){
+			x--;
+			mx1++;mx2--;
+			rx -=dy;
+			r  +=rx;
+		}
+		gdImageSetPixel(im,mx1, my1, c);
+		gdImageSetPixel(im,mx1, my2, c);
+		gdImageSetPixel(im,mx2, my1, c);
+		gdImageSetPixel(im,mx2, my2, c);
+	}
+}
+
+
 BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
 {
 	int x=0,mx1=0,mx2=0,my1=0,my2=0;