[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/video linedraw.c
From: |
Nehal Mistry |
Subject: |
[Stratagus-CVS] stratagus/src/video linedraw.c |
Date: |
Fri, 28 Nov 2003 16:59:41 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Nehal Mistry <address@hidden> 03/11/28 16:59:41
Modified files:
src/video : linedraw.c
Log message:
fix circle drawing for tiny circles
Patches:
Index: stratagus/src/video/linedraw.c
diff -u stratagus/src/video/linedraw.c:1.53 stratagus/src/video/linedraw.c:1.54
--- stratagus/src/video/linedraw.c:1.53 Thu Nov 27 05:33:51 2003
+++ stratagus/src/video/linedraw.c Fri Nov 28 16:59:41 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: linedraw.c,v 1.53 2003/11/27 10:33:51 nehalmistry Exp $
+// $Id: linedraw.c,v 1.54 2003/11/28 21:59:41 nehalmistry Exp $
//@{
@@ -810,25 +810,58 @@
}
}
+global void VideoDrawTransCircle(SDL_Color color, int x, int y,
+ int r, unsigned char alpha)
+{
+ int p;
+ int px;
+ int py;
+
+ p = 1 - r;
+ py = r;
+
+ for (px = 0; px <= py + 1; ++px) {
+ VideoDrawTransPixel(color, x + px, y + py, alpha);
+ VideoDrawTransPixel(color, x + px, y - py, alpha);
+ VideoDrawTransPixel(color, x - px, y + py, alpha);
+ VideoDrawTransPixel(color, x - px, y - py, alpha);
+
+ VideoDrawTransPixel(color, x + py, y + px, alpha);
+ VideoDrawTransPixel(color, x + py, y - px, alpha);
+ VideoDrawTransPixel(color, x - py, y + px, alpha);
+ VideoDrawTransPixel(color, x - py, y - px, alpha);
+
+ if (p < 0) {
+ p += 2 * px + 3;
+ } else {
+ p += 2 * (px - py) + 5;
+ py -= 1;
+ }
+ }
+}
+
global void VideoDrawCircleClip(SDL_Color color, int x, int y, int r)
{
- int w;
- int h;
+ SDL_Rect oldrect;
+ SDL_Rect newrect;
- w = h = r * 2;
+ SDL_GetClipRect(TheScreen, &oldrect);
+ newrect.x = ClipX1;
+ newrect.y = ClipY1;
+ newrect.w = ClipX2 - 2 * ClipX1;
+ newrect.h = ClipY2 - 2 * ClipY1;
- CLIP_RECTANGLE(x, y, w, h);
+ printf("x y w h %d %d %d %d\n", newrect.x, newrect.y, newrect.w,
newrect.h);
+ SDL_SetClipRect(TheScreen, &newrect);
VideoDrawCircle(color, x, y, r);
-
- r = w / 2;
- h = w / 2;
+ SDL_SetClipRect(TheScreen, &oldrect);
}
global void VideoDrawTransCircleClip(SDL_Color color, int x, int y,
int r, unsigned char alpha)
{
// FIXME: clip, trans
- VideoDrawCircle(color, x, y, r);
+ VideoDrawTransCircle(color, x, y, r, alpha);
}
global void VideoFillCircle(SDL_Color color, int x, int y, int r)
@@ -857,7 +890,7 @@
py -= 1;
// Fill up the left/right half of the circle
- if (py > px) {
+ if (py >= px) {
VideoDrawVLine(color, x + py + 1, y, px + 1);
VideoDrawVLine(color, x + py + 1, y - px, px);
VideoDrawVLine(color, x - py - 1, y, px + 1);
@@ -894,7 +927,7 @@
py -= 1;
// Fill up the left/right half of the circle
- if (py > px) {
+ if (py >= px) {
VideoDrawTransVLine(color, x + py + 1, y, px + 1, alpha);
VideoDrawTransVLine(color, x + py + 1, y - px, px, alpha);
VideoDrawTransVLine(color, x - py - 1, y, px + 1, alpha);
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/18
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/20
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/21
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/22
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/27
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/27
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/27
- [Stratagus-CVS] stratagus/src/video linedraw.c,
Nehal Mistry <=
- [Stratagus-CVS] stratagus/src/video linedraw.c, Nehal Mistry, 2003/11/29