From 30850e232c81d0d8900b6fcd58b152d68c80e390 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Thu, 18 Jul 2024 22:05:37 +0200 Subject: [PATCH 1/8] Shim gfxdraw when possible --- buildconfig/Setup.Android.SDL2.in | 2 +- buildconfig/Setup.Emscripten.SDL2.in | 2 +- buildconfig/Setup.SDL2.in | 2 +- buildconfig/stubs/pygame/gfxdraw.pyi | 32 +- src_c/SDL_gfx/SDL_gfxPrimitives.c | 4367 ++---------------------- src_c/SDL_gfx/SDL_gfxPrimitives.h | 154 - src_c/SDL_gfx/SDL_gfxPrimitives_font.h | 3082 ----------------- src_c/_gfxdraw.c | 447 +++ src_c/gfxdraw.c | 1045 ------ src_c/meson.build | 6 +- src_c/static.c | 4 +- src_py/gfxdraw.py | 85 + src_py/meson.build | 1 + 13 files changed, 752 insertions(+), 8477 deletions(-) delete mode 100644 src_c/SDL_gfx/SDL_gfxPrimitives_font.h create mode 100644 src_c/_gfxdraw.c delete mode 100644 src_c/gfxdraw.c create mode 100644 src_py/gfxdraw.py diff --git a/buildconfig/Setup.Android.SDL2.in b/buildconfig/Setup.Android.SDL2.in index fc556ad024..9bcaa77d74 100644 --- a/buildconfig/Setup.Android.SDL2.in +++ b/buildconfig/Setup.Android.SDL2.in @@ -29,7 +29,7 @@ _sdl2.controller_old src_c/_sdl2/controller_old.c $(SDL) $(DEBUG) -Isrc_c GFX = src_c/SDL_gfx/SDL_gfxPrimitives.c #GFX = src_c/SDL_gfx/SDL_gfxBlitFunc.c src_c/SDL_gfx/SDL_gfxPrimitives.c -gfxdraw src_c/gfxdraw.c $(SDL) $(GFX) $(DEBUG) +_gfxdraw src_c/_gfxdraw.c $(SDL) $(GFX) $(DEBUG) #optional freetype module (do not break in multiple lines #or the configuration script will choke!) diff --git a/buildconfig/Setup.Emscripten.SDL2.in b/buildconfig/Setup.Emscripten.SDL2.in index 23b22f5766..5b40e629fe 100644 --- a/buildconfig/Setup.Emscripten.SDL2.in +++ b/buildconfig/Setup.Emscripten.SDL2.in @@ -48,7 +48,7 @@ display src_c/void.c draw src_c/void.c event src_c/void.c font src_c/void.c -gfxdraw src_c/void.c +_gfxdraw src_c/void.c joystick src_c/void.c key src_c/void.c newbuffer src_c/void.c diff --git a/buildconfig/Setup.SDL2.in b/buildconfig/Setup.SDL2.in index 2fd66eeea3..27b3eed752 100644 --- a/buildconfig/Setup.SDL2.in +++ b/buildconfig/Setup.SDL2.in @@ -39,7 +39,7 @@ _sdl2.controller_old src_c/_sdl2/controller_old.c $(SDL) $(DEBUG) -Isrc_c GFX = src_c/SDL_gfx/SDL_gfxPrimitives.c #GFX = src_c/SDL_gfx/SDL_gfxBlitFunc.c src_c/SDL_gfx/SDL_gfxPrimitives.c -gfxdraw src_c/gfxdraw.c $(SDL) $(GFX) $(DEBUG) +_gfxdraw src_c/_gfxdraw.c $(SDL) $(GFX) $(DEBUG) #optional freetype module (do not break in multiple lines #or the configuration script will choke!) diff --git a/buildconfig/stubs/pygame/gfxdraw.pyi b/buildconfig/stubs/pygame/gfxdraw.pyi index d3592e6b7c..1dbb49986f 100644 --- a/buildconfig/stubs/pygame/gfxdraw.pyi +++ b/buildconfig/stubs/pygame/gfxdraw.pyi @@ -2,27 +2,27 @@ from pygame.surface import Surface from ._common import ColorValue, Coordinate, RectValue, Sequence -def pixel(surface: Surface, x: int, y: int, color: ColorValue, /) -> None: ... -def hline(surface: Surface, x1: int, x2: int, y: int, color: ColorValue, /) -> None: ... -def vline(surface: Surface, x: int, y1: int, y2: int, color: ColorValue, /) -> None: ... +def pixel(surface: Surface, x: int, y: int, color: ColorValue) -> None: ... +def hline(surface: Surface, x1: int, x2: int, y: int, color: ColorValue) -> None: ... +def vline(surface: Surface, x: int, y1: int, y2: int, color: ColorValue) -> None: ... def line( - surface: Surface, x1: int, y1: int, x2: int, y2: int, color: ColorValue, / + surface: Surface, x1: int, y1: int, x2: int, y2: int, color: ColorValue ) -> None: ... -def rectangle(surface: Surface, rect: RectValue, color: ColorValue, /) -> None: ... -def box(surface: Surface, rect: RectValue, color: ColorValue, /) -> None: ... -def circle(surface: Surface, x: int, y: int, r: int, color: ColorValue, /) -> None: ... -def aacircle(surface: Surface, x: int, y: int, r: int, color: ColorValue, /) -> None: ... +def rectangle(surface: Surface, rect: RectValue, color: ColorValue) -> None: ... +def box(surface: Surface, rect: RectValue, color: ColorValue) -> None: ... +def circle(surface: Surface, x: int, y: int, r: int, color: ColorValue) -> None: ... +def aacircle(surface: Surface, x: int, y: int, r: int, color: ColorValue) -> None: ... def filled_circle( - surface: Surface, x: int, y: int, r: int, color: ColorValue, / + surface: Surface, x: int, y: int, r: int, color: ColorValue ) -> None: ... def ellipse( - surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / + surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue ) -> None: ... def aaellipse( surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / ) -> None: ... def filled_ellipse( - surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / + surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue ) -> None: ... def arc( surface: Surface, @@ -31,7 +31,7 @@ def arc( r: int, start_angle: int, atp_angle: int, - color: ColorValue, / + color: ColorValue ) -> None: ... def pie( surface: Surface, @@ -50,7 +50,7 @@ def trigon( y2: int, x3: int, y3: int, - color: ColorValue, / + color: ColorValue ) -> None: ... def aatrigon( surface: Surface, @@ -70,16 +70,16 @@ def filled_trigon( y2: int, x3: int, y3: int, - color: ColorValue, / + color: ColorValue ) -> None: ... def polygon( - surface: Surface, points: Sequence[Coordinate], color: ColorValue, / + surface: Surface, points: Sequence[Coordinate], color: ColorValue ) -> None: ... def aapolygon( surface: Surface, points: Sequence[Coordinate], color: ColorValue, / ) -> None: ... def filled_polygon( - surface: Surface, points: Sequence[Coordinate], color: ColorValue, / + surface: Surface, points: Sequence[Coordinate], color: ColorValue ) -> None: ... def textured_polygon( surface: Surface, points: Sequence[Coordinate], texture: Surface, tx: int, ty: int, / diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives.c b/src_c/SDL_gfx/SDL_gfxPrimitives.c index 84cf120187..94d6735f74 100644 --- a/src_c/SDL_gfx/SDL_gfxPrimitives.c +++ b/src_c/SDL_gfx/SDL_gfxPrimitives.c @@ -13,41 +13,12 @@ LGPL (c) A. Schiffler #include "SDL_gfxPrimitives.h" // #include "SDL_rotozoom.h" -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ -#include "SDL_gfxPrimitives_font.h" -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ /* -===================- */ #define DEFAULT_ALPHA_PIXEL_ROUTINE #undef EXPERIMENTAL_ALPHA_PIXEL_ROUTINE -/* ---- Structures */ - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ -/*! -\brief The structure passed to the internal Bresenham iterator. -*/ -typedef struct { - Sint16 x, y; - int dx, dy, s1, s2, swapdir, error; - Uint32 count; -} SDL_gfxBresenhamIterator; - -/*! -\brief The structure passed to the internal Murphy iterator. -*/ -typedef struct { - Uint32 color; - SDL_Surface *dst; - int u, v; /* delta x , delta y */ - int ku, kt, kv, kd; /* loop constants */ - int oct2; - int quad4; - Sint16 last1x, last1y, last2x, last2y, first1x, first1y, first2x, first2y, tempx, tempy; -} SDL_gfxMurphyIterator; -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* ----- Defines for pixel clipping tests */ #define clip_xmin(surface) surface->clip_rect.x @@ -55,205 +26,6 @@ typedef struct { #define clip_ymin(surface) surface->clip_rect.y #define clip_ymax(surface) surface->clip_rect.y + surface->clip_rect.h - 1 -/*! -\brief Internal pixel drawing - fast, no blending, no locking, clipping. - -\param dst The surface to draw on. -\param x The horizontal coordinate of the pixel. -\param y The vertical position of the pixel. -\param color The color value of the pixel to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -fastPixelColorNolock(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color) -{ - int bpp; - Uint8 *p; - - /* - * Honor clipping setup at pixel level - */ - if ((x >= clip_xmin(dst)) && (x <= clip_xmax(dst)) && - (y >= clip_ymin(dst)) && (y <= clip_ymax(dst))) { - /* - * Get destination format - */ - bpp = GFX_SURF_BytesPerPixel(dst); - p = (Uint8 *)dst->pixels + y * dst->pitch + x * bpp; - switch (bpp) { - case 1: - *p = color; - break; - case 2: - *(Uint16 *)p = color; - break; - case 3: - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - p[0] = (color >> 16) & 0xff; - p[1] = (color >> 8) & 0xff; - p[2] = color & 0xff; - } - else { - p[0] = color & 0xff; - p[1] = (color >> 8) & 0xff; - p[2] = (color >> 16) & 0xff; - } - break; - case 4: - *(Uint32 *)p = color; - break; - } /* switch */ - } - - return (0); -} - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ -/*! -\brief Internal pixel drawing - fast, no blending, no locking, no clipping. - -Function is faster but dangerous since no clipping check is done. -Code needs to make sure we stay in surface bounds before calling. - -\param dst The surface to draw on. -\param x The horizontal coordinate of the pixel. -\param y The vertical position of the pixel. -\param color The color value of the pixel to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int fastPixelColorNolockNoclip(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) -{ - int bpp; - Uint8 *p; - - /* - * Get destination format - */ - bpp = GFX_SURF_BytesPerPixel(dst); - p = (Uint8 *) dst->pixels + y * dst->pitch + x * bpp; - switch (bpp) { - case 1: - *p = color; - break; - case 2: - *(Uint16 *) p = color; - break; - case 3: - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - p[0] = (color >> 16) & 0xff; - p[1] = (color >> 8) & 0xff; - p[2] = color & 0xff; - } else { - p[0] = color & 0xff; - p[1] = (color >> 8) & 0xff; - p[2] = (color >> 16) & 0xff; - } - break; - case 4: - *(Uint32 *) p = color; - break; - } /* switch */ - - return (0); -} -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/*! -\brief Internal pixel drawing - fast, no blending, locking, clipping. - -\param dst The surface to draw on. -\param x The horizontal coordinate of the pixel. -\param y The vertical position of the pixel. -\param color The color value of the pixel to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -fastPixelColor(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color) -{ - int result; - - /* - * Lock the surface - */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - - result = fastPixelColorNolock(dst, x, y, color); - - /* - * Unlock surface - */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - return (result); -} - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ -/*! -\brief Internal pixel drawing - fast, no blending, locking, RGB input. - -\param dst The surface to draw on. -\param x The horizontal coordinate of the pixel. -\param y The vertical position of the pixel. -\param r The red value of the pixel to draw. -\param g The green value of the pixel to draw. -\param b The blue value of the pixel to draw. -\param a The alpha value of the pixel to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int fastPixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - Uint32 color; - - /* - * Setup color - */ - color = SDL_MapRGBA(dst->format, r, g, b, a); - - /* - * Draw - */ - return (fastPixelColor(dst, x, y, color)); -} - -/*! -\brief Internal pixel drawing - fast, no blending, no locking RGB input. - -\param dst The surface to draw on. -\param x The horizontal coordinate of the pixel. -\param y The vertical position of the pixel. -\param r The red value of the pixel to draw. -\param g The green value of the pixel to draw. -\param b The blue value of the pixel to draw. -\param a The alpha value of the pixel to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int fastPixelRGBANolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - Uint32 color; - - /* - * Setup color - */ - color = SDL_MapRGBA(dst->format, r, g, b, a); - - /* - * Draw - */ - return (fastPixelColorNolock(dst, x, y, color)); -} -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /*! \brief Internal pixel drawing function with alpha blending where input color in in destination format. @@ -900,36 +672,6 @@ _VLineAlpha(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color) return (filledRectAlpha(dst, x, y1, x, y2, color)); } -/*! -\brief Pixel draw with blending enabled and using alpha weight on color. - -\param dst The surface to draw on. -\param x The horizontal coordinate of the pixel. -\param y The vertical position of the pixel. -\param color The color value of the pixel to draw (0xRRGGBBAA). -\param weight The weight multiplied into the alpha value of the pixel. - -\returns Returns 0 on success, -1 on failure. -*/ -int -pixelColorWeight(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color, - Uint32 weight) -{ - Uint32 a; - - /* - * Get alpha - */ - a = (color & (Uint32)0x000000ff); - - /* - * Modify Alpha by weight - */ - a = ((a * weight) >> 8); - - return (pixelColor(dst, x, y, (color & (Uint32)0xffffff00) | (Uint32)a)); -} - /*! \brief Pixel draw with blending enabled and using alpha weight on color - no locking. @@ -963,78 +705,27 @@ pixelColorWeightNolock(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color, } /*! -\brief Pixel draw with blending enabled if a<255. - -\param dst The surface to draw on. -\param x X (horizontal) coordinate of the pixel. -\param y Y (vertical) coordinate of the pixel. -\param r The red color value of the pixel to draw. -\param g The green color value of the pixel to draw. -\param b The blue color value of the pixel to draw. -\param a The alpha value of the pixel to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -pixelRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, - Uint8 a) -{ - Uint32 color; - - /* - * Check Alpha - */ - if (a == 255) { - /* - * No alpha blending required - */ - /* - * Setup color - */ - color = SDL_MapRGBA(dst->format, r, g, b, a); - /* - * Draw - */ - return (fastPixelColor(dst, x, y, color)); - } - else { - /* - * Alpha blending required - */ - /* - * Draw - */ - return (pixelColor(dst, x, y, - ((Uint32)r << 24) | ((Uint32)g << 16) | - ((Uint32)b << 8) | (Uint32)a)); - } -} - -/*! -\brief Draw horizontal line without blending; - -Just stores the color value (including the alpha component) without blending. -Only the same number of bits of the destination surface are transferred -from the input color value. +\brief Draw horizontal line with blending. \param dst The surface to draw on. \param x1 X coordinate of the first point (i.e. left) of the line. \param x2 X coordinate of the second point (i.e. right) of the line. \param y Y coordinate of the points of the line. -\param color The color value of the line to draw. +\param color The color value of the line to draw (0xRRGGBBAA). \returns Returns 0 on success, -1 on failure. */ int -hlineColorStore(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) +hlineColor(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) { Sint16 left, right, top, bottom; Uint8 *pixel, *pixellast; int dx; int pixx, pixy; - Sint16 w; Sint16 xtmp; int result = -1; + Uint8 *colorptr; + Uint8 color3[3]; /* * Check visibility of clipping rectangle @@ -1081,241 +772,71 @@ hlineColorStore(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) } /* - * Calculate width + * Calculate width difference */ - w = x2 - x1; + dx = x2 - x1; /* - * Lock the surface + * Alpha check */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } + if ((color & 255) == 255) { + /* + * No alpha-blending required + */ - /* - * More variable setup - */ - dx = w; - pixx = GFX_SURF_BytesPerPixel(dst); - pixy = dst->pitch; - pixel = ((Uint8 *)dst->pixels) + pixx * (int)x1 + pixy * (int)y; + /* + * Setup color + */ + colorptr = (Uint8 *)&color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], + colorptr[2], colorptr[3]); + } + else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], + colorptr[1], colorptr[0]); + } - /* - * Draw - */ - switch (GFX_SURF_BytesPerPixel(dst)) { - case 1: - memset(pixel, color, dx + 1); - break; - case 2: - pixellast = pixel + dx + dx; - for (; pixel <= pixellast; pixel += pixx) { - *(Uint16 *)pixel = color; + /* + * Lock the surface + */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); } - break; - case 3: - pixellast = pixel + dx + dx + dx; - for (; pixel <= pixellast; pixel += pixx) { + } + + /* + * More variable setup + */ + pixx = GFX_SURF_BytesPerPixel(dst); + pixy = dst->pitch; + pixel = ((Uint8 *)dst->pixels) + pixx * (int)x1 + pixy * (int)y; + + /* + * Draw + */ + switch (GFX_SURF_BytesPerPixel(dst)) { + case 1: + memset(pixel, color, dx + 1); + break; + case 2: + pixellast = pixel + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + *(Uint16 *)pixel = color; + } + break; + case 3: + pixellast = pixel + dx + dx + dx; if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - pixel[0] = (color >> 16) & 0xff; - pixel[1] = (color >> 8) & 0xff; - pixel[2] = color & 0xff; + color3[0] = (color >> 16) & 0xff; + color3[1] = (color >> 8) & 0xff; + color3[2] = color & 0xff; } else { - pixel[0] = color & 0xff; - pixel[1] = (color >> 8) & 0xff; - pixel[2] = (color >> 16) & 0xff; - } - } - break; - default: /* case 4 */ - dx = dx + dx; - pixellast = pixel + dx + dx; - for (; pixel <= pixellast; pixel += pixx) { - *(Uint32 *)pixel = color; - } - break; - } - - /* - * Unlock surface - */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - /* - * Set result code - */ - result = 0; - - return (result); -} - -/*! -\brief Draw horizontal line without blending - -Just stores the color value (including the alpha component) without blending. -Function should only be used for 32 bit target surfaces. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. left) of the line. -\param x2 X coordinate of the second point (i.e. right) of the line. -\param y Y coordinate of the points of the line. -\param r The red value of the line to draw. -\param g The green value of the line to draw. -\param b The blue value of the line to draw. -\param a The alpha value of the line to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -hlineRGBAStore(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (hlineColorStore( - dst, x1, x2, y, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -/*! -\brief Draw horizontal line with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. left) of the line. -\param x2 X coordinate of the second point (i.e. right) of the line. -\param y Y coordinate of the points of the line. -\param color The color value of the line to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -hlineColor(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) -{ - Sint16 left, right, top, bottom; - Uint8 *pixel, *pixellast; - int dx; - int pixx, pixy; - Sint16 xtmp; - int result = -1; - Uint8 *colorptr; - Uint8 color3[3]; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Swap x1, x2 if required to ensure x1<=x2 - */ - if (x1 > x2) { - xtmp = x1; - x1 = x2; - x2 = xtmp; - } - - /* - * Get clipping boundary and - * check visibility of hline - */ - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - top = dst->clip_rect.y; - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if ((y < top) || (y > bottom)) { - return (0); - } - - /* - * Clip x - */ - if (x1 < left) { - x1 = left; - } - if (x2 > right) { - x2 = right; - } - - /* - * Calculate width difference - */ - dx = x2 - x1; - - /* - * Alpha check - */ - if ((color & 255) == 255) { - /* - * No alpha-blending required - */ - - /* - * Setup color - */ - colorptr = (Uint8 *)&color; - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], - colorptr[2], colorptr[3]); - } - else { - color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], - colorptr[1], colorptr[0]); - } - - /* - * Lock the surface - */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - - /* - * More variable setup - */ - pixx = GFX_SURF_BytesPerPixel(dst); - pixy = dst->pitch; - pixel = ((Uint8 *)dst->pixels) + pixx * (int)x1 + pixy * (int)y; - - /* - * Draw - */ - switch (GFX_SURF_BytesPerPixel(dst)) { - case 1: - memset(pixel, color, dx + 1); - break; - case 2: - pixellast = pixel + dx + dx; - for (; pixel <= pixellast; pixel += pixx) { - *(Uint16 *)pixel = color; - } - break; - case 3: - pixellast = pixel + dx + dx + dx; - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - color3[0] = (color >> 16) & 0xff; - color3[1] = (color >> 8) & 0xff; - color3[2] = color & 0xff; - } - else { - color3[0] = color & 0xff; - color3[1] = (color >> 8) & 0xff; - color3[2] = (color >> 16) & 0xff; + color3[0] = color & 0xff; + color3[1] = (color >> 8) & 0xff; + color3[2] = (color >> 16) & 0xff; } for (; pixel <= pixellast; pixel += pixx) { memcpy(pixel, color3, 3); @@ -1352,32 +873,6 @@ hlineColor(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) return (result); } -/*! -\brief Draw horizontal line with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. left) of the line. -\param x2 X coordinate of the second point (i.e. right) of the line. -\param y Y coordinate of the points of the line. -\param r The red value of the line to draw. -\param g The green value of the line to draw. -\param b The blue value of the line to draw. -\param a The alpha value of the line to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -hlineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, - Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (hlineColor( - dst, x1, x2, y, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - /*! \brief Draw vertical line with blending. @@ -1545,499 +1040,54 @@ vlineColor(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color) return (result); } -/*! -\brief Draw vertical line with blending. +/* --------- Clipping routines for line */ -\param dst The surface to draw on. -\param x X coordinate of the points of the line. -\param y1 Y coordinate of the first point (i.e. top) of the line. -\param y2 Y coordinate of the second point (i.e. bottom) of the line. -\param r The red value of the line to draw. -\param g The green value of the line to draw. -\param b The blue value of the line to draw. -\param a The alpha value of the line to draw. +/* Clipping based heavily on code from */ +/* http://www.ncsa.uiuc.edu/Vis/Graphics/src/clipCohSuth.c */ -\returns Returns 0 on success, -1 on failure. -*/ -int -vlineRGBA(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, - Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (vlineColor( - dst, x, y1, y2, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} +#define CLIP_LEFT_EDGE 0x1 +#define CLIP_RIGHT_EDGE 0x2 +#define CLIP_BOTTOM_EDGE 0x4 +#define CLIP_TOP_EDGE 0x8 +#define CLIP_INSIDE(a) (!a) +#define CLIP_REJECT(a, b) (a & b) +#define CLIP_ACCEPT(a, b) (!(a | b)) /*! -\brief Draw rectangle with blending. +\brief Internal clip-encoding routine. -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the rectangle. -\param y1 Y coordinate of the first point (i.e. top right) of the rectangle. -\param x2 X coordinate of the second point (i.e. bottom left) of the rectangle. -\param y2 Y coordinate of the second point (i.e. bottom left) of the rectangle. -\param color The color value of the rectangle to draw (0xRRGGBBAA). +Calculates a segment-based clipping encoding for a point against a rectangle. -\returns Returns 0 on success, -1 on failure. +\param x X coordinate of point. +\param y Y coordinate of point. +\param left X coordinate of left edge of the rectangle. +\param top Y coordinate of top edge of the rectangle. +\param right X coordinate of right edge of the rectangle. +\param bottom Y coordinate of bottom edge of the rectangle. */ -int -rectangleColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint32 color) +static int +_clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, + Sint16 bottom) { - int result; - Sint16 tmp; + int code = 0; - /* Check destination surface */ - if (dst == NULL) { - return -1; + if (x < left) { + code |= CLIP_LEFT_EDGE; } - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return 0; + else if (x > right) { + code |= CLIP_RIGHT_EDGE; } - - /* - * Test for special cases of straight lines or single point - */ - if (x1 == x2) { - if (y1 == y2) { - return (pixelColor(dst, x1, y1, color)); - } - else { - return (vlineColor(dst, x1, y1, y2, color)); - } + if (y < top) { + code |= CLIP_TOP_EDGE; } - else { - if (y1 == y2) { - return (hlineColor(dst, x1, x2, y1, color)); - } + else if (y > bottom) { + code |= CLIP_BOTTOM_EDGE; } + return code; +} - /* - * Swap x1, x2 if required - */ - if (x1 > x2) { - tmp = x1; - x1 = x2; - x2 = tmp; - } - - /* - * Swap y1, y2 if required - */ - if (y1 > y2) { - tmp = y1; - y1 = y2; - y2 = tmp; - } - - /* - * Draw rectangle - */ - result = 0; - result |= hlineColor(dst, x1, x2, y1, color); - result |= hlineColor(dst, x1, x2, y2, color); - y1 += 1; - y2 -= 1; - if (y1 <= y2) { - result |= vlineColor(dst, x1, y1, y2, color); - result |= vlineColor(dst, x2, y1, y2, color); - } - - return (result); -} - -/*! -\brief Draw rectangle with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the rectangle. -\param y1 Y coordinate of the first point (i.e. top right) of the rectangle. -\param x2 X coordinate of the second point (i.e. bottom left) of the rectangle. -\param y2 Y coordinate of the second point (i.e. bottom left) of the rectangle. -\param r The red value of the rectangle to draw. -\param g The green value of the rectangle to draw. -\param b The blue value of the rectangle to draw. -\param a The alpha value of the rectangle to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -rectangleRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (rectangleColor( - dst, x1, y1, x2, y2, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ -/*! -\brief Draw rounded-corner rectangle with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the rectangle. -\param y1 Y coordinate of the first point (i.e. top right) of the rectangle. -\param x2 X coordinate of the second point (i.e. bottom left) of the rectangle. -\param y2 Y coordinate of the second point (i.e. bottom left) of the rectangle. -\param rad The radius of the corner arc. -\param color The color value of the rectangle to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int roundedRectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color) -{ - int result; - Sint16 w, h, tmp; - Sint16 xx1, xx2, yy1, yy2; - - /* - * Check destination surface - */ - if (dst == NULL) - { - return -1; - } - - /* - * Check radius vor valid range - */ - if (rad < 0) { - return -1; - } - - /* - * Special case - no rounding - */ - if (rad == 0) { - return rectangleColor(dst, x1, y1, x2, y2, color); - } - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) { - return 0; - } - - /* - * Test for special cases of straight lines or single point - */ - if (x1 == x2) { - if (y1 == y2) { - return (pixelColor(dst, x1, y1, color)); - } else { - return (vlineColor(dst, x1, y1, y2, color)); - } - } else { - if (y1 == y2) { - return (hlineColor(dst, x1, x2, y1, color)); - } - } - - /* - * Swap x1, x2 if required - */ - if (x1 > x2) { - tmp = x1; - x1 = x2; - x2 = tmp; - } - - /* - * Swap y1, y2 if required - */ - if (y1 > y2) { - tmp = y1; - y1 = y2; - y2 = tmp; - } - - /* - * Calculate width&height - */ - w = x2 - x1; - h = y2 - y1; - - /* - * Maybe adjust radius - */ - if ((rad * 2) > w) - { - rad = w / 2; - } - if ((rad * 2) > h) - { - rad = h / 2; - } - - /* - * Draw corners - */ - result = 0; - xx1 = x1 + rad; - xx2 = x2 - rad; - yy1 = y1 + rad; - yy2 = y2 - rad; - result |= arcColor(dst, xx1, yy1, rad, 180, 270, color); - result |= arcColor(dst, xx2, yy1, rad, 270, 360, color); - result |= arcColor(dst, xx1, yy2, rad, 90, 180, color); - result |= arcColor(dst, xx2, yy2, rad, 0, 90, color); - - /* - * Draw lines - */ - if (xx1 <= xx2) { - result |= hlineColor(dst, xx1, xx2, y1, color); - result |= hlineColor(dst, xx1, xx2, y2, color); - } - if (yy1 <= yy2) { - result |= vlineColor(dst, x1, yy1, yy2, color); - result |= vlineColor(dst, x2, yy1, yy2, color); - } - - return result; -} - -/*! -\brief Draw rounded-corner rectangle with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the rectangle. -\param y1 Y coordinate of the first point (i.e. top right) of the rectangle. -\param x2 X coordinate of the second point (i.e. bottom left) of the rectangle. -\param y2 Y coordinate of the second point (i.e. bottom left) of the rectangle. -\param rad The radius of the corner arc. -\param r The red value of the rectangle to draw. -\param g The green value of the rectangle to draw. -\param b The blue value of the rectangle to draw. -\param a The alpha value of the rectangle to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int roundedRectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (roundedRectangleColor - (dst, x1, y1, x2, y2, rad, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); -} - -/*! -\brief Draw rounded-corner box (filled rectangle) with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the box. -\param y1 Y coordinate of the first point (i.e. top right) of the box. -\param x2 X coordinate of the second point (i.e. bottom left) of the box. -\param y2 Y coordinate of the second point (i.e. bottom left) of the box. -\param rad The radius of the corner arcs of the box. -\param color The color value of the box to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int roundedBoxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color) -{ - int result; - Sint16 w, h, tmp; - Sint16 xx1, xx2, yy1, yy2; - - /* - * Check destination surface - */ - if (dst == NULL) - { - return -1; - } - - /* - * Check radius vor valid range - */ - if (rad < 0) { - return -1; - } - - /* - * Special case - no rounding - */ - if (rad == 0) { - return rectangleColor(dst, x1, y1, x2, y2, color); - } - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) { - return 0; - } - - /* - * Test for special cases of straight lines or single point - */ - if (x1 == x2) { - if (y1 == y2) { - return (pixelColor(dst, x1, y1, color)); - } else { - return (vlineColor(dst, x1, y1, y2, color)); - } - } else { - if (y1 == y2) { - return (hlineColor(dst, x1, x2, y1, color)); - } - } - - /* - * Swap x1, x2 if required - */ - if (x1 > x2) { - tmp = x1; - x1 = x2; - x2 = tmp; - } - - /* - * Swap y1, y2 if required - */ - if (y1 > y2) { - tmp = y1; - y1 = y2; - y2 = tmp; - } - - /* - * Calculate width&height - */ - w = x2 - x1; - h = y2 - y1; - - /* - * Maybe adjust radius - */ - if ((rad * 2) > w) - { - rad = w / 2; - } - if ((rad * 2) > h) - { - rad = h / 2; - } - - /* - * Draw corners - */ - result = 0; - xx1 = x1 + rad; - xx2 = x2 - rad; - yy1 = y1 + rad; - yy2 = y2 - rad; - result |= filledPieColor(dst, xx1, yy1, rad, 180, 270, color); - result |= filledPieColor(dst, xx2, yy1, rad, 270, 360, color); - result |= filledPieColor(dst, xx1, yy2, rad, 90, 180, color); - result |= filledPieColor(dst, xx2, yy2, rad, 0, 90, color); - - /* - * Draw body - */ - xx1++; - xx2--; - yy1++; - yy2--; - if (xx1 <= xx2) { - result |= boxColor(dst, xx1, y1, xx2, y2, color); - } - if (yy1 <= yy2) { - result |= boxColor(dst, x1, yy1, xx1-1, yy2, color); - result |= boxColor(dst, xx2+1, yy1, x2, yy2, color); - } - - return result; -} - -/*! -\brief Draw rounded-corner box (filled rectangle) with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the box. -\param y1 Y coordinate of the first point (i.e. top right) of the box. -\param x2 X coordinate of the second point (i.e. bottom left) of the box. -\param y2 Y coordinate of the second point (i.e. bottom left) of the box. -\param rad The radius of the corner arcs of the box. -\param r The red value of the box to draw. -\param g The green value of the box to draw. -\param b The blue value of the box to draw. -\param a The alpha value of the box to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int roundedBoxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, - Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (roundedBoxColor - (dst, x1, y1, x2, y2, rad, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); -} -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/* --------- Clipping routines for line */ - -/* Clipping based heavily on code from */ -/* http://www.ncsa.uiuc.edu/Vis/Graphics/src/clipCohSuth.c */ - -#define CLIP_LEFT_EDGE 0x1 -#define CLIP_RIGHT_EDGE 0x2 -#define CLIP_BOTTOM_EDGE 0x4 -#define CLIP_TOP_EDGE 0x8 -#define CLIP_INSIDE(a) (!a) -#define CLIP_REJECT(a, b) (a & b) -#define CLIP_ACCEPT(a, b) (!(a | b)) - -/*! -\brief Internal clip-encoding routine. - -Calculates a segment-based clipping encoding for a point against a rectangle. - -\param x X coordinate of point. -\param y Y coordinate of point. -\param left X coordinate of left edge of the rectangle. -\param top Y coordinate of top edge of the rectangle. -\param right X coordinate of right edge of the rectangle. -\param bottom Y coordinate of bottom edge of the rectangle. -*/ -static int -_clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, - Sint16 bottom) -{ - int code = 0; - - if (x < left) { - code |= CLIP_LEFT_EDGE; - } - else if (x > right) { - code |= CLIP_RIGHT_EDGE; - } - if (y < top) { - code |= CLIP_TOP_EDGE; - } - else if (y > bottom) { - code |= CLIP_BOTTOM_EDGE; - } - return code; -} - -/*! -\brief Clip line to a the clipping rectangle of a surface. +/*! +\brief Clip line to a the clipping rectangle of a surface. \param dst Target surface to draw on. \param x1 Pointer to X coordinate of first point of line. @@ -2115,127 +1165,90 @@ _clipLine(SDL_Surface *dst, Sint16 *x1, Sint16 *y1, Sint16 *x2, Sint16 *y2) return draw; } +/* ----- Line */ + +/* Non-alpha line drawing code adapted from routine */ +/* by Pete Shinners, pete@shinners.org */ +/* Originally from pygame, http://pygame.seul.org */ + +#define ABS(a) (((a) < 0) ? -(a) : (a)) + /*! -\brief Draw box (filled rectangle) with blending. +\brief Draw line with alpha blending. \param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the box. -\param y1 Y coordinate of the first point (i.e. top right) of the box. -\param x2 X coordinate of the second point (i.e. bottom left) of the box. -\param y2 Y coordinate of the second point (i.e. bottom left) of the box. -\param color The color value of the box to draw (0xRRGGBBAA). +\param x1 X coordinate of the first point of the line. +\param y1 Y coordinate of the first point of the line. +\param x2 X coordinate of the second point of the line. +\param y2 Y coordinate of the second point of the line. +\param color The color value of the line to draw (0xRRGGBBAA). \returns Returns 0 on success, -1 on failure. */ int -boxColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint32 color) +lineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, + Uint32 color) { - Sint16 left, right, top, bottom; - Uint8 *pixel, *pixellast; - int x, dx; - int dy; int pixx, pixy; - Sint16 w, h, tmp; - int result; + int x, y; + int dx, dy; + int ax, ay; + int sx, sy; + int swaptmp; + Uint8 *pixel; Uint8 *colorptr; /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Order coordinates to ensure that - * x1<=x2 and y1<=y2 - */ - if (x1 > x2) { - tmp = x1; - x1 = x2; - x2 = tmp; - } - if (y1 > y2) { - tmp = y1; - y1 = y2; - y2 = tmp; - } - - /* - * Get clipping boundary and - * check visibility + * Clip line and test if we have to draw */ - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - top = dst->clip_rect.y; - if (y2 < top) { - return (0); - } - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if (y1 > bottom) { + if (!(_clipLine(dst, &x1, &y1, &x2, &y2))) { return (0); } - /* Clip all points */ - if (x1 < left) { - x1 = left; - } - else if (x1 > right) { - x1 = right; - } - if (x2 < left) { - x2 = left; - } - else if (x2 > right) { - x2 = right; - } - if (y1 < top) { - y1 = top; - } - else if (y1 > bottom) { - y1 = bottom; - } - if (y2 < top) { - y2 = top; - } - else if (y2 > bottom) { - y2 = bottom; - } - /* - * Test for special cases of straight line or single point + * Test for special cases of straight lines or single point */ if (x1 == x2) { - if (y1 == y2) { - return (pixelColor(dst, x1, y1, color)); + if (y1 < y2) { + return (vlineColor(dst, x1, y1, y2, color)); + } + else if (y1 > y2) { + return (vlineColor(dst, x1, y2, y1, color)); } else { - return (vlineColor(dst, x1, y1, y2, color)); + return (pixelColor(dst, x1, y1, color)); } } if (y1 == y2) { - return (hlineColor(dst, x1, x2, y1, color)); + if (x1 < x2) { + return (hlineColor(dst, x1, x2, y1, color)); + } + else if (x1 > x2) { + return (hlineColor(dst, x2, x1, y1, color)); + } } /* - * Calculate width&height + * Variable setup */ - w = x2 - x1; - h = y2 - y1; + dx = x2 - x1; + dy = y2 - y1; + sx = (dx >= 0) ? 1 : -1; + sy = (dy >= 0) ? 1 : -1; + + /* Lock surface */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } /* - * Alpha check + * Check for alpha blending */ if ((color & 255) == 255) { /* - * No alpha-blending required + * No alpha blending - use fast pixel routines */ /* @@ -2251,246 +1264,39 @@ boxColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, colorptr[1], colorptr[0]); } - /* - * Lock the surface - */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - /* * More variable setup */ - dx = w; - dy = h; + dx = sx * dx + 1; + dy = sy * dy + 1; pixx = GFX_SURF_BytesPerPixel(dst); pixy = dst->pitch; pixel = ((Uint8 *)dst->pixels) + pixx * (int)x1 + pixy * (int)y1; - pixellast = pixel + pixx * dx + pixy * dy; - dx++; + pixx *= sx; + pixy *= sy; + if (dx < dy) { + swaptmp = dx; + dx = dy; + dy = swaptmp; + swaptmp = pixx; + pixx = pixy; + pixy = swaptmp; + } /* * Draw */ + x = 0; + y = 0; switch (GFX_SURF_BytesPerPixel(dst)) { case 1: - for (; pixel <= pixellast; pixel += pixy) { - memset(pixel, (Uint8)color, dx); - } - break; - case 2: - pixy -= (pixx * dx); - for (; pixel <= pixellast; pixel += pixy) { - for (x = 0; x < dx; x++) { - *(Uint16 *)pixel = color; - pixel += pixx; - } - } - break; - case 3: - pixy -= (pixx * dx); - for (; pixel <= pixellast; pixel += pixy) { - for (x = 0; x < dx; x++) { - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - pixel[0] = (color >> 16) & 0xff; - pixel[1] = (color >> 8) & 0xff; - pixel[2] = color & 0xff; - } - else { - pixel[0] = color & 0xff; - pixel[1] = (color >> 8) & 0xff; - pixel[2] = (color >> 16) & 0xff; - } - pixel += pixx; - } - } - break; - default: /* case 4 */ - pixy -= (pixx * dx); - for (; pixel <= pixellast; pixel += pixy) { - for (x = 0; x < dx; x++) { - *(Uint32 *)pixel = color; - pixel += pixx; - } - } - break; - } - - /* Unlock surface */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - result = 0; - } - else { - result = filledRectAlpha(dst, x1, y1, x1 + w, y1 + h, color); - } - - return (result); -} - -/*! -\brief Draw box (filled rectangle) with blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point (i.e. top right) of the box. -\param y1 Y coordinate of the first point (i.e. top right) of the box. -\param x2 X coordinate of the second point (i.e. bottom left) of the box. -\param y2 Y coordinate of the second point (i.e. bottom left) of the box. -\param r The red value of the box to draw. -\param g The green value of the box to draw. -\param b The blue value of the box to draw. -\param a The alpha value of the box to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -boxRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (boxColor( - dst, x1, y1, x2, y2, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -/* ----- Line */ - -/* Non-alpha line drawing code adapted from routine */ -/* by Pete Shinners, pete@shinners.org */ -/* Originally from pygame, http://pygame.seul.org */ - -#define ABS(a) (((a) < 0) ? -(a) : (a)) - -/*! -\brief Draw line with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the line. -\param y1 Y coordinate of the first point of the line. -\param x2 X coordinate of the second point of the line. -\param y2 Y coordinate of the second point of the line. -\param color The color value of the line to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -lineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint32 color) -{ - int pixx, pixy; - int x, y; - int dx, dy; - int ax, ay; - int sx, sy; - int swaptmp; - Uint8 *pixel; - Uint8 *colorptr; - - /* - * Clip line and test if we have to draw - */ - if (!(_clipLine(dst, &x1, &y1, &x2, &y2))) { - return (0); - } - - /* - * Test for special cases of straight lines or single point - */ - if (x1 == x2) { - if (y1 < y2) { - return (vlineColor(dst, x1, y1, y2, color)); - } - else if (y1 > y2) { - return (vlineColor(dst, x1, y2, y1, color)); - } - else { - return (pixelColor(dst, x1, y1, color)); - } - } - if (y1 == y2) { - if (x1 < x2) { - return (hlineColor(dst, x1, x2, y1, color)); - } - else if (x1 > x2) { - return (hlineColor(dst, x2, x1, y1, color)); - } - } - - /* - * Variable setup - */ - dx = x2 - x1; - dy = y2 - y1; - sx = (dx >= 0) ? 1 : -1; - sy = (dy >= 0) ? 1 : -1; - - /* Lock surface */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - - /* - * Check for alpha blending - */ - if ((color & 255) == 255) { - /* - * No alpha blending - use fast pixel routines - */ - - /* - * Setup color - */ - colorptr = (Uint8 *)&color; - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], - colorptr[2], colorptr[3]); - } - else { - color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], - colorptr[1], colorptr[0]); - } - - /* - * More variable setup - */ - dx = sx * dx + 1; - dy = sy * dy + 1; - pixx = GFX_SURF_BytesPerPixel(dst); - pixy = dst->pitch; - pixel = ((Uint8 *)dst->pixels) + pixx * (int)x1 + pixy * (int)y1; - pixx *= sx; - pixy *= sy; - if (dx < dy) { - swaptmp = dx; - dx = dy; - dy = swaptmp; - swaptmp = pixx; - pixx = pixy; - pixy = swaptmp; - } - - /* - * Draw - */ - x = 0; - y = 0; - switch (GFX_SURF_BytesPerPixel(dst)) { - case 1: - for (; x < dx; x++, pixel += pixx) { - *pixel = color; - y += dy; - if (y >= dx) { - y -= dx; - pixel += pixy; - } + for (; x < dx; x++, pixel += pixx) { + *pixel = color; + y += dy; + if (y >= dx) { + y -= dx; + pixel += pixy; + } } break; case 2: @@ -2580,33 +1386,6 @@ lineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, return (0); } -/*! -\brief Draw line with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the line. -\param y1 Y coordinate of the first point of the line. -\param x2 X coordinate of the second point of the line. -\param y2 Y coordinate of the second point of the line. -\param r The red value of the line to draw. -\param g The green value of the line to draw. -\param b The blue value of the line to draw. -\param a The alpha value of the line to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -lineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (lineColor( - dst, x1, y1, x2, y2, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - /* AA Line */ #define AAlevels 256 @@ -2858,1340 +1637,11 @@ _aalineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, } /* Unlock surface */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - return (result); -} - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ -/*! -\brief Ddraw anti-aliased line with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the aa-line. -\param y1 Y coordinate of the first point of the aa-line. -\param x2 X coordinate of the second point of the aa-line. -\param y2 Y coordinate of the second point of the aa-line. -\param color The color value of the aa-line to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) -{ - return (_aalineColor(dst, x1, y1, x2, y2, color, 1)); -} - -/*! -\brief Draw anti-aliased line with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the aa-line. -\param y1 Y coordinate of the first point of the aa-line. -\param x2 X coordinate of the second point of the aa-line. -\param y2 Y coordinate of the second point of the aa-line. -\param r The red value of the aa-line to draw. -\param g The green value of the aa-line to draw. -\param b The blue value of the aa-line to draw. -\param a The alpha value of the aa-line to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - return (_aalineColor - (dst, x1, y1, x2, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a, 1)); -} -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/* ----- Circle */ - -/*! -\brief Draw circle with blending. - -Note: Circle drawing routine is based on an algorithms from the sge library, -but modified by A. Schiffler for multiple pixel-draw removal and other -minor speedup changes. - -\param dst The surface to draw on. -\param x X coordinate of the center of the circle. -\param y Y coordinate of the center of the circle. -\param rad Radius in pixels of the circle. -\param color The color value of the circle to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -circleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color) -{ - Sint16 left, right, top, bottom; - int result; - Sint16 x1, y1, x2, y2; - Sint16 cx = 0; - Sint16 cy = rad; - Sint16 df = 1 - rad; - Sint16 d_e = 3; - Sint16 d_se = -2 * rad + 5; - Sint16 xpcx, xmcx, xpcy, xmcy; - Sint16 ypcy, ymcy, ypcx, ymcx; - Uint8 *colorptr; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Sanity check radius - */ - if (rad < 0) { - return (-1); - } - - /* - * Special case for rad=0 - draw a point - */ - if (rad == 0) { - return (pixelColor(dst, x, y, color)); - } - - /* - * Get circle and clipping boundary and - * test if bounding box of circle is visible - */ - x2 = x + rad; - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - x1 = x - rad; - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - y2 = y + rad; - top = dst->clip_rect.y; - if (y2 < top) { - return (0); - } - y1 = y - rad; - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if (y1 > bottom) { - return (0); - } - - /* - * Draw circle - */ - result = 0; - - /* Lock surface */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - - /* - * Alpha Check - */ - if ((color & 255) == 255) { - /* - * No Alpha - direct memory writes - */ - - /* - * Setup color - */ - colorptr = (Uint8 *)&color; - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], - colorptr[2], colorptr[3]); - } - else { - color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], - colorptr[1], colorptr[0]); - } - - /* - * Draw - */ - do { - ypcy = y + cy; - ymcy = y - cy; - if (cx > 0) { - xpcx = x + cx; - xmcx = x - cx; - result |= fastPixelColorNolock(dst, xmcx, ypcy, color); - result |= fastPixelColorNolock(dst, xpcx, ypcy, color); - result |= fastPixelColorNolock(dst, xmcx, ymcy, color); - result |= fastPixelColorNolock(dst, xpcx, ymcy, color); - } - else { - result |= fastPixelColorNolock(dst, x, ymcy, color); - result |= fastPixelColorNolock(dst, x, ypcy, color); - } - xpcy = x + cy; - xmcy = x - cy; - if ((cx > 0) && (cx != cy)) { - ypcx = y + cx; - ymcx = y - cx; - result |= fastPixelColorNolock(dst, xmcy, ypcx, color); - result |= fastPixelColorNolock(dst, xpcy, ypcx, color); - result |= fastPixelColorNolock(dst, xmcy, ymcx, color); - result |= fastPixelColorNolock(dst, xpcy, ymcx, color); - } - else if (cx == 0) { - result |= fastPixelColorNolock(dst, xmcy, y, color); - result |= fastPixelColorNolock(dst, xpcy, y, color); - } - /* - * Update - */ - if (df < 0) { - df += d_e; - d_e += 2; - d_se += 2; - } - else { - df += d_se; - d_e += 2; - d_se += 4; - cy--; - } - cx++; - } while (cx <= cy); - - /* - * Unlock surface - */ - SDL_UnlockSurface(dst); - } - else { - /* - * Using Alpha - blended pixel blits - */ - - do { - /* - * Draw - */ - ypcy = y + cy; - ymcy = y - cy; - if (cx > 0) { - xpcx = x + cx; - xmcx = x - cx; - result |= pixelColorNolock(dst, xmcx, ypcy, color); - result |= pixelColorNolock(dst, xpcx, ypcy, color); - result |= pixelColorNolock(dst, xmcx, ymcy, color); - result |= pixelColorNolock(dst, xpcx, ymcy, color); - } - else { - result |= pixelColorNolock(dst, x, ymcy, color); - result |= pixelColorNolock(dst, x, ypcy, color); - } - xpcy = x + cy; - xmcy = x - cy; - if ((cx > 0) && (cx != cy)) { - ypcx = y + cx; - ymcx = y - cx; - result |= pixelColorNolock(dst, xmcy, ypcx, color); - result |= pixelColorNolock(dst, xpcy, ypcx, color); - result |= pixelColorNolock(dst, xmcy, ymcx, color); - result |= pixelColorNolock(dst, xpcy, ymcx, color); - } - else if (cx == 0) { - result |= pixelColorNolock(dst, xmcy, y, color); - result |= pixelColorNolock(dst, xpcy, y, color); - } - /* - * Update - */ - if (df < 0) { - df += d_e; - d_e += 2; - d_se += 2; - } - else { - df += d_se; - d_e += 2; - d_se += 4; - cy--; - } - cx++; - } while (cx <= cy); - - } /* Alpha check */ - - /* Unlock surface */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - return (result); -} - -/*! -\brief Draw circle with blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the circle. -\param y Y coordinate of the center of the circle. -\param rad Radius in pixels of the circle. -\param r The red value of the circle to draw. -\param g The green value of the circle to draw. -\param b The blue value of the circle to draw. -\param a The alpha value of the circle to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -circleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, - Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (circleColor( - dst, x, y, rad, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -/* ----- Arc */ - -/*! -\brief Arc with blending. - -Note Arc drawing is based on circle algorithm by A. Schiffler and -written by D. Raber. Calculates which octants arc goes through and -renders pixels accordingly. - -\param dst The surface to draw on. -\param x X coordinate of the center of the arc. -\param y Y coordinate of the center of the arc. -\param rad Radius in pixels of the arc. -\param start Starting radius in degrees of the arc. 0 degrees is down, -increasing counterclockwise. \param end Ending radius in degrees of the arc. 0 -degrees is down, increasing counterclockwise. \param color The color value of -the arc to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint32 color) -{ - Sint16 left, right, top, bottom; - int result; - Sint16 x1, y1, x2, y2; - Sint16 cx = 0; - Sint16 cy = rad; - Sint16 df = 1 - rad; - Sint16 d_e = 3; - Sint16 d_se = -2 * rad + 5; - Sint16 xpcx, xmcx, xpcy, xmcy; - Sint16 ypcy, ymcy, ypcx, ymcx; - Uint8 *colorptr; - Uint8 drawoct; - int startoct, endoct, oct, stopval_start = 0, stopval_end = 0; - double dstart, dend, temp = 0.; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Sanity check radius - */ - if (rad < 0) { - return (-1); - } - - /* - * Special case for rad=0 - draw a point - */ - if (rad == 0) { - return (pixelColor(dst, x, y, color)); - } - - /* - * Get arc's circle and clipping boundary and - * test if bounding box of circle is visible - */ - x2 = x + rad; - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - x1 = x - rad; - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - y2 = y + rad; - top = dst->clip_rect.y; - if (y2 < top) { - return (0); - } - y1 = y - rad; - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if (y1 > bottom) { - return (0); - } - - // Octant labelling - // - // \ 5 | 6 / - // \ | / - // 4 \ | / 7 - // \|/ - //------+------ +x - // /|\ - // 3 / | \ 0 - // / | \ - // / 2 | 1 \ - // +y - - // Initially reset bitmask to 0x00000000 - // the set whether or not to keep drawing a given octant. - // For example: 0x00111100 means we're drawing in octants 2-5 - drawoct = 0; - - /* - * Fixup angles - */ - start %= 360; - end %= 360; - // 0 <= start & end < 360; note that sometimes start > end - if so, arc - // goes back through 0. - while (start < 0) - start += 360; - while (end < 0) - end += 360; - start %= 360; - end %= 360; - - // now, we find which octants we're drawing in. - startoct = start / 45; - endoct = end / 45; - oct = startoct - 1; // we increment as first step in loop - - // stopval_start, stopval_end; - // what values of cx to stop at. - do { - oct = (oct + 1) % 8; - - if (oct == startoct) { - // need to compute stopval_start for this octant. Look at picture - // above if this is unclear - dstart = (double)start; - switch (oct) { - case 0: - case 3: - temp = sin(dstart * M_PI / 180.); - break; - case 1: - case 6: - temp = cos(dstart * M_PI / 180.); - break; - case 2: - case 5: - temp = -cos(dstart * M_PI / 180.); - break; - case 4: - case 7: - temp = -sin(dstart * M_PI / 180.); - break; - } - temp *= rad; - stopval_start = (int)temp; // always round down. - // This isn't arbitrary, but requires graph paper to explain well. - // The basic idea is that we're always changing drawoct after we - // draw, so we stop immediately after we render the last sensible - // pixel at x = ((int)temp). - - // and whether to draw in this octant initially - if (oct % 2) - drawoct |= - (1 << oct); // this is basically like saying drawoct[oct] - // = true, if drawoct were a bool array - else - drawoct &= 255 - (1 << oct); // this is basically like saying - // drawoct[oct] = false - } - if (oct == endoct) { - // need to compute stopval_end for this octant - dend = (double)end; - switch (oct) { - case 0: - case 3: - temp = sin(dend * M_PI / 180); - break; - case 1: - case 6: - temp = cos(dend * M_PI / 180); - break; - case 2: - case 5: - temp = -cos(dend * M_PI / 180); - break; - case 4: - case 7: - temp = -sin(dend * M_PI / 180); - break; - } - temp *= rad; - stopval_end = (int)temp; - - // and whether to draw in this octant initially - if (startoct == endoct) { - // note: we start drawing, stop, then start again in this - // case otherwise: we only draw in this octant, so initialize - // it to false, it will get set back to true - if (start > end) { - // unfortunately, if we're in the same octant and need to - // draw over the whole circle, we need to set the rest to - // true, because the while loop will end at the bottom. - drawoct = 255; - } - else { - drawoct &= 255 - (1 << oct); - } - } - else if (oct % 2) - drawoct &= 255 - (1 << oct); - else - drawoct |= (1 << oct); - } - else if (oct != startoct) { // already verified that it's != endoct - drawoct |= (1 << oct); // draw this entire segment - } - } while (oct != endoct); - - // so now we have what octants to draw and when to draw them. all that's - // left is the actual raster code. - - /* Lock surface */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - - /* - * Draw arc - */ - result = 0; - - /* - * Alpha Check - */ - if ((color & 255) == 255) { - /* - * No Alpha - direct memory writes - */ - - /* - * Setup color - */ - colorptr = (Uint8 *)&color; - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], - colorptr[2], colorptr[3]); - } - else { - color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], - colorptr[1], colorptr[0]); - } - - /* - * Draw - */ - do { - ypcy = y + cy; - ymcy = y - cy; - if (cx > 0) { - xpcx = x + cx; - xmcx = x - cx; - // always check if we're drawing a certain octant before adding - // a pixel to that octant. - if (drawoct & 4) - result |= fastPixelColorNolock( - dst, xmcx, ypcy, - color); // drawoct & 4 = 22; drawoct[2] - if (drawoct & 2) - result |= fastPixelColorNolock(dst, xpcx, ypcy, color); - if (drawoct & 32) - result |= fastPixelColorNolock(dst, xmcx, ymcy, color); - if (drawoct & 64) - result |= fastPixelColorNolock(dst, xpcx, ymcy, color); - } - else { - if (drawoct & 6) - result |= fastPixelColorNolock( - dst, x, ypcy, - color); // 4 + 2; drawoct[2] || drawoct[1] - if (drawoct & 96) - result |= - fastPixelColorNolock(dst, x, ymcy, color); // 32 + 64 - } - - xpcy = x + cy; - xmcy = x - cy; - if (cx > 0 && cx != cy) { - ypcx = y + cx; - ymcx = y - cx; - if (drawoct & 8) - result |= fastPixelColorNolock(dst, xmcy, ypcx, color); - if (drawoct & 1) - result |= fastPixelColorNolock(dst, xpcy, ypcx, color); - if (drawoct & 16) - result |= fastPixelColorNolock(dst, xmcy, ymcx, color); - if (drawoct & 128) - result |= fastPixelColorNolock(dst, xpcy, ymcx, color); - } - else if (cx == 0) { - if (drawoct & 24) - result |= - fastPixelColorNolock(dst, xmcy, y, color); // 8 + 16 - if (drawoct & 129) - result |= - fastPixelColorNolock(dst, xpcy, y, color); // 1 + 128 - } - - /* - * Update whether we're drawing an octant - */ - if (stopval_start == cx) { - // works like an on-off switch because start & end may be in - // the same octant. - if (drawoct & (1 << startoct)) - drawoct &= 255 - (1 << startoct); - else - drawoct |= (1 << startoct); - } - if (stopval_end == cx) { - if (drawoct & (1 << endoct)) - drawoct &= 255 - (1 << endoct); - else - drawoct |= (1 << endoct); - } - - /* - * Update pixels - */ - if (df < 0) { - df += d_e; - d_e += 2; - d_se += 2; - } - else { - df += d_se; - d_e += 2; - d_se += 4; - cy--; - } - cx++; - } while (cx <= cy); - - /* - * Unlock surface - */ - SDL_UnlockSurface(dst); - } - else { - /* - * Using Alpha - blended pixel blits - */ - - do { - ypcy = y + cy; - ymcy = y - cy; - if (cx > 0) { - xpcx = x + cx; - xmcx = x - cx; - - // always check if we're drawing a certain octant before adding - // a pixel to that octant. - if (drawoct & 4) - result |= pixelColorNolock(dst, xmcx, ypcy, color); - if (drawoct & 2) - result |= pixelColorNolock(dst, xpcx, ypcy, color); - if (drawoct & 32) - result |= pixelColorNolock(dst, xmcx, ymcy, color); - if (drawoct & 64) - result |= pixelColorNolock(dst, xpcx, ymcy, color); - } - else { - if (drawoct & 96) - result |= pixelColorNolock(dst, x, ymcy, color); - if (drawoct & 6) - result |= pixelColorNolock(dst, x, ypcy, color); - } - - xpcy = x + cy; - xmcy = x - cy; - if (cx > 0 && cx != cy) { - ypcx = y + cx; - ymcx = y - cx; - if (drawoct & 8) - result |= pixelColorNolock(dst, xmcy, ypcx, color); - if (drawoct & 1) - result |= pixelColorNolock(dst, xpcy, ypcx, color); - if (drawoct & 16) - result |= pixelColorNolock(dst, xmcy, ymcx, color); - if (drawoct & 128) - result |= pixelColorNolock(dst, xpcy, ymcx, color); - } - else if (cx == 0) { - if (drawoct & 24) - result |= pixelColorNolock(dst, xmcy, y, color); - if (drawoct & 129) - result |= pixelColorNolock(dst, xpcy, y, color); - } - - /* - * Update whether we're drawing an octant - */ - if (stopval_start == cx) { - // works like an on-off switch. - // This is just in case start & end are in the same octant. - if (drawoct & (1 << startoct)) - drawoct &= 255 - (1 << startoct); - else - drawoct |= (1 << startoct); - } - if (stopval_end == cx) { - if (drawoct & (1 << endoct)) - drawoct &= 255 - (1 << endoct); - else - drawoct |= (1 << endoct); - } - - /* - * Update pixels - */ - if (df < 0) { - df += d_e; - d_e += 2; - d_se += 2; - } - else { - df += d_se; - d_e += 2; - d_se += 4; - cy--; - } - cx++; - } while (cx <= cy); - - } /* Alpha check */ - - /* Unlock surface */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - return (result); -} - -/*! -\brief Arc with blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the arc. -\param y Y coordinate of the center of the arc. -\param rad Radius in pixels of the arc. -\param start Starting radius in degrees of the arc. 0 degrees is down, -increasing counterclockwise. \param end Ending radius in degrees of the arc. 0 -degrees is down, increasing counterclockwise. \param r The red value of the arc -to draw. \param g The green value of the arc to draw. \param b The blue value -of the arc to draw. \param a The alpha value of the arc to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -arcRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (arcColor( - dst, x, y, rad, start, end, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -/* ----- AA Circle */ - -/*! -\brief Draw anti-aliased circle with blending. - -Note: The AA-circle routine is based on AA-ellipse with identical radii. - -\param dst The surface to draw on. -\param x X coordinate of the center of the aa-circle. -\param y Y coordinate of the center of the aa-circle. -\param rad Radius in pixels of the aa-circle. -\param color The color value of the aa-circle to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -aacircleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color) -{ - return (aaellipseColor(dst, x, y, rad, rad, color)); -} - -/*! -\brief Draw anti-aliased circle with blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the aa-circle. -\param y Y coordinate of the center of the aa-circle. -\param rad Radius in pixels of the aa-circle. -\param r The red value of the aa-circle to draw. -\param g The green value of the aa-circle to draw. -\param b The blue value of the aa-circle to draw. -\param a The alpha value of the aa-circle to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -aacircleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (aaellipseColor( - dst, x, y, rad, rad, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -/* ----- Filled Circle */ - -/*! -\brief Draw filled circle with blending. - -Note: Based on algorithms from sge library with modifications by A. Schiffler -for multiple-hline draw removal and other minor speedup changes. - -\param dst The surface to draw on. -\param x X coordinate of the center of the filled circle. -\param y Y coordinate of the center of the filled circle. -\param rad Radius in pixels of the filled circle. -\param color The color value of the filled circle to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledCircleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, - Uint32 color) -{ - Sint16 left, right, top, bottom; - int result; - Sint16 x1, y1, x2, y2; - Sint16 cx = 0; - Sint16 cy = rad; - Sint16 ocx = (Sint16)0xffff; - Sint16 ocy = (Sint16)0xffff; - Sint16 df = 1 - rad; - Sint16 d_e = 3; - Sint16 d_se = -2 * rad + 5; - Sint16 xpcx, xmcx, xpcy, xmcy; - Sint16 ypcy, ymcy, ypcx, ymcx; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Sanity check radius - */ - if (rad < 0) { - return (-1); - } - - /* - * Special case for rad=0 - draw a point - */ - if (rad == 0) { - return (pixelColor(dst, x, y, color)); - } - - /* - * Get circle and clipping boundary and - * test if bounding box of circle is visible - */ - x2 = x + rad; - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - x1 = x - rad; - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - y2 = y + rad; - top = dst->clip_rect.y; - if (y2 < top) { - return (0); - } - y1 = y - rad; - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if (y1 > bottom) { - return (0); - } - - /* - * Draw - */ - result = 0; - do { - xpcx = x + cx; - xmcx = x - cx; - xpcy = x + cy; - xmcy = x - cy; - if (ocy != cy) { - if (cy > 0) { - ypcy = y + cy; - ymcy = y - cy; - result |= hlineColor(dst, xmcx, xpcx, ypcy, color); - result |= hlineColor(dst, xmcx, xpcx, ymcy, color); - } - else { - result |= hlineColor(dst, xmcx, xpcx, y, color); - } - ocy = cy; - } - if (ocx != cx) { - if (cx != cy) { - if (cx > 0) { - ypcx = y + cx; - ymcx = y - cx; - result |= hlineColor(dst, xmcy, xpcy, ymcx, color); - result |= hlineColor(dst, xmcy, xpcy, ypcx, color); - } - else { - result |= hlineColor(dst, xmcy, xpcy, y, color); - } - } - ocx = cx; - } - /* - * Update - */ - if (df < 0) { - df += d_e; - d_e += 2; - d_se += 2; - } - else { - df += d_se; - d_e += 2; - d_se += 4; - cy--; - } - cx++; - } while (cx <= cy); - - return (result); -} - -/*! -\brief Draw filled circle with blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the filled circle. -\param y Y coordinate of the center of the filled circle. -\param rad Radius in pixels of the filled circle. -\param r The red value of the filled circle to draw. -\param g The green value of the filled circle to draw. -\param b The blue value of the filled circle to draw. -\param a The alpha value of the filled circle to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledCircleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, - Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (filledCircleColor( - dst, x, y, rad, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -/* ----- Ellipse */ - -/*! -\brief Draw ellipse with blending. - -Note: Based on algorithms from sge library with modifications by A. Schiffler -for multiple-pixel draw removal and other minor speedup changes. - -\param dst The surface to draw on. -\param x X coordinate of the center of the ellipse. -\param y Y coordinate of the center of the ellipse. -\param rx Horizontal radius in pixels of the ellipse. -\param ry Vertical radius in pixels of the ellipse. -\param color The color value of the ellipse to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -ellipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint32 color) -{ - Sint16 left, right, top, bottom; - int result; - Sint16 x1, y1, x2, y2; - int ix, iy; - int h, i, j, k; - int oh, oi, oj, ok; - int xmh, xph, ypk, ymk; - int xmi, xpi, ymj, ypj; - int xmj, xpj, ymi, ypi; - int xmk, xpk, ymh, yph; - Uint8 *colorptr; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Sanity check radii - */ - if ((rx < 0) || (ry < 0)) { - return (-1); - } - - /* - * Special case for rx=0 - draw a vline - */ - if (rx == 0) { - return (vlineColor(dst, x, y - ry, y + ry, color)); - } - /* - * Special case for ry=0 - draw a hline - */ - if (ry == 0) { - return (hlineColor(dst, x - rx, x + rx, y, color)); - } - - /* - * Get circle and clipping boundary and - * test if bounding box of circle is visible - */ - x2 = x + rx; - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - x1 = x - rx; - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - y2 = y + ry; - top = dst->clip_rect.y; - if (y2 < top) { - return (0); - } - y1 = y - ry; - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if (y1 > bottom) { - return (0); - } - - /* - * Init vars - */ - oh = oi = oj = ok = 0xFFFF; - - /* - * Draw - */ - result = 0; - - /* Lock surface */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - - /* - * Check alpha - */ - if ((color & 255) == 255) { - /* - * No Alpha - direct memory writes - */ - - /* - * Setup color - */ - colorptr = (Uint8 *)&color; - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], - colorptr[2], colorptr[3]); - } - else { - color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], - colorptr[1], colorptr[0]); - } - - if (rx > ry) { - ix = 0; - iy = rx * 64; - - do { - h = (ix + 32) >> 6; - i = (iy + 32) >> 6; - j = (h * ry) / rx; - k = (i * ry) / rx; - - if (((ok != k) && (oj != k)) || ((oj != j) && (ok != j)) || - (k != j)) { - xph = x + h; - xmh = x - h; - if (k > 0) { - ypk = y + k; - ymk = y - k; - result |= fastPixelColorNolock(dst, xmh, ypk, color); - result |= fastPixelColorNolock(dst, xph, ypk, color); - result |= fastPixelColorNolock(dst, xmh, ymk, color); - result |= fastPixelColorNolock(dst, xph, ymk, color); - } - else { - result |= fastPixelColorNolock(dst, xmh, y, color); - result |= fastPixelColorNolock(dst, xph, y, color); - } - ok = k; - xpi = x + i; - xmi = x - i; - if (j > 0) { - ypj = y + j; - ymj = y - j; - result |= fastPixelColorNolock(dst, xmi, ypj, color); - result |= fastPixelColorNolock(dst, xpi, ypj, color); - result |= fastPixelColorNolock(dst, xmi, ymj, color); - result |= fastPixelColorNolock(dst, xpi, ymj, color); - } - else { - result |= fastPixelColorNolock(dst, xmi, y, color); - result |= fastPixelColorNolock(dst, xpi, y, color); - } - oj = j; - } - - ix = ix + iy / rx; - iy = iy - ix / rx; - - } while (i > h); - } - else { - ix = 0; - iy = ry * 64; - - do { - h = (ix + 32) >> 6; - i = (iy + 32) >> 6; - j = (h * rx) / ry; - k = (i * rx) / ry; - - if (((oi != i) && (oh != i)) || - ((oh != h) && (oi != h) && (i != h))) { - xmj = x - j; - xpj = x + j; - if (i > 0) { - ypi = y + i; - ymi = y - i; - result |= fastPixelColorNolock(dst, xmj, ypi, color); - result |= fastPixelColorNolock(dst, xpj, ypi, color); - result |= fastPixelColorNolock(dst, xmj, ymi, color); - result |= fastPixelColorNolock(dst, xpj, ymi, color); - } - else { - result |= fastPixelColorNolock(dst, xmj, y, color); - result |= fastPixelColorNolock(dst, xpj, y, color); - } - oi = i; - xmk = x - k; - xpk = x + k; - if (h > 0) { - yph = y + h; - ymh = y - h; - result |= fastPixelColorNolock(dst, xmk, yph, color); - result |= fastPixelColorNolock(dst, xpk, yph, color); - result |= fastPixelColorNolock(dst, xmk, ymh, color); - result |= fastPixelColorNolock(dst, xpk, ymh, color); - } - else { - result |= fastPixelColorNolock(dst, xmk, y, color); - result |= fastPixelColorNolock(dst, xpk, y, color); - } - oh = h; - } - - ix = ix + iy / ry; - iy = iy - ix / ry; - - } while (i > h); - } - } - else { - if (rx > ry) { - ix = 0; - iy = rx * 64; - - do { - h = (ix + 32) >> 6; - i = (iy + 32) >> 6; - j = (h * ry) / rx; - k = (i * ry) / rx; - - if (((ok != k) && (oj != k)) || ((oj != j) && (ok != j)) || - (k != j)) { - xph = x + h; - xmh = x - h; - if (k > 0) { - ypk = y + k; - ymk = y - k; - result |= pixelColorNolock(dst, xmh, ypk, color); - result |= pixelColorNolock(dst, xph, ypk, color); - result |= pixelColorNolock(dst, xmh, ymk, color); - result |= pixelColorNolock(dst, xph, ymk, color); - } - else { - result |= pixelColorNolock(dst, xmh, y, color); - result |= pixelColorNolock(dst, xph, y, color); - } - ok = k; - xpi = x + i; - xmi = x - i; - if (j > 0) { - ypj = y + j; - ymj = y - j; - result |= pixelColorNolock(dst, xmi, ypj, color); - result |= pixelColorNolock(dst, xpi, ypj, color); - result |= pixelColorNolock(dst, xmi, ymj, color); - result |= pixelColor(dst, xpi, ymj, color); - } - else { - result |= pixelColorNolock(dst, xmi, y, color); - result |= pixelColorNolock(dst, xpi, y, color); - } - oj = j; - } - - ix = ix + iy / rx; - iy = iy - ix / rx; - - } while (i > h); - } - else { - ix = 0; - iy = ry * 64; - - do { - h = (ix + 32) >> 6; - i = (iy + 32) >> 6; - j = (h * rx) / ry; - k = (i * rx) / ry; - - if (((oi != i) && (oh != i)) || - ((oh != h) && (oi != h) && (i != h))) { - xmj = x - j; - xpj = x + j; - if (i > 0) { - ypi = y + i; - ymi = y - i; - result |= pixelColorNolock(dst, xmj, ypi, color); - result |= pixelColorNolock(dst, xpj, ypi, color); - result |= pixelColorNolock(dst, xmj, ymi, color); - result |= pixelColorNolock(dst, xpj, ymi, color); - } - else { - result |= pixelColorNolock(dst, xmj, y, color); - result |= pixelColorNolock(dst, xpj, y, color); - } - oi = i; - xmk = x - k; - xpk = x + k; - if (h > 0) { - yph = y + h; - ymh = y - h; - result |= pixelColorNolock(dst, xmk, yph, color); - result |= pixelColorNolock(dst, xpk, yph, color); - result |= pixelColorNolock(dst, xmk, ymh, color); - result |= pixelColorNolock(dst, xpk, ymh, color); - } - else { - result |= pixelColorNolock(dst, xmk, y, color); - result |= pixelColorNolock(dst, xpk, y, color); - } - oh = h; - } - - ix = ix + iy / ry; - iy = iy - ix / ry; - - } while (i > h); - } - - } /* Alpha check */ - - /* Unlock surface */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - return (result); -} - -/*! -\brief Draw ellipse with blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the ellipse. -\param y Y coordinate of the center of the ellipse. -\param rx Horizontal radius in pixels of the ellipse. -\param ry Vertical radius in pixels of the ellipse. -\param r The red value of the ellipse to draw. -\param g The green value of the ellipse to draw. -\param b The blue value of the ellipse to draw. -\param a The alpha value of the ellipse to draw. + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } -\returns Returns 0 on success, -1 on failure. -*/ -int -ellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (ellipseColor( - dst, x, y, rx, ry, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); + return (result); } /* ----- AA Ellipse */ @@ -4512,214 +1962,6 @@ aaellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); } -/* ---- Filled Ellipse */ - -/* Note: */ -/* Based on algorithm from sge library with multiple-hline draw removal */ -/* and other speedup changes. */ - -/*! -\brief Draw filled ellipse with blending. - -Note: Based on algorithm from sge library with multiple-hline draw removal -and other speedup changes. - -\param dst The surface to draw on. -\param x X coordinate of the center of the filled ellipse. -\param y Y coordinate of the center of the filled ellipse. -\param rx Horizontal radius in pixels of the filled ellipse. -\param ry Vertical radius in pixels of the filled ellipse. -\param color The color value of the filled ellipse to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledEllipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint32 color) -{ - Sint16 left, right, top, bottom; - int result; - Sint16 x1, y1, x2, y2; - int ix, iy; - int h, i, j, k; - int oh, oi, oj, ok; - int xmh, xph; - int xmi, xpi; - int xmj, xpj; - int xmk, xpk; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Sanity check radii - */ - if ((rx < 0) || (ry < 0)) { - return (-1); - } - - /* - * Special case for rx=0 - draw a vline - */ - if (rx == 0) { - return (vlineColor(dst, x, y - ry, y + ry, color)); - } - /* - * Special case for ry=0 - draw a hline - */ - if (ry == 0) { - return (hlineColor(dst, x - rx, x + rx, y, color)); - } - - /* - * Get circle and clipping boundary and - * test if bounding box of circle is visible - */ - x2 = x + rx; - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - x1 = x - rx; - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - y2 = y + ry; - top = dst->clip_rect.y; - if (y2 < top) { - return (0); - } - y1 = y - ry; - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if (y1 > bottom) { - return (0); - } - - /* - * Init vars - */ - oh = oi = oj = ok = 0xFFFF; - - /* - * Draw - */ - result = 0; - if (rx > ry) { - ix = 0; - iy = rx * 64; - - do { - h = (ix + 32) >> 6; - i = (iy + 32) >> 6; - j = (h * ry) / rx; - k = (i * ry) / rx; - - if ((ok != k) && (oj != k)) { - xph = x + h; - xmh = x - h; - if (k > 0) { - result |= hlineColor(dst, xmh, xph, y + k, color); - result |= hlineColor(dst, xmh, xph, y - k, color); - } - else { - result |= hlineColor(dst, xmh, xph, y, color); - } - ok = k; - } - if ((oj != j) && (ok != j) && (k != j)) { - xmi = x - i; - xpi = x + i; - if (j > 0) { - result |= hlineColor(dst, xmi, xpi, y + j, color); - result |= hlineColor(dst, xmi, xpi, y - j, color); - } - else { - result |= hlineColor(dst, xmi, xpi, y, color); - } - oj = j; - } - - ix = ix + iy / rx; - iy = iy - ix / rx; - - } while (i > h); - } - else { - ix = 0; - iy = ry * 64; - - do { - h = (ix + 32) >> 6; - i = (iy + 32) >> 6; - j = (h * rx) / ry; - k = (i * rx) / ry; - - if ((oi != i) && (oh != i)) { - xmj = x - j; - xpj = x + j; - if (i > 0) { - result |= hlineColor(dst, xmj, xpj, y + i, color); - result |= hlineColor(dst, xmj, xpj, y - i, color); - } - else { - result |= hlineColor(dst, xmj, xpj, y, color); - } - oi = i; - } - if ((oh != h) && (oi != h) && (i != h)) { - xmk = x - k; - xpk = x + k; - if (h > 0) { - result |= hlineColor(dst, xmk, xpk, y + h, color); - result |= hlineColor(dst, xmk, xpk, y - h, color); - } - else { - result |= hlineColor(dst, xmk, xpk, y, color); - } - oh = h; - } - - ix = ix + iy / ry; - iy = iy - ix / ry; - - } while (i > h); - } - - return (result); -} - -/*! -\brief Draw filled ellipse with blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the filled ellipse. -\param y Y coordinate of the center of the filled ellipse. -\param rx Horizontal radius in pixels of the filled ellipse. -\param ry Vertical radius in pixels of the filled ellipse. -\param r The red value of the filled ellipse to draw. -\param g The green value of the filled ellipse to draw. -\param b The blue value of the filled ellipse to draw. -\param a The alpha value of the filled ellipse to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledEllipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (filledEllipseColor( - dst, x, y, rx, ry, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - /* ----- pie */ /*! @@ -4922,118 +2164,6 @@ pieRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, 0)); } -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ -/*! -\brief Draw filled pie with alpha blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the filled pie. -\param y Y coordinate of the center of the filled pie. -\param rad Radius in pixels of the filled pie. -\param start Starting radius in degrees of the filled pie. -\param end Ending radius in degrees of the filled pie. -\param color The color value of the filled pie to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color) -{ - return (_pieColor(dst, x, y, rad, start, end, color, 1)); -} - -/*! -\brief Draw filled pie with alpha blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the filled pie. -\param y Y coordinate of the center of the filled pie. -\param rad Radius in pixels of the filled pie. -\param start Starting radius in degrees of the filled pie. -\param end Ending radius in degrees of the filled pie. -\param r The red value of the filled pie to draw. -\param g The green value of the filled pie to draw. -\param b The blue value of the filled pie to draw. -\param a The alpha value of the filled pie to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int filledPieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, - Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - return (_pieColor(dst, x, y, rad, start, end, - ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a, 1)); -} -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/* ------ Trigon */ - -/*! -\brief Draw trigon (triangle outline) with alpha blending. - -Note: Creates vertex array and uses polygon routine to render. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the trigon. -\param y1 Y coordinate of the first point of the trigon. -\param x2 X coordinate of the second point of the trigon. -\param y2 Y coordinate of the second point of the trigon. -\param x3 X coordinate of the third point of the trigon. -\param y3 Y coordinate of the third point of the trigon. -\param color The color value of the trigon to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -trigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint32 color) -{ - Sint16 vx[3]; - Sint16 vy[3]; - - vx[0] = x1; - vx[1] = x2; - vx[2] = x3; - vy[0] = y1; - vy[1] = y2; - vy[2] = y3; - - return (polygonColor(dst, vx, vy, 3, color)); -} - -/*! -\brief Draw trigon (triangle outline) with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the trigon. -\param y1 Y coordinate of the first point of the trigon. -\param x2 X coordinate of the second point of the trigon. -\param y2 Y coordinate of the second point of the trigon. -\param x3 X coordinate of the third point of the trigon. -\param y3 Y coordinate of the third point of the trigon. -\param r The red value of the trigon to draw. -\param g The green value of the trigon to draw. -\param b The blue value of the trigon to draw. -\param a The alpha value of the trigon to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -trigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - Sint16 vx[3]; - Sint16 vy[3]; - - vx[0] = x1; - vx[1] = x2; - vx[2] = x3; - vy[0] = y1; - vy[1] = y2; - vy[2] = y3; - - return (polygonRGBA(dst, vx, vy, 3, r, g, b, a)); -} - /* ------ AA-Trigon */ /*! @@ -5043,87 +2173,18 @@ Note: Creates vertex array and uses aapolygon routine to render. \param dst The surface to draw on. \param x1 X coordinate of the first point of the aa-trigon. -\param y1 Y coordinate of the first point of the aa-trigon. -\param x2 X coordinate of the second point of the aa-trigon. -\param y2 Y coordinate of the second point of the aa-trigon. -\param x3 X coordinate of the third point of the aa-trigon. -\param y3 Y coordinate of the third point of the aa-trigon. -\param color The color value of the aa-trigon to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -aatrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint32 color) -{ - Sint16 vx[3]; - Sint16 vy[3]; - - vx[0] = x1; - vx[1] = x2; - vx[2] = x3; - vy[0] = y1; - vy[1] = y2; - vy[2] = y3; - - return (aapolygonColor(dst, vx, vy, 3, color)); -} - -/*! -\brief Draw anti-aliased trigon (triangle outline) with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the aa-trigon. -\param y1 Y coordinate of the first point of the aa-trigon. -\param x2 X coordinate of the second point of the aa-trigon. -\param y2 Y coordinate of the second point of the aa-trigon. -\param x3 X coordinate of the third point of the aa-trigon. -\param y3 Y coordinate of the third point of the aa-trigon. -\param r The red value of the aa-trigon to draw. -\param g The green value of the aa-trigon to draw. -\param b The blue value of the aa-trigon to draw. -\param a The alpha value of the aa-trigon to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -aatrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - Sint16 vx[3]; - Sint16 vy[3]; - - vx[0] = x1; - vx[1] = x2; - vx[2] = x3; - vy[0] = y1; - vy[1] = y2; - vy[2] = y3; - - return (aapolygonRGBA(dst, vx, vy, 3, r, g, b, a)); -} - -/* ------ Filled Trigon */ - -/*! -\brief Draw filled trigon (triangle) with alpha blending. - -Note: Creates vertex array and uses aapolygon routine to render. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the filled trigon. -\param y1 Y coordinate of the first point of the filled trigon. -\param x2 X coordinate of the second point of the filled trigon. -\param y2 Y coordinate of the second point of the filled trigon. -\param x3 X coordinate of the third point of the filled trigon. -\param y3 Y coordinate of the third point of the filled trigon. -\param color The color value of the filled trigon to draw (0xRRGGBBAA). +\param y1 Y coordinate of the first point of the aa-trigon. +\param x2 X coordinate of the second point of the aa-trigon. +\param y2 Y coordinate of the second point of the aa-trigon. +\param x3 X coordinate of the third point of the aa-trigon. +\param y3 Y coordinate of the third point of the aa-trigon. +\param color The color value of the aa-trigon to draw (0xRRGGBBAA). \returns Returns 0 on success, -1 on failure. */ int -filledTrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint32 color) +aatrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, + Sint16 x3, Sint16 y3, Uint32 color) { Sint16 vx[3]; Sint16 vy[3]; @@ -5135,31 +2196,29 @@ filledTrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, vy[1] = y2; vy[2] = y3; - return (filledPolygonColor(dst, vx, vy, 3, color)); + return (aapolygonColor(dst, vx, vy, 3, color)); } /*! -\brief Draw filled trigon (triangle) with alpha blending. - -Note: Creates vertex array and uses aapolygon routine to render. +\brief Draw anti-aliased trigon (triangle outline) with alpha blending. \param dst The surface to draw on. -\param x1 X coordinate of the first point of the filled trigon. -\param y1 Y coordinate of the first point of the filled trigon. -\param x2 X coordinate of the second point of the filled trigon. -\param y2 Y coordinate of the second point of the filled trigon. -\param x3 X coordinate of the third point of the filled trigon. -\param y3 Y coordinate of the third point of the filled trigon. -\param r The red value of the filled trigon to draw. -\param g The green value of the filled trigon to draw. -\param b The blue value of the filled trigon to draw. -\param a The alpha value of the filled trigon to draw. +\param x1 X coordinate of the first point of the aa-trigon. +\param y1 Y coordinate of the first point of the aa-trigon. +\param x2 X coordinate of the second point of the aa-trigon. +\param y2 Y coordinate of the second point of the aa-trigon. +\param x3 X coordinate of the third point of the aa-trigon. +\param y3 Y coordinate of the third point of the aa-trigon. +\param r The red value of the aa-trigon to draw. +\param g The green value of the aa-trigon to draw. +\param b The blue value of the aa-trigon to draw. +\param a The alpha value of the aa-trigon to draw. \returns Returns 0 on success, -1 on failure. */ int -filledTrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +aatrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, + Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { Sint16 vx[3]; Sint16 vy[3]; @@ -5171,9 +2230,11 @@ filledTrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, vy[1] = y2; vy[2] = y3; - return (filledPolygonRGBA(dst, vx, vy, 3, r, g, b, a)); + return (aapolygonRGBA(dst, vx, vy, 3, r, g, b, a)); } +/* ------ Filled Trigon */ + /* ---- Polygon */ /*! @@ -5243,32 +2304,6 @@ polygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, return (result); } -/*! -\brief Draw polygon with alpha blending. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the polygon. -\param vy Vertex array containing Y coordinates of the points of the polygon. -\param n Number of points in the vertex array. Minimum number is 3. -\param r The red value of the polygon to draw. -\param g The green value of the polygon to draw. -\param b The blue value of the polygon to draw. -\param a The alpha value of the polygon to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -polygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (polygonColor( - dst, vx, vy, n, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - /* ---- AA-Polygon */ /*! @@ -5585,40 +2620,6 @@ filledPolygonColorMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, return (result); } -/*! -\brief Draw filled polygon with alpha blending (multi-threaded capable). - -Note: The last two parameters are optional; but are required for multithreaded -operation. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the filled -polygon. \param vy Vertex array containing Y coordinates of the points of the -filled polygon. \param n Number of points in the vertex array. Minimum number -is 3. \param r The red value of the filled polygon to draw. \param g The green -value of the filled polygon to draw. \param b The blue value of the filed -polygon to draw. \param a The alpha value of the filled polygon to draw. \param -polyInts Preallocated, temporary vertex array used for sorting vertices. -Required for multithreaded operation; set to NULL otherwise. \param -polyAllocated Flag indicating if temporary vertex array was allocated. Required -for multithreaded operation; set to NULL otherwise. - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledPolygonRGBAMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, - int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a, int **polyInts, - int *polyAllocated) -{ - /* - * Draw - */ - return (filledPolygonColorMT( - dst, vx, vy, n, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a, - polyInts, polyAllocated)); -} - /*! \brief Draw filled polygon with alpha blending. @@ -5643,32 +2644,6 @@ filledPolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, return (filledPolygonColorMT(dst, vx, vy, n, color, NULL, NULL)); } -/*! -\brief Draw filled polygon with alpha blending. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the filled -polygon. \param vy Vertex array containing Y coordinates of the points of the -filled polygon. \param n Number of points in the vertex array. Minimum number -is 3. \param r The red value of the filled polygon to draw. \param g The green -value of the filled polygon to draw. \param b The blue value of the filed -polygon to draw. \param a The alpha value of the filled polygon to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledPolygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (filledPolygonColorMT( - dst, vx, vy, n, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a, - NULL, NULL)); -} - /*! \brief Internal function to draw a textured horizontal line. @@ -6022,414 +2997,6 @@ texturedPolygon(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, NULL, NULL)); } -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/* ---- Character */ - -/*! -\brief Global cache for NxM pixel font surfaces created at runtime. -*/ -static SDL_Surface *gfxPrimitivesFont[256]; - -/*! -\brief Global cache of the color used for the font surfaces created at runtime. -*/ -// static Uint32 gfxPrimitivesFontColor[256]; - -/*! -\brief Pointer to the current font data. Default is a 8x8 pixel internal font. -*/ -static const unsigned char *currentFontdata = gfxPrimitivesFontdata; - -/*! -\brief Width of the current font. Default is 8. -*/ -static Uint32 charWidth = 8; - -/*! -\brief Height of the current font. Default is 8. -*/ -static Uint32 charHeight = 8; - -/*! -\brief Width for rendering. Autocalculated. -*/ -static Uint32 charWidthLocal = 8; - -/*! -\brief Height for rendering. Autocalculated. -*/ -static Uint32 charHeightLocal = 8; - -/*! -\brief Pitch of the current font in bytes. Default is 1. -*/ -static Uint32 charPitch = 1; - -/*! -\brief Characters 90deg clockwise rotations. Default is 0. Max is 3. -*/ -static Uint32 charRotation = 0; - -/*! -\brief Character data size in bytes of the current font. Default is 8. -*/ -static Uint32 charSize = 8; - -/*! -\brief Sets or resets the current global font data. - -The font data array is organized in follows: -[fontdata] = [character 0][character 1]...[character 255] where -[character n] = [byte 1 row 1][byte 2 row 1]...[byte {pitch} row 1][byte 1 row 2] ...[byte {pitch} row height] where -[byte n] = [bit 0]...[bit 7] where -[bit n] = [0 for transparent pixel|1 for colored pixel] - -\param fontdata Pointer to array of font data. Set to NULL, to reset global font to the default 8x8 font. -\param cw Width of character in bytes. Ignored if fontdata==NULL. -\param ch Height of character in bytes. Ignored if fontdata==NULL. -*/ -void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch) -{ - int i; - - if ((fontdata) && (cw) && (ch)) { - currentFontdata = fontdata; - charWidth = cw; - charHeight = ch; - } else { - currentFontdata = gfxPrimitivesFontdata; - charWidth = 8; - charHeight = 8; - } - - charPitch = (charWidth+7)/8; - charSize = charPitch * charHeight; - - /* Maybe flip width/height for rendering */ - if ((charRotation==1) || (charRotation==3)) - { - charWidthLocal = charHeight; - charHeightLocal = charWidth; - } - else - { - charWidthLocal = charWidth; - charHeightLocal = charHeight; - } - - /* Clear character cache */ - for (i = 0; i < 256; i++) { - if (gfxPrimitivesFont[i]) { - SDL_FreeSurface(gfxPrimitivesFont[i]); - gfxPrimitivesFont[i] = NULL; - } - } -} - -/*! -\brief Sets current global font character rotation steps. - -Default is 0 (no rotation). 1 = 90deg clockwise. 2 = 180deg clockwise. 3 = 270deg clockwise. -Changing the rotation, will reset the character cache. - -\param rotation Number of 90deg clockwise steps to rotate -*/ -void gfxPrimitivesSetFontRotation(Uint32 rotation) -{ - int i; - - rotation = rotation & 3; - if (charRotation != rotation) - { - /* Store rotation */ - charRotation = rotation; - - /* Maybe flip width/height for rendering */ - if ((charRotation==1) || (charRotation==3)) - { - charWidthLocal = charHeight; - charHeightLocal = charWidth; - } - else - { - charWidthLocal = charWidth; - charHeightLocal = charHeight; - } - - /* Clear character cache */ - for (i = 0; i < 256; i++) { - if (gfxPrimitivesFont[i]) { - SDL_FreeSurface(gfxPrimitivesFont[i]); - gfxPrimitivesFont[i] = NULL; - } - } - } -} - - - -/*! -\brief Draw a character of the currently set font. - -On first call for a particular character and color combination, the function needs to -generate the character surface (slower. Subsequent calls blit a cached surface (fast). -Uses alpha blending if A<255 in color. - -\param dst The surface to draw on. -\param x X (horizontal) coordinate of the upper left corner of the character. -\param y Y (vertical) coordinate of the upper left corner of the character. -\param c The character to draw. -\param color The color value of the character to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color) -{ - Sint16 left, right, top, bottom; - Sint16 x1, y1, x2, y2; - SDL_Rect srect; - SDL_Rect drect; - int result; - Uint32 ix, iy; - const unsigned char *charpos; - Uint8 *curpos; - int forced_redraw; - Uint8 patt, mask; - Uint8 *linepos; - Uint32 pitch; - SDL_Surface *rotatedCharacter; - Uint32 ci; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) { - return(0); - } - - /* - * Get text and clipping boundary and - * test if bounding box of character is visible - */ - - left = dst->clip_rect.x; - x2 = x + charWidthLocal; - if (x2clip_rect.x + dst->clip_rect.w - 1; - x1 = x; - if (x1>right) { - return(0); - } - top = dst->clip_rect.y; - y2 = y + charHeightLocal; - if (y2clip_rect.y + dst->clip_rect.h - 1; - y1 = y; - if (y1>bottom) { - return(0); - } - - /* - * Setup source rectangle - */ - srect.x = 0; - srect.y = 0; - srect.w = charWidthLocal; - srect.h = charHeightLocal; - - /* - * Setup destination rectangle - */ - drect.x = x; - drect.y = y; - drect.w = charWidthLocal; - drect.h = charHeightLocal; - - /* Character index in cache */ - ci = (unsigned char) c; - - /* - * Create new charWidth x charHeight bitmap surface if not already present. - * Might get rotated later. - */ - if (gfxPrimitivesFont[ci] == NULL) { - gfxPrimitivesFont[ci] = - SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_HWSURFACE | SDL_SRCALPHA, - charWidth, charHeight, 32, - 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); - /* - * Check pointer - */ - if (gfxPrimitivesFont[ci] == NULL) { - return (-1); - } - /* - * Definitely redraw - */ - forced_redraw = 1; - } else { - forced_redraw = 0; - } - - /* - * Check if color has changed - */ - if ((gfxPrimitivesFontColor[ci] != color) || (forced_redraw)) { - /* - * Redraw character - */ - SDL_SetAlpha(gfxPrimitivesFont[ci], SDL_SRCALPHA, 255); - gfxPrimitivesFontColor[ci] = color; - - /* Lock font-surface */ - if (SDL_LockSurface(gfxPrimitivesFont[ci]) != 0) - return (-1); - - /* - * Variable setup - */ - charpos = currentFontdata + ci * charSize; - linepos = (Uint8 *) gfxPrimitivesFont[ci]->pixels; - pitch = gfxPrimitivesFont[ci]->pitch; - - /* - * Drawing loop - */ - patt = 0; - for (iy = 0; iy < charHeight; iy++) { - mask = 0x00; - curpos = linepos; - for (ix = 0; ix < charWidth; ix++) { - if (!(mask >>= 1)) { - patt = *charpos++; - mask = 0x80; - } - - if (patt & mask) - *(Uint32 *)curpos = color; - else - *(Uint32 *)curpos = 0; - curpos += 4; - } - linepos += pitch; - } - - /* Unlock font-surface */ - SDL_UnlockSurface(gfxPrimitivesFont[ci]); - - /* Maybe rotate and replace cached image */ - if (charRotation>0) - { - // XXX: NOTE: To drop dependency on the rotateSurface90Degrees call. - //rotatedCharacter = rotateSurface90Degrees(gfxPrimitivesFont[ci], charRotation); - //SDL_FreeSurface(gfxPrimitivesFont[ci]); - //gfxPrimitivesFont[ci] = rotatedCharacter; - } - } - - /* - * Draw bitmap onto destination surface - */ - result = SDL_BlitSurface(gfxPrimitivesFont[ci], &srect, dst, &drect); - - return (result); -} - -/*! -\brief Draw a character of the currently set font. - -\param dst The surface to draw on. -\param x X (horizontal) coordinate of the upper left corner of the character. -\param y Y (vertical) coordinate of the upper left corner of the character. -\param c The character to draw. -\param r The red value of the character to draw. -\param g The green value of the character to draw. -\param b The blue value of the character to draw. -\param a The alpha value of the character to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (characterColor(dst, x, y, c, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); -} - -/*! -\brief Draw a string in the currently set font. - -The spacing between consecutive characters in the string is the fixed number of pixels -of the character width of the current global font. - -\param dst The surface to draw on. -\param x X (horizontal) coordinate of the upper left corner of the string. -\param y Y (vertical) coordinate of the upper left corner of the string. -\param s The string to draw. -\param color The color value of the string to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint32 color) -{ - int result = 0; - Sint16 curx = x; - Sint16 cury = y; - const char *curchar = s; - - while (*curchar && !result) { - result |= characterColor(dst, curx, cury, *curchar, color); - switch (charRotation) - { - case 0: - curx += charWidthLocal; - break; - case 2: - curx -= charWidthLocal; - break; - case 1: - cury += charHeightLocal; - break; - case 3: - cury -= charHeightLocal; - break; - } - curchar++; - } - - return (result); -} - -/*! -\brief Draw a string in the currently set font. - -\param dst The surface to draw on. -\param x X (horizontal) coordinate of the upper left corner of the string. -\param y Y (vertical) coordinate of the upper left corner of the string. -\param s The string to draw. -\param r The red value of the string to draw. -\param g The green value of the string to draw. -\param b The blue value of the string to draw. -\param a The alpha value of the string to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (stringColor(dst, x, y, s, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); -} - -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* ---- Bezier curve */ /*! @@ -6595,547 +3162,3 @@ bezierRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, int s, dst, vx, vy, n, s, ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); } - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/*! -\brief Internal function to initialize the Bresenham line iterator. - -Example of use: -SDL_gfxBresenhamIterator b; -_bresenhamInitialize (&b, x1, y1, x2, y2); -do { -plot(b.x, b.y); -} while (_bresenhamIterate(&b)==0); - -\param b Pointer to struct for bresenham line drawing state. -\param x1 X coordinate of the first point of the line. -\param y1 Y coordinate of the first point of the line. -\param x2 X coordinate of the second point of the line. -\param y2 Y coordinate of the second point of the line. - -\returns Returns 0 on success, -1 on failure. -*/ -int _bresenhamInitialize(SDL_gfxBresenhamIterator *b, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2) -{ - int temp; - - if (b==NULL) { - return(-1); - } - - b->x = x1; - b->y = y1; - - /* dx = abs(x2-x1), s1 = sign(x2-x1) */ - if ((b->dx = x2 - x1) != 0) { - if (b->dx < 0) { - b->dx = -b->dx; - b->s1 = -1; - } else { - b->s1 = 1; - } - } else { - b->s1 = 0; - } - - /* dy = abs(y2-y1), s2 = sign(y2-y1) */ - if ((b->dy = y2 - y1) != 0) { - if (b->dy < 0) { - b->dy = -b->dy; - b->s2 = -1; - } else { - b->s2 = 1; - } - } else { - b->s2 = 0; - } - - if (b->dy > b->dx) { - temp = b->dx; - b->dx = b->dy; - b->dy = temp; - b->swapdir = 1; - } else { - b->swapdir = 0; - } - - b->count = (b->dx<0) ? 0 : (unsigned int)b->dx; - b->dy <<= 1; - b->error = b->dy - b->dx; - b->dx <<= 1; - - return(0); -} - - -/*! -\brief Internal function to move Bresenham line iterator to the next position. - -Maybe updates the x and y coordinates of the iterator struct. - -\param b Pointer to struct for bresenham line drawing state. - -\returns Returns 0 on success, 1 if last point was reached, 2 if moving past end-of-line, -1 on failure. -*/ -int _bresenhamIterate(SDL_gfxBresenhamIterator *b) -{ - if (b==NULL) { - return (-1); - } - - /* last point check */ - if (b->count==0) { - return (2); - } - - while (b->error >= 0) { - if (b->swapdir) { - b->x += b->s1; - } else { - b->y += b->s2; - } - - b->error -= b->dx; - } - - if (b->swapdir) { - b->y += b->s2; - } else { - b->x += b->s1; - } - - b->error += b->dy; - b->count--; - - /* count==0 indicates "end-of-line" */ - return ((b->count) ? 0 : 1); -} - - -/*! -\brief Internal function to draw parallel lines with Murphy algorithm. - -\param m Pointer to struct for murphy iterator. -\param x X coordinate of point. -\param y Y coordinate of point. -\param d1 Direction square/diagonal. -*/ -void _murphyParaline(SDL_gfxMurphyIterator *m, Sint16 x, Sint16 y, int d1) -{ - int p; - d1 = -d1; - - /* - * Lock the surface - */ - if (SDL_MUSTLOCK(m->dst)) { - SDL_LockSurface(m->dst); - } - - for (p = 0; p <= m->u; p++) { - - pixelColorNolock(m->dst, x, y, m->color); - - if (d1 <= m->kt) { - if (m->oct2 == 0) { - x++; - } else { - if (m->quad4 == 0) { - y++; - } else { - y--; - } - } - d1 += m->kv; - } else { - x++; - if (m->quad4 == 0) { - y++; - } else { - y--; - } - d1 += m->kd; - } - } - - /* Unlock surface */ - if (SDL_MUSTLOCK(m->dst)) { - SDL_UnlockSurface(m->dst); - } - - m->tempx = x; - m->tempy = y; -} - -/*! -\brief Internal function to draw one iteration of the Murphy algorithm. - -\param m Pointer to struct for murphy iterator. -\param miter Iteration count. -\param ml1bx X coordinate of a point. -\param ml1by Y coordinate of a point. -\param ml2bx X coordinate of a point. -\param ml2by Y coordinate of a point. -\param ml1x X coordinate of a point. -\param ml1y Y coordinate of a point. -\param ml2x X coordinate of a point. -\param ml2y Y coordinate of a point. - -*/ -void _murphyIteration(SDL_gfxMurphyIterator *m, Uint8 miter, - Uint16 ml1bx, Uint16 ml1by, Uint16 ml2bx, Uint16 ml2by, - Uint16 ml1x, Uint16 ml1y, Uint16 ml2x, Uint16 ml2y) -{ - int atemp1, atemp2; - int ftmp1, ftmp2; - Uint16 m1x, m1y, m2x, m2y; - Uint16 fix, fiy, lax, lay, curx, cury; - Sint32 px[4], py[4]; - - SDL_gfxBresenhamIterator b; - - if (miter > 1) { - if (m->first1x != -32768) { - fix = (m->first1x + m->first2x) / 2; - fiy = (m->first1y + m->first2y) / 2; - lax = (m->last1x + m->last2x) / 2; - lay = (m->last1y + m->last2y) / 2; - curx = (ml1x + ml2x) / 2; - cury = (ml1y + ml2y) / 2; - - atemp1 = (fix - curx); - atemp2 = (fiy - cury); - ftmp1 = atemp1 * atemp1 + atemp2 * atemp2; - atemp1 = (lax - curx); - atemp2 = (lay - cury); - ftmp2 = atemp1 * atemp1 + atemp2 * atemp2; - - if (ftmp1 <= ftmp2) { - m1x = m->first1x; - m1y = m->first1y; - m2x = m->first2x; - m2y = m->first2y; - } else { - m1x = m->last1x; - m1y = m->last1y; - m2x = m->last2x; - m2y = m->last2y; - } - - atemp1 = (m2x - ml2x); - atemp2 = (m2y - ml2y); - ftmp1 = atemp1 * atemp1 + atemp2 * atemp2; - atemp1 = (m2x - ml2bx); - atemp2 = (m2y - ml2by); - ftmp2 = atemp1 * atemp1 + atemp2 * atemp2; - - if (ftmp2 >= ftmp1) { - ftmp1 = ml2bx; - ftmp2 = ml2by; - ml2bx = ml2x; - ml2by = ml2y; - ml2x = ftmp1; - ml2y = ftmp2; - ftmp1 = ml1bx; - ftmp2 = ml1by; - ml1bx = ml1x; - ml1by = ml1y; - ml1x = ftmp1; - ml1y = ftmp2; - } - - /* - * Lock the surface - */ - if (SDL_MUSTLOCK(m->dst)) { - SDL_LockSurface(m->dst); - } - - _bresenhamInitialize(&b, m2x, m2y, m1x, m1y); - do { - pixelColorNolock(m->dst, b.x, b.y, m->color); - } while (_bresenhamIterate(&b)==0); - - _bresenhamInitialize(&b, m1x, m1y, ml1bx, ml1by); - do { - pixelColorNolock(m->dst, b.x, b.y, m->color); - } while (_bresenhamIterate(&b)==0); - - _bresenhamInitialize(&b, ml1bx, ml1by, ml2bx, ml2by); - do { - pixelColorNolock(m->dst, b.x, b.y, m->color); - } while (_bresenhamIterate(&b)==0); - - _bresenhamInitialize(&b, ml2bx, ml2by, m2x, m2y); - do { - pixelColorNolock(m->dst, b.x, b.y, m->color); - } while (_bresenhamIterate(&b)==0); - - /* Unlock surface */ - if (SDL_MUSTLOCK(m->dst)) { - SDL_UnlockSurface(m->dst); - } - - px[0] = m1x; - px[1] = m2x; - px[2] = ml1bx; - px[3] = ml2bx; - py[0] = m1y; - py[1] = m2y; - py[2] = ml1by; - py[3] = ml2by; - polygonColor(m->dst, (Sint16 *)px, (Sint16 *)py, 4, m->color); - } - } - - m->last1x = ml1x; - m->last1y = ml1y; - m->last2x = ml2x; - m->last2y = ml2y; - m->first1x = ml1bx; - m->first1y = ml1by; - m->first2x = ml2bx; - m->first2y = ml2by; -} - -#define HYPOT(x, y) sqrt((double)(x) * (double)(x) + (double)(y) * (double)(y)) - -/*! -\brief Internal function to draw wide lines with Murphy algorithm. - -Draws lines parallel to ideal line. - -\param m Pointer to struct for murphy iterator. -\param x1 X coordinate of first point. -\param y1 Y coordinate of first point. -\param x2 X coordinate of second point. -\param y2 Y coordinate of second point. -\param width Width of line. -\param miter Iteration count. - -*/ -void _murphyWideline(SDL_gfxMurphyIterator *m, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 miter) -{ - float offset = (float)width / 2.f; - - Sint16 temp; - Sint16 ptx, pty, ptxx, ptxy, ml1x, ml1y, ml2x, ml2y, ml1bx, ml1by, ml2bx, ml2by; - - int d0, d1; /* difference terms d0=perpendicular to line, d1=along line */ - - int q; /* pel counter,q=perpendicular to line */ - int tmp; - - int dd; /* distance along line */ - int tk; /* thickness threshold */ - double ang; /* angle for initial point calculation */ - double sang, cang; - - /* Initialisation */ - m->u = x2 - x1; /* delta x */ - m->v = y2 - y1; /* delta y */ - - if (m->u < 0) { /* swap to make sure we are in quadrants 1 or 4 */ - temp = x1; - x1 = x2; - x2 = temp; - temp = y1; - y1 = y2; - y1 = temp; - m->u *= -1; - m->v *= -1; - } - - if (m->v < 0) { /* swap to 1st quadrant and flag */ - m->v *= -1; - m->quad4 = 1; - } else { - m->quad4 = 0; - } - - if (m->v > m->u) { /* swap things if in 2 octant */ - tmp = m->u; - m->u = m->v; - m->v = tmp; - m->oct2 = 1; - } else { - m->oct2 = 0; - } - - m->ku = m->u + m->u; /* change in l for square shift */ - m->kv = m->v + m->v; /* change in d for square shift */ - m->kd = m->kv - m->ku; /* change in d for diagonal shift */ - m->kt = m->u - m->kv; /* diag/square decision threshold */ - - d0 = 0; - d1 = 0; - dd = 0; - - ang = atan((double) m->v / (double) m->u); /* calc new initial point - offset both sides of ideal */ - sang = sin(ang); - cang = cos(ang); - - if (m->oct2 == 0) { - ptx = x1 + (Sint16)lrint(offset * sang); - if (m->quad4 == 0) { - pty = y1 - (Sint16)lrint(offset * cang); - } else { - pty = y1 + (Sint16)lrint(offset * cang); - } - } else { - ptx = x1 - (Sint16)lrint(offset * cang); - if (m->quad4 == 0) { - pty = y1 + (Sint16)lrint(offset * sang); - } else { - pty = y1 - (Sint16)lrint(offset * sang); - } - } - - /* used here for constant thickness line */ - tk = (int) (4. * HYPOT(ptx - x1, pty - y1) * HYPOT(m->u, m->v)); - - if (miter == 0) { - m->first1x = -32768; - m->first1y = -32768; - m->first2x = -32768; - m->first2y = -32768; - m->last1x = -32768; - m->last1y = -32768; - m->last2x = -32768; - m->last2y = -32768; - } - ptxx = ptx; - ptxy = pty; - - for (q = 0; dd <= tk; q++) { /* outer loop, stepping perpendicular to line */ - - _murphyParaline(m, ptx, pty, d1); /* call to inner loop - right edge */ - if (q == 0) { - ml1x = ptx; - ml1y = pty; - ml1bx = m->tempx; - ml1by = m->tempy; - } else { - ml2x = ptx; - ml2y = pty; - ml2bx = m->tempx; - ml2by = m->tempy; - } - if (d0 < m->kt) { /* square move */ - if (m->oct2 == 0) { - if (m->quad4 == 0) { - pty++; - } else { - pty--; - } - } else { - ptx++; - } - } else { /* diagonal move */ - dd += m->kv; - d0 -= m->ku; - if (d1 < m->kt) { /* normal diagonal */ - if (m->oct2 == 0) { - ptx--; - if (m->quad4 == 0) { - pty++; - } else { - pty--; - } - } else { - ptx++; - if (m->quad4 == 0) { - pty--; - } else { - pty++; - } - } - d1 += m->kv; - } else { /* double square move, extra parallel line */ - if (m->oct2 == 0) { - ptx--; - } else { - if (m->quad4 == 0) { - pty--; - } else { - pty++; - } - } - d1 += m->kd; - if (dd > tk) { - _murphyIteration(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y); - return; /* breakout on the extra line */ - } - _murphyParaline(m, ptx, pty, d1); - if (m->oct2 == 0) { - if (m->quad4 == 0) { - pty++; - } else { - - pty--; - } - } else { - ptx++; - } - } - } - dd += m->ku; - d0 += m->kv; - } - - _murphyIteration(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y); -} - - -/*! -\brief Draw a thick line with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the line. -\param y1 Y coordinate of the first point of the line. -\param x2 X coordinate of the second point of the line. -\param y2 Y coordinate of the second point of the line. -\param width Width of the line in pixels. Must be >0. -\param color The color value of the line to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int thickLineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint32 color) -{ - SDL_gfxMurphyIterator m; - - if (dst == NULL) return -1; - if (width < 1) return -1; - - m.dst = dst; - m.color = color; - - _murphyWideline(&m, x1, y1, x2, y2, width, 0); - _murphyWideline(&m, x1, y1, x2, y2, width, 1); - - return(0); -} - -/*! -\brief Draw a thick line with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the line. -\param y1 Y coordinate of the first point of the line. -\param x2 X coordinate of the second point of the line. -\param y2 Y coordinate of the second point of the line. -\param width Width of the line in pixels. Must be >0. -\param r The red value of the character to draw. -\param g The green value of the character to draw. -\param b The blue value of the character to draw. -\param a The alpha value of the character to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int thickLineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - return (thickLineColor(dst, x1, y1, x2, y2, width, - ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); -} -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives.h b/src_c/SDL_gfx/SDL_gfxPrimitives.h index 5f532524e3..47eeeaf847 100644 --- a/src_c/SDL_gfx/SDL_gfxPrimitives.h +++ b/src_c/SDL_gfx/SDL_gfxPrimitives.h @@ -60,127 +60,21 @@ extern "C" { /* Pixel */ -SDL_GFXPRIMITIVES_SCOPE int -pixelColor(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -pixelRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, - Uint8 a); - /* Horizontal line */ SDL_GFXPRIMITIVES_SCOPE int hlineColor(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -hlineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, - Uint8 b, Uint8 a); /* Vertical line */ SDL_GFXPRIMITIVES_SCOPE int vlineColor(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -vlineRGBA(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, - Uint8 b, Uint8 a); - -/* Rectangle */ - -SDL_GFXPRIMITIVES_SCOPE int -rectangleColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -rectangleRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint8 r, Uint8 g, Uint8 b, Uint8 a); - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* Rounded-Corner Rectangle */ - - SDL_GFXPRIMITIVES_SCOPE int roundedRectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color); - SDL_GFXPRIMITIVES_SCOPE int roundedRectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, - Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/* Filled rectangle (Box) */ - -SDL_GFXPRIMITIVES_SCOPE int -boxColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -boxRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, - Uint8 g, Uint8 b, Uint8 a); - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* Rounded-Corner Filled rectangle (Box) */ - - SDL_GFXPRIMITIVES_SCOPE int roundedBoxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color); - SDL_GFXPRIMITIVES_SCOPE int roundedBoxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, - Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ /* Line */ SDL_GFXPRIMITIVES_SCOPE int lineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -lineRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, - Uint8 g, Uint8 b, Uint8 a); - -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* AA Line */ - - SDL_GFXPRIMITIVES_SCOPE int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); - SDL_GFXPRIMITIVES_SCOPE int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, - Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - - /* Thick Line */ - SDL_GFXPRIMITIVES_SCOPE int thickLineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint8 width, Uint32 color); - SDL_GFXPRIMITIVES_SCOPE int thickLineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/* Circle */ - -SDL_GFXPRIMITIVES_SCOPE int -circleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -circleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, - Uint8 b, Uint8 a); - -/* Arc */ - -SDL_GFXPRIMITIVES_SCOPE int -arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -arcRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - -/* AA Circle */ - -SDL_GFXPRIMITIVES_SCOPE int -aacircleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -aacircleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, - Uint8 g, Uint8 b, Uint8 a); - -/* Filled Circle */ - -SDL_GFXPRIMITIVES_SCOPE int -filledCircleColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 r, - Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -filledCircleRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, - Uint8 g, Uint8 b, Uint8 a); - -/* Ellipse */ - -SDL_GFXPRIMITIVES_SCOPE int -ellipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -ellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint8 r, Uint8 g, Uint8 b, Uint8 a); /* AA Ellipse */ @@ -191,15 +85,6 @@ SDL_GFXPRIMITIVES_SCOPE int aaellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -/* Filled Ellipse */ - -SDL_GFXPRIMITIVES_SCOPE int -filledEllipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -filledEllipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, - Uint8 r, Uint8 g, Uint8 b, Uint8 a); - /* Pie */ SDL_GFXPRIMITIVES_SCOPE int @@ -209,24 +94,6 @@ SDL_GFXPRIMITIVES_SCOPE int pieRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* Filled Pie */ - - SDL_GFXPRIMITIVES_SCOPE int filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, - Sint16 start, Sint16 end, Uint32 color); - SDL_GFXPRIMITIVES_SCOPE int filledPieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, - Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - -/* Trigon */ - -SDL_GFXPRIMITIVES_SCOPE int -trigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -trigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - /* AA-Trigon */ SDL_GFXPRIMITIVES_SCOPE int @@ -250,9 +117,6 @@ filledTrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, SDL_GFXPRIMITIVES_SCOPE int polygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -polygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint8 r, Uint8 g, Uint8 b, Uint8 a); /* AA-Polygon */ @@ -269,9 +133,6 @@ SDL_GFXPRIMITIVES_SCOPE int filledPolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color); SDL_GFXPRIMITIVES_SCOPE int -filledPolygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint8 r, Uint8 g, Uint8 b, Uint8 a); -SDL_GFXPRIMITIVES_SCOPE int texturedPolygon(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy); @@ -281,10 +142,6 @@ SDL_GFXPRIMITIVES_SCOPE int filledPolygonColorMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color, int **polyInts, int *polyAllocated); SDL_GFXPRIMITIVES_SCOPE int -filledPolygonRGBAMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, - int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a, int **polyInts, - int *polyAllocated); -SDL_GFXPRIMITIVES_SCOPE int texturedPolygonMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy, int **polyInts, int *polyAllocated); @@ -298,17 +155,6 @@ SDL_GFXPRIMITIVES_SCOPE int bezierRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -#if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* Characters/Strings */ - - SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch); - SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFontRotation(Uint32 rotation); - SDL_GFXPRIMITIVES_SCOPE int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color); - SDL_GFXPRIMITIVES_SCOPE int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - SDL_GFXPRIMITIVES_SCOPE int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint32 color); - SDL_GFXPRIMITIVES_SCOPE int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -#endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives_font.h b/src_c/SDL_gfx/SDL_gfxPrimitives_font.h deleted file mode 100644 index 911d580143..0000000000 --- a/src_c/SDL_gfx/SDL_gfxPrimitives_font.h +++ /dev/null @@ -1,3082 +0,0 @@ - -/* ---- 8x8 font definition ---- */ - -/* LGPL (c) A. Schiffler */ - -#define GFX_FONTDATAMAX (8 * 256) - -static unsigned char gfxPrimitivesFontdata[GFX_FONTDATAMAX] = { - - /* - * 0 0x00 '^@' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 1 0x01 '^A' - */ - 0x7e, /* 01111110 */ - 0x81, /* 10000001 */ - 0xa5, /* 10100101 */ - 0x81, /* 10000001 */ - 0xbd, /* 10111101 */ - 0x99, /* 10011001 */ - 0x81, /* 10000001 */ - 0x7e, /* 01111110 */ - - /* - * 2 0x02 '^B' - */ - 0x7e, /* 01111110 */ - 0xff, /* 11111111 */ - 0xdb, /* 11011011 */ - 0xff, /* 11111111 */ - 0xc3, /* 11000011 */ - 0xe7, /* 11100111 */ - 0xff, /* 11111111 */ - 0x7e, /* 01111110 */ - - /* - * 3 0x03 '^C' - */ - 0x6c, /* 01101100 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0x7c, /* 01111100 */ - 0x38, /* 00111000 */ - 0x10, /* 00010000 */ - 0x00, /* 00000000 */ - - /* - * 4 0x04 '^D' - */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x7c, /* 01111100 */ - 0xfe, /* 11111110 */ - 0x7c, /* 01111100 */ - 0x38, /* 00111000 */ - 0x10, /* 00010000 */ - 0x00, /* 00000000 */ - - /* - * 5 0x05 '^E' - */ - 0x38, /* 00111000 */ - 0x7c, /* 01111100 */ - 0x38, /* 00111000 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - - /* - * 6 0x06 '^F' - */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x7c, /* 01111100 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0x7c, /* 01111100 */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - - /* - * 7 0x07 '^G' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 8 0x08 '^H' - */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xe7, /* 11100111 */ - 0xc3, /* 11000011 */ - 0xc3, /* 11000011 */ - 0xe7, /* 11100111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - - /* - * 9 0x09 '^I' - */ - 0x00, /* 00000000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x42, /* 01000010 */ - 0x42, /* 01000010 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 10 0x0a '^J' - */ - 0xff, /* 11111111 */ - 0xc3, /* 11000011 */ - 0x99, /* 10011001 */ - 0xbd, /* 10111101 */ - 0xbd, /* 10111101 */ - 0x99, /* 10011001 */ - 0xc3, /* 11000011 */ - 0xff, /* 11111111 */ - - /* - * 11 0x0b '^K' - */ - 0x0f, /* 00001111 */ - 0x07, /* 00000111 */ - 0x0f, /* 00001111 */ - 0x7d, /* 01111101 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x78, /* 01111000 */ - - /* - * 12 0x0c '^L' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - - /* - * 13 0x0d '^M' - */ - 0x3f, /* 00111111 */ - 0x33, /* 00110011 */ - 0x3f, /* 00111111 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x70, /* 01110000 */ - 0xf0, /* 11110000 */ - 0xe0, /* 11100000 */ - - /* - * 14 0x0e '^N' - */ - 0x7f, /* 01111111 */ - 0x63, /* 01100011 */ - 0x7f, /* 01111111 */ - 0x63, /* 01100011 */ - 0x63, /* 01100011 */ - 0x67, /* 01100111 */ - 0xe6, /* 11100110 */ - 0xc0, /* 11000000 */ - - /* - * 15 0x0f '^O' - */ - 0x18, /* 00011000 */ - 0xdb, /* 11011011 */ - 0x3c, /* 00111100 */ - 0xe7, /* 11100111 */ - 0xe7, /* 11100111 */ - 0x3c, /* 00111100 */ - 0xdb, /* 11011011 */ - 0x18, /* 00011000 */ - - /* - * 16 0x10 '^P' - */ - 0x80, /* 10000000 */ - 0xe0, /* 11100000 */ - 0xf8, /* 11111000 */ - 0xfe, /* 11111110 */ - 0xf8, /* 11111000 */ - 0xe0, /* 11100000 */ - 0x80, /* 10000000 */ - 0x00, /* 00000000 */ - - /* - * 17 0x11 '^Q' - */ - 0x02, /* 00000010 */ - 0x0e, /* 00001110 */ - 0x3e, /* 00111110 */ - 0xfe, /* 11111110 */ - 0x3e, /* 00111110 */ - 0x0e, /* 00001110 */ - 0x02, /* 00000010 */ - 0x00, /* 00000000 */ - - /* - * 18 0x12 '^R' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - - /* - * 19 0x13 '^S' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - - /* - * 20 0x14 '^T' - */ - 0x7f, /* 01111111 */ - 0xdb, /* 11011011 */ - 0xdb, /* 11011011 */ - 0x7b, /* 01111011 */ - 0x1b, /* 00011011 */ - 0x1b, /* 00011011 */ - 0x1b, /* 00011011 */ - 0x00, /* 00000000 */ - - /* - * 21 0x15 '^U' - */ - 0x3e, /* 00111110 */ - 0x61, /* 01100001 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x86, /* 10000110 */ - 0x7c, /* 01111100 */ - - /* - * 22 0x16 '^V' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x7e, /* 01111110 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 23 0x17 '^W' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - - /* - * 24 0x18 '^X' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 25 0x19 '^Y' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 26 0x1a '^Z' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0xfe, /* 11111110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 27 0x1b '^[' - */ - 0x00, /* 00000000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0xfe, /* 11111110 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 28 0x1c '^\' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 29 0x1d '^]' - */ - 0x00, /* 00000000 */ - 0x24, /* 00100100 */ - 0x66, /* 01100110 */ - 0xff, /* 11111111 */ - 0x66, /* 01100110 */ - 0x24, /* 00100100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 30 0x1e '^^' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 31 0x1f '^_' - */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 32 0x20 ' ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 33 0x21 '!' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 34 0x22 '"' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x24, /* 00100100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 35 0x23 '#' - */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 36 0x24 '$' - */ - 0x18, /* 00011000 */ - 0x3e, /* 00111110 */ - 0x60, /* 01100000 */ - 0x3c, /* 00111100 */ - 0x06, /* 00000110 */ - 0x7c, /* 01111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 37 0x25 '%' - */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xcc, /* 11001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x66, /* 01100110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 38 0x26 '&' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 39 0x27 ''' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 40 0x28 '(' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x00, /* 00000000 */ - - /* - * 41 0x29 ')' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - - /* - * 42 0x2a '*' - */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0xff, /* 11111111 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 43 0x2b '+' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 44 0x2c ',' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - - /* - * 45 0x2d '-' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 46 0x2e '.' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 47 0x2f '/' - */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0xc0, /* 11000000 */ - 0x80, /* 10000000 */ - 0x00, /* 00000000 */ - - /* - * 48 0x30 '0' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 49 0x31 '1' - */ - 0x18, /* 00011000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 50 0x32 '2' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0x06, /* 00000110 */ - 0x1c, /* 00011100 */ - 0x30, /* 00110000 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 51 0x33 '3' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0x06, /* 00000110 */ - 0x3c, /* 00111100 */ - 0x06, /* 00000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 52 0x34 '4' - */ - 0x1c, /* 00011100 */ - 0x3c, /* 00111100 */ - 0x6c, /* 01101100 */ - 0xcc, /* 11001100 */ - 0xfe, /* 11111110 */ - 0x0c, /* 00001100 */ - 0x1e, /* 00011110 */ - 0x00, /* 00000000 */ - - /* - * 53 0x35 '5' - */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xfc, /* 11111100 */ - 0x06, /* 00000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 54 0x36 '6' - */ - 0x38, /* 00111000 */ - 0x60, /* 01100000 */ - 0xc0, /* 11000000 */ - 0xfc, /* 11111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 55 0x37 '7' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - - /* - * 56 0x38 '8' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 57 0x39 '9' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7e, /* 01111110 */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* - * 58 0x3a ':' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 59 0x3b ';' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - - /* - * 60 0x3c '<' - */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x06, /* 00000110 */ - 0x00, /* 00000000 */ - - /* - * 61 0x3d '=' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 62 0x3e '>' - */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0x00, /* 00000000 */ - - /* - * 63 0x3f '?' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 64 0x40 '@' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xde, /* 11011110 */ - 0xde, /* 11011110 */ - 0xde, /* 11011110 */ - 0xc0, /* 11000000 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* - * 65 0x41 'A' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 66 0x42 'B' - */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* - * 67 0x43 'C' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 68 0x44 'D' - */ - 0xf8, /* 11111000 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0xf8, /* 11111000 */ - 0x00, /* 00000000 */ - - /* - * 69 0x45 'E' - */ - 0xfe, /* 11111110 */ - 0x62, /* 01100010 */ - 0x68, /* 01101000 */ - 0x78, /* 01111000 */ - 0x68, /* 01101000 */ - 0x62, /* 01100010 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 70 0x46 'F' - */ - 0xfe, /* 11111110 */ - 0x62, /* 01100010 */ - 0x68, /* 01101000 */ - 0x78, /* 01111000 */ - 0x68, /* 01101000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 71 0x47 'G' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xce, /* 11001110 */ - 0x66, /* 01100110 */ - 0x3a, /* 00111010 */ - 0x00, /* 00000000 */ - - /* - * 72 0x48 'H' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 73 0x49 'I' - */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 74 0x4a 'J' - */ - 0x1e, /* 00011110 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* - * 75 0x4b 'K' - */ - 0xe6, /* 11100110 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0x78, /* 01111000 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 76 0x4c 'L' - */ - 0xf0, /* 11110000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0x62, /* 01100010 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 77 0x4d 'M' - */ - 0xc6, /* 11000110 */ - 0xee, /* 11101110 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 78 0x4e 'N' - */ - 0xc6, /* 11000110 */ - 0xe6, /* 11100110 */ - 0xf6, /* 11110110 */ - 0xde, /* 11011110 */ - 0xce, /* 11001110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 79 0x4f 'O' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 80 0x50 'P' - */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 81 0x51 'Q' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xce, /* 11001110 */ - 0x7c, /* 01111100 */ - 0x0e, /* 00001110 */ - - /* - * 82 0x52 'R' - */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 83 0x53 'S' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 84 0x54 'T' - */ - 0x7e, /* 01111110 */ - 0x7e, /* 01111110 */ - 0x5a, /* 01011010 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 85 0x55 'U' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 86 0x56 'V' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 87 0x57 'W' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 88 0x58 'X' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 89 0x59 'Y' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 90 0x5a 'Z' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x8c, /* 10001100 */ - 0x18, /* 00011000 */ - 0x32, /* 00110010 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 91 0x5b '[' - */ - 0x3c, /* 00111100 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 92 0x5c '\' - */ - 0xc0, /* 11000000 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x06, /* 00000110 */ - 0x02, /* 00000010 */ - 0x00, /* 00000000 */ - - /* - * 93 0x5d ']' - */ - 0x3c, /* 00111100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 94 0x5e '^' - */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 95 0x5f '_' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - - /* - * 96 0x60 '`' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 97 0x61 'a' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 98 0x62 'b' - */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x7c, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - - /* - * 99 0x63 'c' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc0, /* 11000000 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 100 0x64 'd' - */ - 0x1c, /* 00011100 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 101 0x65 'e' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 102 0x66 'f' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x60, /* 01100000 */ - 0xf8, /* 11111000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 103 0x67 'g' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0xf8, /* 11111000 */ - - /* - * 104 0x68 'h' - */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x6c, /* 01101100 */ - 0x76, /* 01110110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 105 0x69 'i' - */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 106 0x6a 'j' - */ - 0x06, /* 00000110 */ - 0x00, /* 00000000 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - - /* - * 107 0x6b 'k' - */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0x78, /* 01111000 */ - 0x6c, /* 01101100 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 108 0x6c 'l' - */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 109 0x6d 'm' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xec, /* 11101100 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0x00, /* 00000000 */ - - /* - * 110 0x6e 'n' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - - /* - * 111 0x6f 'o' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 112 0x70 'p' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - - /* - * 113 0x71 'q' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0x1e, /* 00011110 */ - - /* - * 114 0x72 'r' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x76, /* 01110110 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 115 0x73 's' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* - * 116 0x74 't' - */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0xfc, /* 11111100 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x36, /* 00110110 */ - 0x1c, /* 00011100 */ - 0x00, /* 00000000 */ - - /* - * 117 0x75 'u' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 118 0x76 'v' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 119 0x77 'w' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 120 0x78 'x' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 121 0x79 'y' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7e, /* 01111110 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - - /* - * 122 0x7a 'z' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x4c, /* 01001100 */ - 0x18, /* 00011000 */ - 0x32, /* 00110010 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 123 0x7b '{' - */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x70, /* 01110000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x0e, /* 00001110 */ - 0x00, /* 00000000 */ - - /* - * 124 0x7c '|' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 125 0x7d '}' - */ - 0x70, /* 01110000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x70, /* 01110000 */ - 0x00, /* 00000000 */ - - /* - * 126 0x7e '~' - */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 127 0x7f '' - */ - 0x00, /* 00000000 */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 128 0x80 '€' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0x78, /* 01111000 */ - - /* - * 129 0x81 '' - */ - 0xcc, /* 11001100 */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 130 0x82 '‚' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 131 0x83 'ƒ' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 132 0x84 '„' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 133 0x85 '…' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 134 0x86 '†' - */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 135 0x87 '‡' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x7e, /* 01111110 */ - 0x0c, /* 00001100 */ - 0x38, /* 00111000 */ - - /* - * 136 0x88 'ˆ' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 137 0x89 '‰' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 138 0x8a 'Š' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 139 0x8b '‹' - */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 140 0x8c 'Œ' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 141 0x8d '' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 142 0x8e 'Ž' - */ - 0xc6, /* 11000110 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 143 0x8f '' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 144 0x90 '' - */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0xf8, /* 11111000 */ - 0xc0, /* 11000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 145 0x91 '‘' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0xd8, /* 11011000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 146 0x92 '’' - */ - 0x3e, /* 00111110 */ - 0x6c, /* 01101100 */ - 0xcc, /* 11001100 */ - 0xfe, /* 11111110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xce, /* 11001110 */ - 0x00, /* 00000000 */ - - /* - * 147 0x93 '“' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 148 0x94 '”' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 149 0x95 '•' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 150 0x96 '–' - */ - 0x78, /* 01111000 */ - 0x84, /* 10000100 */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 151 0x97 '—' - */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 152 0x98 '˜' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7e, /* 01111110 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - - /* - * 153 0x99 '™' - */ - 0xc6, /* 11000110 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 154 0x9a 'š' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 155 0x9b '›' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 156 0x9c 'œ' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x64, /* 01100100 */ - 0xf0, /* 11110000 */ - 0x60, /* 01100000 */ - 0x66, /* 01100110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* - * 157 0x9d '' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 158 0x9e 'ž' - */ - 0xf8, /* 11111000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xfa, /* 11111010 */ - 0xc6, /* 11000110 */ - 0xcf, /* 11001111 */ - 0xc6, /* 11000110 */ - 0xc7, /* 11000111 */ - - /* - * 159 0x9f 'Ÿ' - */ - 0x0e, /* 00001110 */ - 0x1b, /* 00011011 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0xd8, /* 11011000 */ - 0x70, /* 01110000 */ - 0x00, /* 00000000 */ - - /* - * 160 0xa0 ' ' - */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 161 0xa1 '¡' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 162 0xa2 '¢' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 163 0xa3 '£' - */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 164 0xa4 '¤' - */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - - /* - * 165 0xa5 '¥' - */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0xe6, /* 11100110 */ - 0xf6, /* 11110110 */ - 0xde, /* 11011110 */ - 0xce, /* 11001110 */ - 0x00, /* 00000000 */ - - /* - * 166 0xa6 '¦' - */ - 0x3c, /* 00111100 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x3e, /* 00111110 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 167 0xa7 '§' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 168 0xa8 '¨' - */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x63, /* 01100011 */ - 0x3e, /* 00111110 */ - 0x00, /* 00000000 */ - - /* - * 169 0xa9 '©' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 170 0xaa 'ª' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 171 0xab '«' - */ - 0x63, /* 01100011 */ - 0xe6, /* 11100110 */ - 0x6c, /* 01101100 */ - 0x7e, /* 01111110 */ - 0x33, /* 00110011 */ - 0x66, /* 01100110 */ - 0xcc, /* 11001100 */ - 0x0f, /* 00001111 */ - - /* - * 172 0xac '¬' - */ - 0x63, /* 01100011 */ - 0xe6, /* 11100110 */ - 0x6c, /* 01101100 */ - 0x7a, /* 01111010 */ - 0x36, /* 00110110 */ - 0x6a, /* 01101010 */ - 0xdf, /* 11011111 */ - 0x06, /* 00000110 */ - - /* - * 173 0xad '­' - */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 174 0xae '®' - */ - 0x00, /* 00000000 */ - 0x33, /* 00110011 */ - 0x66, /* 01100110 */ - 0xcc, /* 11001100 */ - 0x66, /* 01100110 */ - 0x33, /* 00110011 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 175 0xaf '¯' - */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0x66, /* 01100110 */ - 0x33, /* 00110011 */ - 0x66, /* 01100110 */ - 0xcc, /* 11001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 176 0xb0 '°' - */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - - /* - * 177 0xb1 '±' - */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - - /* - * 178 0xb2 '²' - */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - - /* - * 179 0xb3 '³' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 180 0xb4 '´' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 181 0xb5 'µ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 182 0xb6 '¶' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf6, /* 11110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 183 0xb7 '·' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 184 0xb8 '¸' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 185 0xb9 '¹' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf6, /* 11110110 */ - 0x06, /* 00000110 */ - 0xf6, /* 11110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 186 0xba 'º' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 187 0xbb '»' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x06, /* 00000110 */ - 0xf6, /* 11110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 188 0xbc '¼' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf6, /* 11110110 */ - 0x06, /* 00000110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 189 0xbd '½' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 190 0xbe '¾' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 191 0xbf '¿' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 192 0xc0 'À' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 193 0xc1 'Á' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 194 0xc2 'Â' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 195 0xc3 'Ã' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 196 0xc4 'Ä' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 197 0xc5 'Å' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 198 0xc6 'Æ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 199 0xc7 'Ç' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x37, /* 00110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 200 0xc8 'È' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x37, /* 00110111 */ - 0x30, /* 00110000 */ - 0x3f, /* 00111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 201 0xc9 'É' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 00111111 */ - 0x30, /* 00110000 */ - 0x37, /* 00110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 202 0xca 'Ê' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf7, /* 11110111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 203 0xcb 'Ë' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xf7, /* 11110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 204 0xcc 'Ì' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x37, /* 00110111 */ - 0x30, /* 00110000 */ - 0x37, /* 00110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 205 0xcd 'Í' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 206 0xce 'Î' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf7, /* 11110111 */ - 0x00, /* 00000000 */ - 0xf7, /* 11110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 207 0xcf 'Ï' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 208 0xd0 'Ð' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 209 0xd1 'Ñ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 210 0xd2 'Ò' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 211 0xd3 'Ó' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x3f, /* 00111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 212 0xd4 'Ô' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 213 0xd5 'Õ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 214 0xd6 'Ö' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 00111111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 215 0xd7 '×' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xff, /* 11111111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 216 0xd8 'Ø' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 217 0xd9 'Ù' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 218 0xda 'Ú' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 219 0xdb 'Û' - */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - - /* - * 220 0xdc 'Ü' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - - /* - * 221 0xdd 'Ý' - */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - - /* - * 222 0xde 'Þ' - */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - - /* - * 223 0xdf 'ß' - */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 224 0xe0 'à' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0xc8, /* 11001000 */ - 0xdc, /* 11011100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 225 0xe1 'á' - */ - 0x78, /* 01111000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xd8, /* 11011000 */ - 0xcc, /* 11001100 */ - 0xc6, /* 11000110 */ - 0xcc, /* 11001100 */ - 0x00, /* 00000000 */ - - /* - * 226 0xe2 'â' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x00, /* 00000000 */ - - /* - * 227 0xe3 'ã' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 228 0xe4 'ä' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 229 0xe5 'å' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xd8, /* 11011000 */ - 0xd8, /* 11011000 */ - 0xd8, /* 11011000 */ - 0x70, /* 01110000 */ - 0x00, /* 00000000 */ - - /* - * 230 0xe6 'æ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0xc0, /* 11000000 */ - - /* - * 231 0xe7 'ç' - */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 232 0xe8 'è' - */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - - /* - * 233 0xe9 'é' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 234 0xea 'ê' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0xee, /* 11101110 */ - 0x00, /* 00000000 */ - - /* - * 235 0xeb 'ë' - */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x3e, /* 00111110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 236 0xec 'ì' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xdb, /* 11011011 */ - 0xdb, /* 11011011 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 237 0xed 'í' - */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x7e, /* 01111110 */ - 0xdb, /* 11011011 */ - 0xdb, /* 11011011 */ - 0x7e, /* 01111110 */ - 0x60, /* 01100000 */ - 0xc0, /* 11000000 */ - - /* - * 238 0xee 'î' - */ - 0x1e, /* 00011110 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0x7e, /* 01111110 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x1e, /* 00011110 */ - 0x00, /* 00000000 */ - - /* - * 239 0xef 'ï' - */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 240 0xf0 'ð' - */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 241 0xf1 'ñ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 242 0xf2 'ò' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 243 0xf3 'ó' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 244 0xf4 'ô' - */ - 0x0e, /* 00001110 */ - 0x1b, /* 00011011 */ - 0x1b, /* 00011011 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 245 0xf5 'õ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xd8, /* 11011000 */ - 0xd8, /* 11011000 */ - 0x70, /* 01110000 */ - - /* - * 246 0xf6 'ö' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 247 0xf7 '÷' - */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 248 0xf8 'ø' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 249 0xf9 'ù' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 250 0xfa 'ú' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 251 0xfb 'û' - */ - 0x0f, /* 00001111 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0xec, /* 11101100 */ - 0x6c, /* 01101100 */ - 0x3c, /* 00111100 */ - 0x1c, /* 00011100 */ - - /* - * 252 0xfc 'ü' - */ - 0x6c, /* 01101100 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 253 0xfd 'ý' - */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 254 0xfe 'þ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 255 0xff ' ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - -}; diff --git a/src_c/_gfxdraw.c b/src_c/_gfxdraw.c new file mode 100644 index 0000000000..b6e27c31b4 --- /dev/null +++ b/src_c/_gfxdraw.c @@ -0,0 +1,447 @@ +/* + pygame-ce - Python Game Library + Copyright (C) 2008 Marcus von Appen + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ +/* + This is a proposed SDL_gfx draw module for Pygame. It is backported + from Pygame 2. + + TODO: + - do a filled pie version using filledPieColor + - Determine if SDL video must be initiated for all routines to work. + Add check if required, else remove ASSERT_VIDEO_INIT. + - Example (Maybe). +*/ +#define PYGAME_SDLGFXPRIM_INTERNAL + +#include "pygame.h" + +#include "doc/gfxdraw_doc.h" + +#include "surface.h" + +#include "pgcompat.h" + +#include "SDL_gfx/SDL_gfxPrimitives.h" + +static PyObject * +_gfx_aaellipsecolor(PyObject *self, PyObject *args); +static PyObject * +_gfx_piecolor(PyObject *self, PyObject *args); +static PyObject * +_gfx_aatrigoncolor(PyObject *self, PyObject *args); +static PyObject * +_gfx_aapolygoncolor(PyObject *self, PyObject *args); +static PyObject * +_gfx_texturedpolygon(PyObject *self, PyObject *args); +static PyObject * +_gfx_beziercolor(PyObject *self, PyObject *args); + +static PyMethodDef _gfxdraw_methods[] = { + {"aaellipse", _gfx_aaellipsecolor, METH_VARARGS, DOC_GFXDRAW_AAELLIPSE}, + {"pie", _gfx_piecolor, METH_VARARGS, DOC_GFXDRAW_PIE}, + {"aatrigon", _gfx_aatrigoncolor, METH_VARARGS, DOC_GFXDRAW_AATRIGON}, + {"aapolygon", _gfx_aapolygoncolor, METH_VARARGS, DOC_GFXDRAW_AAPOLYGON}, + {"textured_polygon", _gfx_texturedpolygon, METH_VARARGS, + DOC_GFXDRAW_TEXTUREDPOLYGON}, + {"bezier", _gfx_beziercolor, METH_VARARGS, DOC_GFXDRAW_BEZIER}, + {NULL, NULL, 0, NULL}, +}; + +#define ASSERT_VIDEO_INIT(unused) /* Is video really needed for gfxdraw? */ + +static int +Sint16FromObj(PyObject *item, Sint16 *val) +{ + if (PyNumber_Check(item)) { + PyObject *intobj; + long tmp; + + if (!(intobj = PyNumber_Long(item))) + return 0; + tmp = PyLong_AsLong(intobj); + Py_DECREF(intobj); + if (tmp == -1 && PyErr_Occurred()) + return 0; + *val = (Sint16)tmp; + return 1; + } + return 0; +} + +static int +Sint16FromSeqIndex(PyObject *obj, Py_ssize_t _index, Sint16 *val) +{ + int result = 0; + PyObject *item; + item = PySequence_GetItem(obj, _index); + if (item) { + result = Sint16FromObj(item, val); + Py_DECREF(item); + } + return result; +} + +static PyObject * +_gfx_aaellipsecolor(PyObject *self, PyObject *args) +{ + PyObject *surface, *color; + Sint16 x, y, rx, ry; + Uint8 rgba[4]; + + ASSERT_VIDEO_INIT(NULL); + + if (!PyArg_ParseTuple(args, "OhhhhO:aaellipse", &surface, &x, &y, &rx, &ry, + &color)) + return NULL; + + if (!pgSurface_Check(surface)) { + return RAISE(PyExc_TypeError, "surface must be a Surface"); + } + if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { + return NULL; + } + + if (aaellipseRGBA(pgSurface_AsSurface(surface), x, y, rx, ry, rgba[0], + rgba[1], rgba[2], rgba[3]) == -1) { + return RAISE(pgExc_SDLError, SDL_GetError()); + } + Py_RETURN_NONE; +} + +static PyObject * +_gfx_piecolor(PyObject *self, PyObject *args) +{ + PyObject *surface, *color; + Sint16 x, y, r, start, end; + Uint8 rgba[4]; + + ASSERT_VIDEO_INIT(NULL); + + if (!PyArg_ParseTuple(args, "OhhhhhO:pie", &surface, &x, &y, &r, &start, + &end, &color)) + return NULL; + + if (!pgSurface_Check(surface)) { + return RAISE(PyExc_TypeError, "surface must be a Surface"); + } + if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { + return NULL; + } + + if (pieRGBA(pgSurface_AsSurface(surface), x, y, r, start, end, rgba[0], + rgba[1], rgba[2], rgba[3]) == -1) { + return RAISE(pgExc_SDLError, SDL_GetError()); + } + Py_RETURN_NONE; +} + +static PyObject * +_gfx_aatrigoncolor(PyObject *self, PyObject *args) +{ + PyObject *surface, *color; + Sint16 x1, x2, x3, _y1, y2, y3; + Uint8 rgba[4]; + + ASSERT_VIDEO_INIT(NULL); + + if (!PyArg_ParseTuple(args, "OhhhhhhO:aatrigon", &surface, &x1, &_y1, &x2, + &y2, &x3, &y3, &color)) + return NULL; + + if (!pgSurface_Check(surface)) { + return RAISE(PyExc_TypeError, "surface must be a Surface"); + } + if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { + return NULL; + } + + if (aatrigonRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, x3, y3, + rgba[0], rgba[1], rgba[2], rgba[3]) == -1) { + return RAISE(pgExc_SDLError, SDL_GetError()); + } + Py_RETURN_NONE; +} + +static PyObject * +_gfx_aapolygoncolor(PyObject *self, PyObject *args) +{ + PyObject *surface, *color, *points, *item; + Sint16 *vx, *vy, x, y; + Py_ssize_t count, i; + int ret; + Uint8 rgba[4]; + + ASSERT_VIDEO_INIT(NULL); + + if (!PyArg_ParseTuple(args, "OOO:aapolygon", &surface, &points, &color)) + return NULL; + + if (!pgSurface_Check(surface)) { + return RAISE(PyExc_TypeError, "surface must be a Surface"); + } + if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { + return NULL; + } + if (!PySequence_Check(points)) { + return RAISE(PyExc_TypeError, "points must be a sequence"); + } + + count = PySequence_Size(points); + if (count < 3) { + return RAISE(PyExc_ValueError, + "points must contain more than 2 points"); + } + + vx = PyMem_New(Sint16, (size_t)count); + vy = PyMem_New(Sint16, (size_t)count); + if (!vx || !vy) { + if (vx) + PyMem_Free(vx); + if (vy) + PyMem_Free(vy); + return NULL; + } + + for (i = 0; i < count; i++) { + item = PySequence_ITEM(points, i); + if (!Sint16FromSeqIndex(item, 0, &x)) { + PyMem_Free(vx); + PyMem_Free(vy); + Py_XDECREF(item); + return NULL; + } + if (!Sint16FromSeqIndex(item, 1, &y)) { + PyMem_Free(vx); + PyMem_Free(vy); + Py_XDECREF(item); + return NULL; + } + Py_DECREF(item); + vx[i] = x; + vy[i] = y; + } + + Py_BEGIN_ALLOW_THREADS; + ret = aapolygonRGBA(pgSurface_AsSurface(surface), vx, vy, (int)count, + rgba[0], rgba[1], rgba[2], rgba[3]); + Py_END_ALLOW_THREADS; + + PyMem_Free(vx); + PyMem_Free(vy); + + if (ret == -1) { + return RAISE(pgExc_SDLError, SDL_GetError()); + } + Py_RETURN_NONE; +} + +static PyObject * +_gfx_texturedpolygon(PyObject *self, PyObject *args) +{ + PyObject *surface, *texture, *points, *item; + SDL_Surface *s_surface, *s_texture; + Sint16 *vx, *vy, x, y, tdx, tdy; + Py_ssize_t count, i; + int ret; + + ASSERT_VIDEO_INIT(NULL); + + if (!PyArg_ParseTuple(args, "OOOhh:textured_polygon", &surface, &points, + &texture, &tdx, &tdy)) + return NULL; + + if (!pgSurface_Check(surface)) { + return RAISE(PyExc_TypeError, "surface must be a Surface"); + } + s_surface = pgSurface_AsSurface(surface); + if (!pgSurface_Check(texture)) { + return RAISE(PyExc_TypeError, "texture must be a Surface"); + } + s_texture = pgSurface_AsSurface(texture); + if (!PySequence_Check(points)) { + return RAISE(PyExc_TypeError, "points must be a sequence"); + } + if (PG_SURF_BytesPerPixel(s_surface) == 1 && + (s_texture->format->Amask || s_texture->flags & SDL_SRCALPHA)) { + return RAISE(PyExc_ValueError, + "Per-byte alpha texture unsupported " + "for 8 bit surfaces"); + } + + count = PySequence_Size(points); + if (count < 3) { + return RAISE(PyExc_ValueError, + "points must contain more than 2 points"); + } + + vx = PyMem_New(Sint16, (size_t)count); + vy = PyMem_New(Sint16, (size_t)count); + if (!vx || !vy) { + if (vx) + PyMem_Free(vx); + if (vy) + PyMem_Free(vy); + return NULL; + } + + for (i = 0; i < count; i++) { + item = PySequence_ITEM(points, i); + if (!Sint16FromSeqIndex(item, 0, &x)) { + PyMem_Free(vx); + PyMem_Free(vy); + Py_XDECREF(item); + return NULL; + } + if (!Sint16FromSeqIndex(item, 1, &y)) { + PyMem_Free(vx); + PyMem_Free(vy); + Py_XDECREF(item); + return NULL; + } + Py_DECREF(item); + vx[i] = x; + vy[i] = y; + } + + Py_BEGIN_ALLOW_THREADS; + ret = texturedPolygon(s_surface, vx, vy, (int)count, s_texture, tdx, tdy); + Py_END_ALLOW_THREADS; + + PyMem_Free(vx); + PyMem_Free(vy); + + if (ret == -1) { + return RAISE(pgExc_SDLError, SDL_GetError()); + } + Py_RETURN_NONE; +} + +static PyObject * +_gfx_beziercolor(PyObject *self, PyObject *args) +{ + PyObject *surface, *color, *points, *item; + Sint16 *vx, *vy, x, y; + Py_ssize_t count, i; + int ret, steps; + Uint8 rgba[4]; + + ASSERT_VIDEO_INIT(NULL); + + if (!PyArg_ParseTuple(args, "OOiO:bezier", &surface, &points, &steps, + &color)) + return NULL; + + if (!pgSurface_Check(surface)) { + return RAISE(PyExc_TypeError, "surface must be a Surface"); + } + if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { + return NULL; + } + if (!PySequence_Check(points)) { + return RAISE(PyExc_TypeError, "points must be a sequence"); + } + + count = PySequence_Size(points); + if (count < 3) { + return RAISE(PyExc_ValueError, + "points must contain more than 2 points"); + } + + if (steps < 2) { + return RAISE(PyExc_ValueError, + "steps parameter must be greater than 1"); + } + + vx = PyMem_New(Sint16, (size_t)count); + vy = PyMem_New(Sint16, (size_t)count); + if (!vx || !vy) { + if (vx) + PyMem_Free(vx); + if (vy) + PyMem_Free(vy); + return RAISE(PyExc_MemoryError, "memory allocation failed"); + } + + for (i = 0; i < count; i++) { + item = PySequence_ITEM(points, i); + if (!Sint16FromSeqIndex(item, 0, &x)) { + PyMem_Free(vx); + PyMem_Free(vy); + Py_XDECREF(item); + return NULL; + } + if (!Sint16FromSeqIndex(item, 1, &y)) { + PyMem_Free(vx); + PyMem_Free(vy); + Py_XDECREF(item); + return NULL; + } + Py_DECREF(item); + vx[i] = x; + vy[i] = y; + } + + Py_BEGIN_ALLOW_THREADS; + ret = bezierRGBA(pgSurface_AsSurface(surface), vx, vy, (int)count, steps, + rgba[0], rgba[1], rgba[2], rgba[3]); + Py_END_ALLOW_THREADS; + + PyMem_Free(vx); + PyMem_Free(vy); + + if (ret == -1) { + return RAISE(pgExc_SDLError, SDL_GetError()); + } + Py_RETURN_NONE; +} + +MODINIT_DEFINE(_gfxdraw) +{ + static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT, + "_gfxdraw", + DOC_GFXDRAW, + -1, + _gfxdraw_methods, + NULL, + NULL, + NULL, + NULL}; + + /* import needed APIs; Do this first so if there is an error + the module is not loaded. + */ + import_pygame_base(); + if (PyErr_Occurred()) { + return NULL; + } + import_pygame_color(); + if (PyErr_Occurred()) { + return NULL; + } + import_pygame_rect(); + if (PyErr_Occurred()) { + return NULL; + } + import_pygame_surface(); + if (PyErr_Occurred()) { + return NULL; + } + + return PyModule_Create(&_module); +} diff --git a/src_c/gfxdraw.c b/src_c/gfxdraw.c deleted file mode 100644 index c3ded48fd8..0000000000 --- a/src_c/gfxdraw.c +++ /dev/null @@ -1,1045 +0,0 @@ -/* - pygame-ce - Python Game Library - Copyright (C) 2008 Marcus von Appen - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ -/* - This is a proposed SDL_gfx draw module for Pygame. It is backported - from Pygame 2. - - TODO: - - fix filledPolygonRGBA to use MT versions for threaded use. - - do a filled pie version using filledPieColor - - Determine if SDL video must be initiated for all routines to work. - Add check if required, else remove ASSERT_VIDEO_INIT. - - Example (Maybe). -*/ -#define PYGAME_SDLGFXPRIM_INTERNAL - -#include "pygame.h" - -#include "doc/gfxdraw_doc.h" - -#include "surface.h" - -#include "pgcompat.h" - -#include "SDL_gfx/SDL_gfxPrimitives.h" - -static PyObject * -_gfx_pixelcolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_hlinecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_vlinecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_rectanglecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_boxcolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_linecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_circlecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_arccolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_aacirclecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_filledcirclecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_ellipsecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_aaellipsecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_filledellipsecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_piecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_trigoncolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_aatrigoncolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_filledtrigoncolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_polygoncolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_aapolygoncolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_filledpolygoncolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_texturedpolygon(PyObject *self, PyObject *args); -static PyObject * -_gfx_beziercolor(PyObject *self, PyObject *args); - -static PyMethodDef _gfxdraw_methods[] = { - {"pixel", _gfx_pixelcolor, METH_VARARGS, DOC_GFXDRAW_PIXEL}, - {"hline", _gfx_hlinecolor, METH_VARARGS, DOC_GFXDRAW_HLINE}, - {"vline", _gfx_vlinecolor, METH_VARARGS, DOC_GFXDRAW_VLINE}, - {"rectangle", _gfx_rectanglecolor, METH_VARARGS, DOC_GFXDRAW_RECTANGLE}, - {"box", _gfx_boxcolor, METH_VARARGS, DOC_GFXDRAW_RECTANGLE}, - {"line", _gfx_linecolor, METH_VARARGS, DOC_GFXDRAW_LINE}, - {"circle", _gfx_circlecolor, METH_VARARGS, DOC_GFXDRAW_CIRCLE}, - {"arc", _gfx_arccolor, METH_VARARGS, DOC_GFXDRAW_ARC}, - {"aacircle", _gfx_aacirclecolor, METH_VARARGS, DOC_GFXDRAW_AACIRCLE}, - {"filled_circle", _gfx_filledcirclecolor, METH_VARARGS, - DOC_GFXDRAW_FILLEDCIRCLE}, - {"ellipse", _gfx_ellipsecolor, METH_VARARGS, DOC_GFXDRAW_ELLIPSE}, - {"aaellipse", _gfx_aaellipsecolor, METH_VARARGS, DOC_GFXDRAW_AAELLIPSE}, - {"filled_ellipse", _gfx_filledellipsecolor, METH_VARARGS, - DOC_GFXDRAW_FILLEDELLIPSE}, - {"pie", _gfx_piecolor, METH_VARARGS, DOC_GFXDRAW_PIE}, - {"trigon", _gfx_trigoncolor, METH_VARARGS, DOC_GFXDRAW_TRIGON}, - {"aatrigon", _gfx_aatrigoncolor, METH_VARARGS, DOC_GFXDRAW_AATRIGON}, - {"filled_trigon", _gfx_filledtrigoncolor, METH_VARARGS, - DOC_GFXDRAW_FILLEDTRIGON}, - {"polygon", _gfx_polygoncolor, METH_VARARGS, DOC_GFXDRAW_POLYGON}, - {"aapolygon", _gfx_aapolygoncolor, METH_VARARGS, DOC_GFXDRAW_AAPOLYGON}, - {"filled_polygon", _gfx_filledpolygoncolor, METH_VARARGS, - DOC_GFXDRAW_FILLEDPOLYGON}, - {"textured_polygon", _gfx_texturedpolygon, METH_VARARGS, - DOC_GFXDRAW_TEXTUREDPOLYGON}, - {"bezier", _gfx_beziercolor, METH_VARARGS, DOC_GFXDRAW_BEZIER}, - {NULL, NULL, 0, NULL}, -}; - -#define ASSERT_VIDEO_INIT(unused) /* Is video really needed for gfxdraw? */ - -static int -Sint16FromObj(PyObject *item, Sint16 *val) -{ - if (PyNumber_Check(item)) { - PyObject *intobj; - long tmp; - - if (!(intobj = PyNumber_Long(item))) - return 0; - tmp = PyLong_AsLong(intobj); - Py_DECREF(intobj); - if (tmp == -1 && PyErr_Occurred()) - return 0; - *val = (Sint16)tmp; - return 1; - } - return 0; -} - -static int -Sint16FromSeqIndex(PyObject *obj, Py_ssize_t _index, Sint16 *val) -{ - int result = 0; - PyObject *item; - item = PySequence_GetItem(obj, _index); - if (item) { - result = Sint16FromObj(item, val); - Py_DECREF(item); - } - return result; -} - -static PyObject * -_gfx_pixelcolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhO:pixel", &surface, &x, &y, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (pixelRGBA(pgSurface_AsSurface(surface), x, y, rgba[0], rgba[1], - rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_hlinecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x1, x2, y; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhO:hline", &surface, &x1, &x2, &y, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (hlineRGBA(pgSurface_AsSurface(surface), x1, x2, y, rgba[0], rgba[1], - rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_vlinecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, _y1, y2; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhO:vline", &surface, &x, &_y1, &y2, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (vlineRGBA(pgSurface_AsSurface(surface), x, _y1, y2, rgba[0], rgba[1], - rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_rectanglecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color, *rect; - SDL_Rect temprect, *sdlrect; - Sint16 x1, x2, _y1, y2; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOO:rectangle", &surface, &rect, &color)) { - /* Exception already set */ - return NULL; - } - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - sdlrect = pgRect_FromObject(rect, &temprect); - if (sdlrect == NULL) { - return RAISE(PyExc_TypeError, "invalid rect style argument"); - } - - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - x1 = sdlrect->x; - _y1 = sdlrect->y; - x2 = (Sint16)(sdlrect->x + sdlrect->w - 1); - y2 = (Sint16)(sdlrect->y + sdlrect->h - 1); - - if (rectangleRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_boxcolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color, *rect; - SDL_Rect temprect, *sdlrect; - Sint16 x1, x2, _y1, y2; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOO:box", &surface, &rect, &color)) { - /* Exception already set */ - return NULL; - } - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - sdlrect = pgRect_FromObject(rect, &temprect); - if (sdlrect == NULL) { - return RAISE(PyExc_TypeError, "invalid rect style argument"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - x1 = sdlrect->x; - _y1 = sdlrect->y; - x2 = (Sint16)(sdlrect->x + sdlrect->w - 1); - y2 = (Sint16)(sdlrect->y + sdlrect->h - 1); - - if (boxRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_linecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x1, x2, _y1, y2; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhO:line", &surface, &x1, &_y1, &x2, &y2, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (lineRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_circlecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, r; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhO:circle", &surface, &x, &y, &r, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (circleRGBA(pgSurface_AsSurface(surface), x, y, r, rgba[0], rgba[1], - rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_arccolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, r, start, end; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhhO:arc", &surface, &x, &y, &r, &start, - &end, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (arcRGBA(pgSurface_AsSurface(surface), x, y, r, start, end, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_aacirclecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, r; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhO:aacircle", &surface, &x, &y, &r, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (aacircleRGBA(pgSurface_AsSurface(surface), x, y, r, rgba[0], rgba[1], - rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_filledcirclecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, r; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhO:filledcircle", &surface, &x, &y, &r, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (filledCircleRGBA(pgSurface_AsSurface(surface), x, y, r, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_ellipsecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, rx, ry; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhO:ellipse", &surface, &x, &y, &rx, &ry, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (ellipseRGBA(pgSurface_AsSurface(surface), x, y, rx, ry, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_aaellipsecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, rx, ry; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhO:aaellipse", &surface, &x, &y, &rx, &ry, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (aaellipseRGBA(pgSurface_AsSurface(surface), x, y, rx, ry, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_filledellipsecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, rx, ry; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhO:filled_ellipse", &surface, &x, &y, &rx, - &ry, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (filledEllipseRGBA(pgSurface_AsSurface(surface), x, y, rx, ry, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_piecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, r, start, end; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhhO:pie", &surface, &x, &y, &r, &start, - &end, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (pieRGBA(pgSurface_AsSurface(surface), x, y, r, start, end, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_trigoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x1, x2, x3, _y1, y2, y3; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhhhO:trigon", &surface, &x1, &_y1, &x2, - &y2, &x3, &y3, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (trigonRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, x3, y3, - rgba[0], rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_aatrigoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x1, x2, x3, _y1, y2, y3; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhhhO:aatrigon", &surface, &x1, &_y1, &x2, - &y2, &x3, &y3, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (aatrigonRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, x3, y3, - rgba[0], rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_filledtrigoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x1, x2, x3, _y1, y2, y3; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhhhO:filled_trigon", &surface, &x1, &_y1, - &x2, &y2, &x3, &y3, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (filledTrigonRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, x3, y3, - rgba[0], rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_polygoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color, *points, *item; - Sint16 *vx, *vy, x, y; - Py_ssize_t count, i; - int ret; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOO:polygon", &surface, &points, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - if (!PySequence_Check(points)) { - return RAISE(PyExc_TypeError, "points must be a sequence"); - } - - count = PySequence_Size(points); - if (count < 3) { - return RAISE(PyExc_ValueError, - "points must contain more than 2 points"); - } - - vx = PyMem_New(Sint16, (size_t)count); - vy = PyMem_New(Sint16, (size_t)count); - if (!vx || !vy) { - if (vx) - PyMem_Free(vx); - if (vy) - PyMem_Free(vy); - return NULL; - } - - for (i = 0; i < count; i++) { - item = PySequence_ITEM(points, i); - if (!Sint16FromSeqIndex(item, 0, &x)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - if (!Sint16FromSeqIndex(item, 1, &y)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - Py_DECREF(item); - vx[i] = x; - vy[i] = y; - } - - Py_BEGIN_ALLOW_THREADS; - ret = polygonRGBA(pgSurface_AsSurface(surface), vx, vy, (int)count, - rgba[0], rgba[1], rgba[2], rgba[3]); - Py_END_ALLOW_THREADS; - - PyMem_Free(vx); - PyMem_Free(vy); - - if (ret == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_aapolygoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color, *points, *item; - Sint16 *vx, *vy, x, y; - Py_ssize_t count, i; - int ret; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOO:aapolygon", &surface, &points, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - if (!PySequence_Check(points)) { - return RAISE(PyExc_TypeError, "points must be a sequence"); - } - - count = PySequence_Size(points); - if (count < 3) { - return RAISE(PyExc_ValueError, - "points must contain more than 2 points"); - } - - vx = PyMem_New(Sint16, (size_t)count); - vy = PyMem_New(Sint16, (size_t)count); - if (!vx || !vy) { - if (vx) - PyMem_Free(vx); - if (vy) - PyMem_Free(vy); - return NULL; - } - - for (i = 0; i < count; i++) { - item = PySequence_ITEM(points, i); - if (!Sint16FromSeqIndex(item, 0, &x)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - if (!Sint16FromSeqIndex(item, 1, &y)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - Py_DECREF(item); - vx[i] = x; - vy[i] = y; - } - - Py_BEGIN_ALLOW_THREADS; - ret = aapolygonRGBA(pgSurface_AsSurface(surface), vx, vy, (int)count, - rgba[0], rgba[1], rgba[2], rgba[3]); - Py_END_ALLOW_THREADS; - - PyMem_Free(vx); - PyMem_Free(vy); - - if (ret == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_filledpolygoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color, *points, *item; - Sint16 *vx, *vy, x, y; - Py_ssize_t count, i; - int ret; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOO:filled_polygon", &surface, &points, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - if (!PySequence_Check(points)) { - return RAISE(PyExc_TypeError, "points must be a sequence"); - } - - count = PySequence_Size(points); - if (count < 3) { - return RAISE(PyExc_ValueError, - "points must contain more than 2 points"); - } - - vx = PyMem_New(Sint16, (size_t)count); - vy = PyMem_New(Sint16, (size_t)count); - if (!vx || !vy) { - if (vx) - PyMem_Free(vx); - if (vy) - PyMem_Free(vy); - return NULL; - } - - for (i = 0; i < count; i++) { - item = PySequence_ITEM(points, i); - if (!Sint16FromSeqIndex(item, 0, &x)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - if (!Sint16FromSeqIndex(item, 1, &y)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - Py_DECREF(item); - vx[i] = x; - vy[i] = y; - } - - Py_BEGIN_ALLOW_THREADS; - ret = filledPolygonRGBA(pgSurface_AsSurface(surface), vx, vy, (int)count, - rgba[0], rgba[1], rgba[2], rgba[3]); - Py_END_ALLOW_THREADS; - - PyMem_Free(vx); - PyMem_Free(vy); - - if (ret == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_texturedpolygon(PyObject *self, PyObject *args) -{ - PyObject *surface, *texture, *points, *item; - SDL_Surface *s_surface, *s_texture; - Sint16 *vx, *vy, x, y, tdx, tdy; - Py_ssize_t count, i; - int ret; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOOhh:textured_polygon", &surface, &points, - &texture, &tdx, &tdy)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - s_surface = pgSurface_AsSurface(surface); - if (!pgSurface_Check(texture)) { - return RAISE(PyExc_TypeError, "texture must be a Surface"); - } - s_texture = pgSurface_AsSurface(texture); - if (!PySequence_Check(points)) { - return RAISE(PyExc_TypeError, "points must be a sequence"); - } - if (PG_SURF_BytesPerPixel(s_surface) == 1 && - (s_texture->format->Amask || s_texture->flags & SDL_SRCALPHA)) { - return RAISE(PyExc_ValueError, - "Per-byte alpha texture unsupported " - "for 8 bit surfaces"); - } - - count = PySequence_Size(points); - if (count < 3) { - return RAISE(PyExc_ValueError, - "points must contain more than 2 points"); - } - - vx = PyMem_New(Sint16, (size_t)count); - vy = PyMem_New(Sint16, (size_t)count); - if (!vx || !vy) { - if (vx) - PyMem_Free(vx); - if (vy) - PyMem_Free(vy); - return NULL; - } - - for (i = 0; i < count; i++) { - item = PySequence_ITEM(points, i); - if (!Sint16FromSeqIndex(item, 0, &x)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - if (!Sint16FromSeqIndex(item, 1, &y)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - Py_DECREF(item); - vx[i] = x; - vy[i] = y; - } - - Py_BEGIN_ALLOW_THREADS; - ret = texturedPolygon(s_surface, vx, vy, (int)count, s_texture, tdx, tdy); - Py_END_ALLOW_THREADS; - - PyMem_Free(vx); - PyMem_Free(vy); - - if (ret == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_beziercolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color, *points, *item; - Sint16 *vx, *vy, x, y; - Py_ssize_t count, i; - int ret, steps; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOiO:bezier", &surface, &points, &steps, - &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - if (!PySequence_Check(points)) { - return RAISE(PyExc_TypeError, "points must be a sequence"); - } - - count = PySequence_Size(points); - if (count < 3) { - return RAISE(PyExc_ValueError, - "points must contain more than 2 points"); - } - - if (steps < 2) { - return RAISE(PyExc_ValueError, - "steps parameter must be greater than 1"); - } - - vx = PyMem_New(Sint16, (size_t)count); - vy = PyMem_New(Sint16, (size_t)count); - if (!vx || !vy) { - if (vx) - PyMem_Free(vx); - if (vy) - PyMem_Free(vy); - return RAISE(PyExc_MemoryError, "memory allocation failed"); - } - - for (i = 0; i < count; i++) { - item = PySequence_ITEM(points, i); - if (!Sint16FromSeqIndex(item, 0, &x)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - if (!Sint16FromSeqIndex(item, 1, &y)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - Py_DECREF(item); - vx[i] = x; - vy[i] = y; - } - - Py_BEGIN_ALLOW_THREADS; - ret = bezierRGBA(pgSurface_AsSurface(surface), vx, vy, (int)count, steps, - rgba[0], rgba[1], rgba[2], rgba[3]); - Py_END_ALLOW_THREADS; - - PyMem_Free(vx); - PyMem_Free(vy); - - if (ret == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -MODINIT_DEFINE(gfxdraw) -{ - static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT, - "gfxdraw", - DOC_GFXDRAW, - -1, - _gfxdraw_methods, - NULL, - NULL, - NULL, - NULL}; - - /* import needed APIs; Do this first so if there is an error - the module is not loaded. - */ - import_pygame_base(); - if (PyErr_Occurred()) { - return NULL; - } - import_pygame_color(); - if (PyErr_Occurred()) { - return NULL; - } - import_pygame_rect(); - if (PyErr_Occurred()) { - return NULL; - } - import_pygame_surface(); - if (PyErr_Occurred()) { - return NULL; - } - - return PyModule_Create(&_module); -} diff --git a/src_c/meson.build b/src_c/meson.build index 8e8287c834..7fac062753 100644 --- a/src_c/meson.build +++ b/src_c/meson.build @@ -295,9 +295,9 @@ window = py.extension_module( subdir: pg, ) -gfxdraw = py.extension_module( - 'gfxdraw', - ['gfxdraw.c', 'SDL_gfx/SDL_gfxPrimitives.c'], +_gfxdraw = py.extension_module( + '_gfxdraw', + ['_gfxdraw.c', 'SDL_gfx/SDL_gfxPrimitives.c'], # c_args: warnings_error, dependencies: pg_base_deps, install: true, diff --git a/src_c/static.c b/src_c/static.c index c8929de6e7..7d67ce4e8c 100644 --- a/src_c/static.c +++ b/src_c/static.c @@ -169,7 +169,7 @@ PyMODINIT_FUNC PyInit_newbuffer(void); PyMODINIT_FUNC -PyInit_gfxdraw(void); +PyInit__gfxdraw(void); PyMODINIT_FUNC PyInit_audio(void); @@ -289,7 +289,7 @@ PyInit_pygame_static() load_submodule("pygame", PyInit_rect(), "rect"); load_submodule("pygame", PyInit_geometry(), "geometry"); - load_submodule("pygame", PyInit_gfxdraw(), "gfxdraw"); + load_submodule("pygame", PyInit__gfxdraw(), "_gfxdraw"); load_submodule("pygame", PyInit_pg_time(), "time"); load_submodule("pygame", PyInit__freetype(), "_freetype"); diff --git a/src_py/gfxdraw.py b/src_py/gfxdraw.py new file mode 100644 index 0000000000..f57bb62347 --- /dev/null +++ b/src_py/gfxdraw.py @@ -0,0 +1,85 @@ +import pygame +from pygame._gfxdraw import * # pylint: disable=wildcard-import,unused-wildcard-import; lgtm[py/polluting-import] + + +def pixel(surface, x, y, color): + surface.set_at((x, y), color) + + +def hline(surface, x1, x2, y, color): + pygame.draw.line(surface, color, (x1, y), (x2, y)) + + +def vline(surface, x, y1, y2, color): + pygame.draw.line(surface, color, (x, y1), (x, y2)) + + +def line(surface, x1, y1, x2, y2, color): + pygame.draw.line(surface, color, (x1, y1), (x2, y2)) + + +def rectangle(surface, rect, color): + pygame.draw.rect(surface, color, rect, 1) + + +def box(surface, rect, color): + pygame.draw.rect(surface, color, rect) + + +def circle(surface, x, y, r, color): + pygame.draw.circle(surface, color, (x, y), r, 1) + + +def aacircle(surface, x, y, r, color): + pygame.draw.aacircle(surface, color, (x, y), r, 1) + + +def filled_circle(surface, x, y, r, color): + pygame.draw.circle(surface, color, (x, y), r) + + +def ellipse(surface, x, y, rx, ry, color): + pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2), 1) + + +# missing feature for aaellipse: pygame.draw.aaellipse + + +def filled_ellipse(surface, x, y, rx, ry, color): + pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2)) + + +def arc(surface, x, y, r, start_angle, atp_angle, color): + pygame.draw.arc( + surface, color, (x - r, y - r, r * 2, r * 2), start_angle, atp_angle, 1 + ) + + +# missing feature for pie: pygame.draw.pie + + +def trigon(surface, x1, y1, x2, y2, x3, y3, color): + pygame.draw.polygon(surface, color, ((x1, y1), (x2, y2), (x3, y3)), 1) + + +# missing feature for aatrigon: pygame.draw.aapolygon + + +def filled_trigon(surface, x1, y1, x2, y2, x3, y3, color): + pygame.draw.polygon(surface, color, ((x1, y1), (x2, y2), (x3, y3))) + + +def polygon(surface, points, color): + pygame.draw.polygon(surface, color, points, 1) + + +# missing feature for aapolygon: pygame.draw.aapolygon + + +def filled_polygon(surface, points, color): + pygame.draw.polygon(surface, color, points) + + +# don't know how to shim: textured_polygon + +# missing feature for bezier: pygame.draw.bezier diff --git a/src_py/meson.build b/src_py/meson.build index 561aebaadb..8f259b4b5e 100644 --- a/src_py/meson.build +++ b/src_py/meson.build @@ -10,6 +10,7 @@ python_sources = files( 'cursors.py', 'freetype.py', 'ftfont.py', + 'gfxdraw.py', 'locals.py', 'macosx.py', 'midi.py', From ebda558d0894cf7bf1e009754430850a0a5498e7 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Thu, 18 Jul 2024 23:59:12 +0200 Subject: [PATCH 2/8] Fix #include for static.c --- src_c/static.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src_c/static.c b/src_c/static.c index 7d67ce4e8c..a1ae5e4b28 100644 --- a/src_c/static.c +++ b/src_c/static.c @@ -416,7 +416,7 @@ PyInit_pygame_static() #include "music.c" -#include "gfxdraw.c" +#include "_gfxdraw.c" #include "alphablit.c" From 18273ec64390c159c9f0eacf1016479f2464df39 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Fri, 19 Jul 2024 11:29:27 +0200 Subject: [PATCH 3/8] Expand and fix shim --- buildconfig/stubs/pygame/gfxdraw.pyi | 32 +- src_c/SDL_gfx/SDL_gfxPrimitives.c | 931 +-------------------------- src_c/SDL_gfx/SDL_gfxPrimitives.h | 53 -- src_c/_gfxdraw.c | 136 ---- src_py/gfxdraw.py | 67 +- 5 files changed, 78 insertions(+), 1141 deletions(-) diff --git a/buildconfig/stubs/pygame/gfxdraw.pyi b/buildconfig/stubs/pygame/gfxdraw.pyi index 1dbb49986f..d3592e6b7c 100644 --- a/buildconfig/stubs/pygame/gfxdraw.pyi +++ b/buildconfig/stubs/pygame/gfxdraw.pyi @@ -2,27 +2,27 @@ from pygame.surface import Surface from ._common import ColorValue, Coordinate, RectValue, Sequence -def pixel(surface: Surface, x: int, y: int, color: ColorValue) -> None: ... -def hline(surface: Surface, x1: int, x2: int, y: int, color: ColorValue) -> None: ... -def vline(surface: Surface, x: int, y1: int, y2: int, color: ColorValue) -> None: ... +def pixel(surface: Surface, x: int, y: int, color: ColorValue, /) -> None: ... +def hline(surface: Surface, x1: int, x2: int, y: int, color: ColorValue, /) -> None: ... +def vline(surface: Surface, x: int, y1: int, y2: int, color: ColorValue, /) -> None: ... def line( - surface: Surface, x1: int, y1: int, x2: int, y2: int, color: ColorValue + surface: Surface, x1: int, y1: int, x2: int, y2: int, color: ColorValue, / ) -> None: ... -def rectangle(surface: Surface, rect: RectValue, color: ColorValue) -> None: ... -def box(surface: Surface, rect: RectValue, color: ColorValue) -> None: ... -def circle(surface: Surface, x: int, y: int, r: int, color: ColorValue) -> None: ... -def aacircle(surface: Surface, x: int, y: int, r: int, color: ColorValue) -> None: ... +def rectangle(surface: Surface, rect: RectValue, color: ColorValue, /) -> None: ... +def box(surface: Surface, rect: RectValue, color: ColorValue, /) -> None: ... +def circle(surface: Surface, x: int, y: int, r: int, color: ColorValue, /) -> None: ... +def aacircle(surface: Surface, x: int, y: int, r: int, color: ColorValue, /) -> None: ... def filled_circle( - surface: Surface, x: int, y: int, r: int, color: ColorValue + surface: Surface, x: int, y: int, r: int, color: ColorValue, / ) -> None: ... def ellipse( - surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue + surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / ) -> None: ... def aaellipse( surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / ) -> None: ... def filled_ellipse( - surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue + surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / ) -> None: ... def arc( surface: Surface, @@ -31,7 +31,7 @@ def arc( r: int, start_angle: int, atp_angle: int, - color: ColorValue + color: ColorValue, / ) -> None: ... def pie( surface: Surface, @@ -50,7 +50,7 @@ def trigon( y2: int, x3: int, y3: int, - color: ColorValue + color: ColorValue, / ) -> None: ... def aatrigon( surface: Surface, @@ -70,16 +70,16 @@ def filled_trigon( y2: int, x3: int, y3: int, - color: ColorValue + color: ColorValue, / ) -> None: ... def polygon( - surface: Surface, points: Sequence[Coordinate], color: ColorValue + surface: Surface, points: Sequence[Coordinate], color: ColorValue, / ) -> None: ... def aapolygon( surface: Surface, points: Sequence[Coordinate], color: ColorValue, / ) -> None: ... def filled_polygon( - surface: Surface, points: Sequence[Coordinate], color: ColorValue + surface: Surface, points: Sequence[Coordinate], color: ColorValue, / ) -> None: ... def textured_polygon( surface: Surface, points: Sequence[Coordinate], texture: Surface, tx: int, ty: int, / diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives.c b/src_c/SDL_gfx/SDL_gfxPrimitives.c index 94d6735f74..59a9363ad6 100644 --- a/src_c/SDL_gfx/SDL_gfxPrimitives.c +++ b/src_c/SDL_gfx/SDL_gfxPrimitives.c @@ -1391,259 +1391,6 @@ lineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, #define AAlevels 256 #define AAbits 8 -/*! -\brief Internal function to draw anti-aliased line with alpha blending and -endpoint control. - -This implementation of the Wu antialiasing code is based on Mike Abrash's -DDJ article which was reprinted as Chapter 42 of his Graphics Programming -Black Book, but has been optimized to work with SDL and utilizes 32-bit -fixed-point arithmetic by A. Schiffler. The endpoint control allows the -suppression to draw the last pixel useful for rendering continuous aa-lines -with alpha<255. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the aa-line. -\param y1 Y coordinate of the first point of the aa-line. -\param x2 X coordinate of the second point of the aa-line. -\param y2 Y coordinate of the second point of the aa-line. -\param color The color value of the aa-line to draw (0xRRGGBBAA). -\param draw_endpoint Flag indicating if the endpoint should be drawn; draw if -non-zero. - -\returns Returns 0 on success, -1 on failure. -*/ -int -_aalineColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Uint32 color, int draw_endpoint) -{ - Sint32 xx0, yy0, xx1, yy1; - int result; - Uint32 intshift, erracc, erradj; - Uint32 erracctmp, wgt, wgtcompmask; - int dx, dy, tmp, xdir, y0p1, x0pxdir; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Clip line and test if we have to draw - */ - if (!(_clipLine(dst, &x1, &y1, &x2, &y2))) { - return (0); - } - - /* - * Keep on working with 32bit numbers - */ - xx0 = x1; - yy0 = y1; - xx1 = x2; - yy1 = y2; - - /* - * Reorder points if required - */ - if (yy0 > yy1) { - tmp = yy0; - yy0 = yy1; - yy1 = tmp; - tmp = xx0; - xx0 = xx1; - xx1 = tmp; - } - - /* - * Calculate distance - */ - dx = xx1 - xx0; - dy = yy1 - yy0; - - /* - * Check for special cases - */ - if (dx == 0) { - /* - * Vertical line - */ - if (draw_endpoint) { - return (vlineColor(dst, x1, y1, y2, color)); - } - else { - if (dy > 0) { - return (vlineColor(dst, x1, yy0, yy0 + dy, color)); - } - else { - return (pixelColor(dst, x1, y1, color)); - } - } - } - else if (dy == 0) { - /* - * Horizontal line - */ - if (draw_endpoint) { - return (hlineColor(dst, x1, x2, y1, color)); - } - else { - if (dx != 0) { - return (hlineColor(dst, xx0, xx0 + dx, y1, color)); - } - else { - return (pixelColor(dst, x1, y1, color)); - } - } - } - else if ((dx == dy) && (draw_endpoint)) { - /* - * Diagonal line (with endpoint) - */ - return (lineColor(dst, x1, y1, x2, y2, color)); - } - - /* - * Adjust for negative dx and set xdir - */ - if (dx >= 0) { - xdir = 1; - } - else { - xdir = -1; - dx = (-dx); - } - - /* - * Line is not horizontal, vertical or diagonal (with endpoint) - */ - result = 0; - - /* - * Zero accumulator - */ - erracc = 0; - - /* - * # of bits by which to shift erracc to get intensity level - */ - intshift = 32 - AAbits; - - /* - * Mask used to flip all bits in an intensity weighting - */ - wgtcompmask = AAlevels - 1; - - /* Lock surface */ - if (SDL_MUSTLOCK(dst)) { - if (SDL_LockSurface(dst) < 0) { - return (-1); - } - } - - /* - * Draw the initial pixel in the foreground color - */ - result |= pixelColorNolock(dst, x1, y1, color); - - /* - * x-major or y-major? - */ - if (dy > dx) { - /* - * y-major. Calculate 16-bit fixed point fractional part of a pixel - * that X advances every time Y advances 1 pixel, truncating the result - * so that we won't overrun the endpoint along the X axis - */ - /* - * Not-so-portable version: erradj = ((Uint64)dx << 32) / (Uint64)dy; - */ - erradj = ((dx << 16) / dy) << 16; - - /* - * draw all pixels other than the first and last - */ - x0pxdir = xx0 + xdir; - while (--dy) { - erracctmp = erracc; - erracc += erradj; - if (erracc <= erracctmp) { - /* - * rollover in error accumulator, x coord advances - */ - xx0 = x0pxdir; - x0pxdir += xdir; - } - yy0++; /* y-major so always advance Y */ - - /* - * the AAbits most significant bits of erracc give us the intensity - * weighting for this pixel, and the complement of the weighting - * for the paired pixel. - */ - wgt = (erracc >> intshift) & 255; - result |= pixelColorWeightNolock(dst, xx0, yy0, color, 255 - wgt); - result |= pixelColorWeightNolock(dst, x0pxdir, yy0, color, wgt); - } - } - else { - /* - * x-major line. Calculate 16-bit fixed-point fractional part of a - * pixel that Y advances each time X advances 1 pixel, truncating the - * result so that we won't overrun the endpoint along the X axis. - */ - /* - * Not-so-portable version: erradj = ((Uint64)dy << 32) / (Uint64)dx; - */ - erradj = ((dy << 16) / dx) << 16; - - /* - * draw all pixels other than the first and last - */ - y0p1 = yy0 + 1; - while (--dx) { - erracctmp = erracc; - erracc += erradj; - if (erracc <= erracctmp) { - /* - * Accumulator turned over, advance y - */ - yy0 = y0p1; - y0p1++; - } - xx0 += xdir; /* x-major so always advance X */ - /* - * the AAbits most significant bits of erracc give us the intensity - * weighting for this pixel, and the complement of the weighting - * for the paired pixel. - */ - wgt = (erracc >> intshift) & 255; - result |= pixelColorWeightNolock(dst, xx0, yy0, color, 255 - wgt); - result |= pixelColorWeightNolock(dst, xx0, y0p1, color, wgt); - } - } - - /* - * Do we have to draw the endpoint - */ - if (draw_endpoint) { - /* - * Draw final pixel, always exactly intersected by the line and doesn't - * need to be weighted. - */ - result |= pixelColorNolock(dst, x2, y2, color); - } - - /* Unlock surface */ - if (SDL_MUSTLOCK(dst)) { - SDL_UnlockSurface(dst); - } - - return (result); -} - /* ----- AA Ellipse */ /* Visual Studio 2015 and above define the lrint intrinsic function, but for @@ -1962,688 +1709,38 @@ aaellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); } -/* ----- pie */ - -/*! -\brief Internal float (low-speed) pie-calc implementation by drawing polygons. - -Note: Determines vertex array and uses polygon or filledPolygon drawing -routines to render. - -\param dst The surface to draw on. -\param x X coordinate of the center of the pie. -\param y Y coordinate of the center of the pie. -\param rad Radius in pixels of the pie. -\param start Starting radius in degrees of the pie. -\param end Ending radius in degrees of the pie. -\param color The color value of the pie to draw (0xRRGGBBAA). -\param filled Flag indicating if the pie should be filled (=1) or not (=0). - -\returns Returns 0 on success, -1 on failure. -*/ -int -_pieColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint32 color, Uint8 filled) -{ - Sint16 left, right, top, bottom; - Sint16 x1, y1, x2, y2; - int result; - double angle, start_angle, end_angle; - double deltaAngle; - double dr; - int numpoints, i; - Sint16 *vx, *vy; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Sanity check radii - */ - if (rad < 0) { - return (-1); - } - - /* - * Fixup angles - */ - start = start % 360; - end = end % 360; - - /* - * Special case for rad=0 - draw a point - */ - if (rad == 0) { - return (pixelColor(dst, x, y, color)); - } - - /* - * Clip against circle, not pie (not 100% optimal). - * Get pie's circle and clipping boundary and - * test if bounding box of circle is visible - */ - x2 = x + rad; - left = dst->clip_rect.x; - if (x2 < left) { - return (0); - } - x1 = x - rad; - right = dst->clip_rect.x + dst->clip_rect.w - 1; - if (x1 > right) { - return (0); - } - y2 = y + rad; - top = dst->clip_rect.y; - if (y2 < top) { - return (0); - } - y1 = y - rad; - bottom = dst->clip_rect.y + dst->clip_rect.h - 1; - if (y1 > bottom) { - return (0); - } - - /* - * Variable setup - */ - dr = (double)rad; - deltaAngle = 3.0 / dr; - start_angle = (double)start * (2.0 * M_PI / 360.0); - end_angle = (double)end * (2.0 * M_PI / 360.0); - if (start > end) { - end_angle += (2.0 * M_PI); - } - - /* We will always have at least 2 points */ - numpoints = 2; - - /* Count points (rather than calculating it) */ - angle = start_angle; - while (angle < end_angle) { - angle += deltaAngle; - numpoints++; - } - - /* Allocate combined vertex array */ - vx = vy = (Sint16 *)malloc(2 * sizeof(Uint16) * numpoints); - if (vx == NULL) { - return (-1); - } - - /* Update point to start of vy */ - vy += numpoints; - - /* Center */ - vx[0] = x; - vy[0] = y; - - /* First vertex */ - angle = start_angle; - vx[1] = x + (int)(dr * cos(angle)); - vy[1] = y + (int)(dr * sin(angle)); - - if (numpoints < 3) { - result = lineColor(dst, vx[0], vy[0], vx[1], vy[1], color); - } - else { - /* Calculate other vertices */ - i = 2; - angle = start_angle; - while (angle < end_angle) { - angle += deltaAngle; - if (angle > end_angle) { - angle = end_angle; - } - vx[i] = x + (int)(dr * cos(angle)); - vy[i] = y + (int)(dr * sin(angle)); - i++; - } - - /* Draw */ - if (filled) { - result = filledPolygonColor(dst, vx, vy, numpoints, color); - } - else { - result = polygonColor(dst, vx, vy, numpoints, color); - } - } - - /* Free combined vertex array */ - free(vx); - - return (result); -} - -/*! -\brief Draw pie (outline) with alpha blending. - -\param dst The surface to draw on. -\param x X coordinate of the center of the pie. -\param y Y coordinate of the center of the pie. -\param rad Radius in pixels of the pie. -\param start Starting radius in degrees of the pie. -\param end Ending radius in degrees of the pie. -\param color The color value of the pie to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -pieColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint32 color) -{ - return (_pieColor(dst, x, y, rad, start, end, color, 0)); -} +/* ---- Filled Polygon */ /*! -\brief Draw pie (outline) with alpha blending. +\brief Internal helper qsort callback functions used in filled polygon drawing. -\param dst The surface to draw on. -\param x X coordinate of the center of the pie. -\param y Y coordinate of the center of the pie. -\param rad Radius in pixels of the pie. -\param start Starting radius in degrees of the pie. -\param end Ending radius in degrees of the pie. -\param r The red value of the pie to draw. -\param g The green value of the pie to draw. -\param b The blue value of the pie to draw. -\param a The alpha value of the pie to draw. +\param a The surface to draw on. +\param b Vertex array containing X coordinates of the points of the polygon. -\returns Returns 0 on success, -1 on failure. +\returns Returns 0 if a==b, a negative number if ab. */ int -pieRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +_gfxPrimitivesCompareInt(const void *a, const void *b) { - return (_pieColor( - dst, x, y, rad, start, end, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a, - 0)); + return (*(const int *)a) - (*(const int *)b); } -/* ------ AA-Trigon */ - /*! -\brief Draw anti-aliased trigon (triangle outline) with alpha blending. - -Note: Creates vertex array and uses aapolygon routine to render. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the aa-trigon. -\param y1 Y coordinate of the first point of the aa-trigon. -\param x2 X coordinate of the second point of the aa-trigon. -\param y2 Y coordinate of the second point of the aa-trigon. -\param x3 X coordinate of the third point of the aa-trigon. -\param y3 Y coordinate of the third point of the aa-trigon. -\param color The color value of the aa-trigon to draw (0xRRGGBBAA). +\brief Global vertex array to use if optional parameters are not given in +filledPolygonMT calls. -\returns Returns 0 on success, -1 on failure. +Note: Used for non-multithreaded (default) operation of filledPolygonMT. */ -int -aatrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint32 color) -{ - Sint16 vx[3]; - Sint16 vy[3]; - - vx[0] = x1; - vx[1] = x2; - vx[2] = x3; - vy[0] = y1; - vy[1] = y2; - vy[2] = y3; - - return (aapolygonColor(dst, vx, vy, 3, color)); -} +static int *gfxPrimitivesPolyIntsGlobal = NULL; /*! -\brief Draw anti-aliased trigon (triangle outline) with alpha blending. - -\param dst The surface to draw on. -\param x1 X coordinate of the first point of the aa-trigon. -\param y1 Y coordinate of the first point of the aa-trigon. -\param x2 X coordinate of the second point of the aa-trigon. -\param y2 Y coordinate of the second point of the aa-trigon. -\param x3 X coordinate of the third point of the aa-trigon. -\param y3 Y coordinate of the third point of the aa-trigon. -\param r The red value of the aa-trigon to draw. -\param g The green value of the aa-trigon to draw. -\param b The blue value of the aa-trigon to draw. -\param a The alpha value of the aa-trigon to draw. +\brief Flag indicating if global vertex array was already allocated. -\returns Returns 0 on success, -1 on failure. -*/ -int -aatrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - Sint16 vx[3]; - Sint16 vy[3]; - - vx[0] = x1; - vx[1] = x2; - vx[2] = x3; - vy[0] = y1; - vy[1] = y2; - vy[2] = y3; - - return (aapolygonRGBA(dst, vx, vy, 3, r, g, b, a)); -} - -/* ------ Filled Trigon */ - -/* ---- Polygon */ - -/*! -\brief Draw polygon with alpha blending. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the polygon. -\param vy Vertex array containing Y coordinates of the points of the polygon. -\param n Number of points in the vertex array. Minimum number is 3. -\param color The color value of the polygon to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -polygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint32 color) -{ - int result; - int i; - const Sint16 *x1, *y1, *x2, *y2; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Vertex array NULL check - */ - if (vx == NULL) { - return (-1); - } - if (vy == NULL) { - return (-1); - } - - /* - * Sanity check - */ - if (n < 3) { - return (-1); - } - - /* - * Pointer setup - */ - x1 = x2 = vx; - y1 = y2 = vy; - x2++; - y2++; - - /* - * Draw - */ - result = 0; - for (i = 1; i < n; i++) { - result |= lineColor(dst, *x1, *y1, *x2, *y2, color); - x1 = x2; - y1 = y2; - x2++; - y2++; - } - result |= lineColor(dst, *x1, *y1, *vx, *vy, color); - - return (result); -} - -/* ---- AA-Polygon */ - -/*! -\brief Draw anti-aliased polygon with alpha blending. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the -aa-polygon. \param vy Vertex array containing Y coordinates of the points of -the aa-polygon. \param n Number of points in the vertex array. Minimum number -is 3. \param color The color value of the aa-polygon to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -aapolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint32 color) -{ - int result; - int i; - const Sint16 *x1, *y1, *x2, *y2; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Vertex array NULL check - */ - if (vx == NULL) { - return (-1); - } - if (vy == NULL) { - return (-1); - } - - /* - * Sanity check - */ - if (n < 3) { - return (-1); - } - - /* - * Pointer setup - */ - x1 = x2 = vx; - y1 = y2 = vy; - x2++; - y2++; - - /* - * Draw - */ - result = 0; - for (i = 1; i < n; i++) { - result |= _aalineColor(dst, *x1, *y1, *x2, *y2, color, 0); - x1 = x2; - y1 = y2; - x2++; - y2++; - } - result |= _aalineColor(dst, *x1, *y1, *vx, *vy, color, 0); - - return (result); -} - -/*! -\brief Draw anti-aliased polygon with alpha blending. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the -aa-polygon. \param vy Vertex array containing Y coordinates of the points of -the aa-polygon. \param n Number of points in the vertex array. Minimum number -is 3. \param r The red value of the aa-polygon to draw. \param g The green -value of the aa-polygon to draw. \param b The blue value of the aa-polygon to -draw. \param a The alpha value of the aa-polygon to draw. - -\returns Returns 0 on success, -1 on failure. -*/ -int -aapolygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - /* - * Draw - */ - return (aapolygonColor( - dst, vx, vy, n, - ((Uint32)r << 24) | ((Uint32)g << 16) | ((Uint32)b << 8) | (Uint32)a)); -} - -/* ---- Filled Polygon */ - -/*! -\brief Internal helper qsort callback functions used in filled polygon drawing. - -\param a The surface to draw on. -\param b Vertex array containing X coordinates of the points of the polygon. - -\returns Returns 0 if a==b, a negative number if ab. -*/ -int -_gfxPrimitivesCompareInt(const void *a, const void *b) -{ - return (*(const int *)a) - (*(const int *)b); -} - -/*! -\brief Global vertex array to use if optional parameters are not given in -filledPolygonMT calls. - -Note: Used for non-multithreaded (default) operation of filledPolygonMT. -*/ -static int *gfxPrimitivesPolyIntsGlobal = NULL; - -/*! -\brief Flag indicating if global vertex array was already allocated. - -Note: Used for non-multithreaded (default) operation of filledPolygonMT. +Note: Used for non-multithreaded (default) operation of filledPolygonMT. */ static int gfxPrimitivesPolyAllocatedGlobal = 0; -/*! -\brief Draw filled polygon with alpha blending (multi-threaded capable). - -Note: The last two parameters are optional; but are required for multithreaded -operation. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the filled -polygon. \param vy Vertex array containing Y coordinates of the points of the -filled polygon. \param n Number of points in the vertex array. Minimum number -is 3. \param color The color value of the filled polygon to draw (0xRRGGBBAA). -\param polyInts Preallocated, temporary vertex array used for sorting vertices. -Required for multithreaded operation; set to NULL otherwise. \param -polyAllocated Flag indicating if temporary vertex array was allocated. Required -for multithreaded operation; set to NULL otherwise. - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledPolygonColorMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, - int n, Uint32 color, int **polyInts, int *polyAllocated) -{ - int result; - int i; - int y, xa, xb; - int miny, maxy; - int x1, y1; - int x2, y2; - int ind1, ind2; - int ints; - int *gfxPrimitivesPolyInts = NULL; - int *gfxPrimitivesPolyIntsNew = NULL; - int gfxPrimitivesPolyAllocated = 0; - - /* - * Check visibility of clipping rectangle - */ - if ((dst->clip_rect.w == 0) || (dst->clip_rect.h == 0)) { - return (0); - } - - /* - * Vertex array NULL check - */ - if (vx == NULL) { - return (-1); - } - if (vy == NULL) { - return (-1); - } - - /* - * Sanity check number of edges - */ - if (n < 3) { - return -1; - } - - /* - * Map polygon cache - */ - if ((polyInts == NULL) || (polyAllocated == NULL)) { - /* Use global cache */ - gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal; - gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal; - } - else { - /* Use local cache */ - gfxPrimitivesPolyInts = *polyInts; - gfxPrimitivesPolyAllocated = *polyAllocated; - } - - /* - * Allocate temp array, only grow array - */ - if (!gfxPrimitivesPolyAllocated) { - gfxPrimitivesPolyInts = (int *)malloc(sizeof(int) * n); - gfxPrimitivesPolyAllocated = n; - } - else { - if (gfxPrimitivesPolyAllocated < n) { - gfxPrimitivesPolyIntsNew = - (int *)realloc(gfxPrimitivesPolyInts, sizeof(int) * n); - if (!gfxPrimitivesPolyIntsNew) { - if (!gfxPrimitivesPolyInts) { - free(gfxPrimitivesPolyInts); - gfxPrimitivesPolyInts = NULL; - } - gfxPrimitivesPolyAllocated = 0; - } - else { - gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsNew; - gfxPrimitivesPolyAllocated = n; - } - } - } - - /* - * Check temp array - */ - if (gfxPrimitivesPolyInts == NULL) { - gfxPrimitivesPolyAllocated = 0; - } - - /* - * Update cache variables - */ - if ((polyInts == NULL) || (polyAllocated == NULL)) { - gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts; - gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated; - } - else { - *polyInts = gfxPrimitivesPolyInts; - *polyAllocated = gfxPrimitivesPolyAllocated; - } - - /* - * Check temp array again - */ - if (gfxPrimitivesPolyInts == NULL) { - return (-1); - } - - /* - * Determine Y maxima - */ - miny = vy[0]; - maxy = vy[0]; - for (i = 1; (i < n); i++) { - if (vy[i] < miny) { - miny = vy[i]; - } - else if (vy[i] > maxy) { - maxy = vy[i]; - } - } - - /* - * Draw, scanning y - */ - result = 0; - for (y = miny; (y <= maxy); y++) { - ints = 0; - for (i = 0; (i < n); i++) { - if (!i) { - ind1 = n - 1; - ind2 = 0; - } - else { - ind1 = i - 1; - ind2 = i; - } - y1 = vy[ind1]; - y2 = vy[ind2]; - if (y1 < y2) { - x1 = vx[ind1]; - x2 = vx[ind2]; - } - else if (y1 > y2) { - y2 = vy[ind1]; - y1 = vy[ind2]; - x2 = vx[ind1]; - x1 = vx[ind2]; - } - else { - continue; - } - if (((y >= y1) && (y < y2)) || - ((y == maxy) && (y > y1) && (y <= y2))) { - gfxPrimitivesPolyInts[ints++] = - ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + - (65536 * x1); - } - } - - qsort(gfxPrimitivesPolyInts, ints, sizeof(int), - _gfxPrimitivesCompareInt); - - for (i = 0; (i < ints); i += 2) { - xa = gfxPrimitivesPolyInts[i] + 1; - xa = (xa >> 16) + ((xa & 32768) >> 15); - xb = gfxPrimitivesPolyInts[i + 1] - 1; - xb = (xb >> 16) + ((xb & 32768) >> 15); - result |= hlineColor(dst, xa, xb, y, color); - } - } - - return (result); -} - -/*! -\brief Draw filled polygon with alpha blending. - -Note: Standard filledPolygon function is calling multithreaded version with -NULL parameters to use the global vertex cache. - -\param dst The surface to draw on. -\param vx Vertex array containing X coordinates of the points of the filled -polygon. \param vy Vertex array containing Y coordinates of the points of the -filled polygon. \param n Number of points in the vertex array. Minimum number -is 3. \param color The color value of the filled polygon to draw (0xRRGGBBAA). - -\returns Returns 0 on success, -1 on failure. -*/ -int -filledPolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint32 color) -{ - /* - * Draw - */ - return (filledPolygonColorMT(dst, vx, vy, n, color, NULL, NULL)); -} - /*! \brief Internal function to draw a textured horizontal line. diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives.h b/src_c/SDL_gfx/SDL_gfxPrimitives.h index 47eeeaf847..f3d7bf8df8 100644 --- a/src_c/SDL_gfx/SDL_gfxPrimitives.h +++ b/src_c/SDL_gfx/SDL_gfxPrimitives.h @@ -58,8 +58,6 @@ extern "C" { /* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */ -/* Pixel */ - /* Horizontal line */ SDL_GFXPRIMITIVES_SCOPE int @@ -85,62 +83,11 @@ SDL_GFXPRIMITIVES_SCOPE int aaellipseRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -/* Pie */ - -SDL_GFXPRIMITIVES_SCOPE int -pieColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -pieRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, - Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - -/* AA-Trigon */ - -SDL_GFXPRIMITIVES_SCOPE int -aatrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -aatrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - -/* Filled Trigon */ - -SDL_GFXPRIMITIVES_SCOPE int -filledTrigonColor(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -filledTrigonRGBA(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, - Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - -/* Polygon */ - -SDL_GFXPRIMITIVES_SCOPE int -polygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint32 color); - -/* AA-Polygon */ - -SDL_GFXPRIMITIVES_SCOPE int -aapolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint32 color); -SDL_GFXPRIMITIVES_SCOPE int -aapolygonRGBA(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint8 r, Uint8 g, Uint8 b, Uint8 a); - /* Filled Polygon */ - -SDL_GFXPRIMITIVES_SCOPE int -filledPolygonColor(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, - Uint32 color); SDL_GFXPRIMITIVES_SCOPE int texturedPolygon(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy); -/* (Note: These MT versions are required for multi-threaded operation.) */ - -SDL_GFXPRIMITIVES_SCOPE int -filledPolygonColorMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, - int n, Uint32 color, int **polyInts, int *polyAllocated); SDL_GFXPRIMITIVES_SCOPE int texturedPolygonMT(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy, diff --git a/src_c/_gfxdraw.c b/src_c/_gfxdraw.c index b6e27c31b4..54f7de3f91 100644 --- a/src_c/_gfxdraw.c +++ b/src_c/_gfxdraw.c @@ -42,21 +42,12 @@ static PyObject * _gfx_aaellipsecolor(PyObject *self, PyObject *args); static PyObject * -_gfx_piecolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_aatrigoncolor(PyObject *self, PyObject *args); -static PyObject * -_gfx_aapolygoncolor(PyObject *self, PyObject *args); -static PyObject * _gfx_texturedpolygon(PyObject *self, PyObject *args); static PyObject * _gfx_beziercolor(PyObject *self, PyObject *args); static PyMethodDef _gfxdraw_methods[] = { {"aaellipse", _gfx_aaellipsecolor, METH_VARARGS, DOC_GFXDRAW_AAELLIPSE}, - {"pie", _gfx_piecolor, METH_VARARGS, DOC_GFXDRAW_PIE}, - {"aatrigon", _gfx_aatrigoncolor, METH_VARARGS, DOC_GFXDRAW_AATRIGON}, - {"aapolygon", _gfx_aapolygoncolor, METH_VARARGS, DOC_GFXDRAW_AAPOLYGON}, {"textured_polygon", _gfx_texturedpolygon, METH_VARARGS, DOC_GFXDRAW_TEXTUREDPOLYGON}, {"bezier", _gfx_beziercolor, METH_VARARGS, DOC_GFXDRAW_BEZIER}, @@ -124,133 +115,6 @@ _gfx_aaellipsecolor(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -_gfx_piecolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x, y, r, start, end; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhhO:pie", &surface, &x, &y, &r, &start, - &end, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (pieRGBA(pgSurface_AsSurface(surface), x, y, r, start, end, rgba[0], - rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_aatrigoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color; - Sint16 x1, x2, x3, _y1, y2, y3; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OhhhhhhO:aatrigon", &surface, &x1, &_y1, &x2, - &y2, &x3, &y3, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - - if (aatrigonRGBA(pgSurface_AsSurface(surface), x1, _y1, x2, y2, x3, y3, - rgba[0], rgba[1], rgba[2], rgba[3]) == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - -static PyObject * -_gfx_aapolygoncolor(PyObject *self, PyObject *args) -{ - PyObject *surface, *color, *points, *item; - Sint16 *vx, *vy, x, y; - Py_ssize_t count, i; - int ret; - Uint8 rgba[4]; - - ASSERT_VIDEO_INIT(NULL); - - if (!PyArg_ParseTuple(args, "OOO:aapolygon", &surface, &points, &color)) - return NULL; - - if (!pgSurface_Check(surface)) { - return RAISE(PyExc_TypeError, "surface must be a Surface"); - } - if (!pg_RGBAFromObjEx(color, rgba, PG_COLOR_HANDLE_SIMPLE)) { - return NULL; - } - if (!PySequence_Check(points)) { - return RAISE(PyExc_TypeError, "points must be a sequence"); - } - - count = PySequence_Size(points); - if (count < 3) { - return RAISE(PyExc_ValueError, - "points must contain more than 2 points"); - } - - vx = PyMem_New(Sint16, (size_t)count); - vy = PyMem_New(Sint16, (size_t)count); - if (!vx || !vy) { - if (vx) - PyMem_Free(vx); - if (vy) - PyMem_Free(vy); - return NULL; - } - - for (i = 0; i < count; i++) { - item = PySequence_ITEM(points, i); - if (!Sint16FromSeqIndex(item, 0, &x)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - if (!Sint16FromSeqIndex(item, 1, &y)) { - PyMem_Free(vx); - PyMem_Free(vy); - Py_XDECREF(item); - return NULL; - } - Py_DECREF(item); - vx[i] = x; - vy[i] = y; - } - - Py_BEGIN_ALLOW_THREADS; - ret = aapolygonRGBA(pgSurface_AsSurface(surface), vx, vy, (int)count, - rgba[0], rgba[1], rgba[2], rgba[3]); - Py_END_ALLOW_THREADS; - - PyMem_Free(vx); - PyMem_Free(vy); - - if (ret == -1) { - return RAISE(pgExc_SDLError, SDL_GetError()); - } - Py_RETURN_NONE; -} - static PyObject * _gfx_texturedpolygon(PyObject *self, PyObject *args) { diff --git a/src_py/gfxdraw.py b/src_py/gfxdraw.py index f57bb62347..9a129ef1bf 100644 --- a/src_py/gfxdraw.py +++ b/src_py/gfxdraw.py @@ -1,82 +1,111 @@ import pygame +import math as _math from pygame._gfxdraw import * # pylint: disable=wildcard-import,unused-wildcard-import; lgtm[py/polluting-import] -def pixel(surface, x, y, color): +_pi_quo_180 = 0.01745329251994329577 + + +def pixel(surface, x, y, color, /): surface.set_at((x, y), color) -def hline(surface, x1, x2, y, color): +def hline(surface, x1, x2, y, color, /): pygame.draw.line(surface, color, (x1, y), (x2, y)) -def vline(surface, x, y1, y2, color): +def vline(surface, x, y1, y2, color, /): pygame.draw.line(surface, color, (x, y1), (x, y2)) -def line(surface, x1, y1, x2, y2, color): +def line(surface, x1, y1, x2, y2, color, /): pygame.draw.line(surface, color, (x1, y1), (x2, y2)) -def rectangle(surface, rect, color): +def rectangle(surface, rect, color, /): pygame.draw.rect(surface, color, rect, 1) -def box(surface, rect, color): +def box(surface, rect, color, /): pygame.draw.rect(surface, color, rect) -def circle(surface, x, y, r, color): +def circle(surface, x, y, r, color, /): pygame.draw.circle(surface, color, (x, y), r, 1) -def aacircle(surface, x, y, r, color): +def aacircle(surface, x, y, r, color, /): pygame.draw.aacircle(surface, color, (x, y), r, 1) -def filled_circle(surface, x, y, r, color): +def filled_circle(surface, x, y, r, color, /): pygame.draw.circle(surface, color, (x, y), r) -def ellipse(surface, x, y, rx, ry, color): +def ellipse(surface, x, y, rx, ry, color, /): pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2), 1) # missing feature for aaellipse: pygame.draw.aaellipse -def filled_ellipse(surface, x, y, rx, ry, color): +def filled_ellipse(surface, x, y, rx, ry, color, /): pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2)) def arc(surface, x, y, r, start_angle, atp_angle, color): pygame.draw.arc( - surface, color, (x - r, y - r, r * 2, r * 2), start_angle, atp_angle, 1 + surface, + color, + (x - r, y - r, r * 2, r * 2), + -atp_angle * _pi_quo_180, + -start_angle * _pi_quo_180, + 1, ) -# missing feature for pie: pygame.draw.pie +def pie(surface, x, y, r, start_angle, atp_angle, color): + start = start_angle * _pi_quo_180 + end = atp_angle * _pi_quo_180 + pygame.draw.arc( + surface, + color, + (x - r, y - r, r * 2, r * 2), + -end, + -start, + 1, + ) + pygame.draw.line( + surface, color, (x, y), (x + _math.cos(start) * r, y + _math.sin(start) * r) + ) + pygame.draw.line( + surface, color, (x, y), (x + _math.cos(end) * r, y + _math.sin(end) * r) + ) -def trigon(surface, x1, y1, x2, y2, x3, y3, color): +def trigon(surface, x1, y1, x2, y2, x3, y3, color, /): pygame.draw.polygon(surface, color, ((x1, y1), (x2, y2), (x3, y3)), 1) -# missing feature for aatrigon: pygame.draw.aapolygon +# replace with pygame.draw.aapolygon when possible +def aatrigon(surface, x1, y1, x2, y2, x3, y3, color, /): + pygame.draw.aalines(surface, color, True, ((x1, y1), (x2, y2), (x3, y3))) -def filled_trigon(surface, x1, y1, x2, y2, x3, y3, color): +def filled_trigon(surface, x1, y1, x2, y2, x3, y3, color, /): pygame.draw.polygon(surface, color, ((x1, y1), (x2, y2), (x3, y3))) -def polygon(surface, points, color): +def polygon(surface, points, color, /): pygame.draw.polygon(surface, color, points, 1) -# missing feature for aapolygon: pygame.draw.aapolygon +# replace with pygame.draw.aapolygon when possible +def aapolygon(surface, points, color, /): + pygame.draw.aalines(surface, color, True, points) -def filled_polygon(surface, points, color): +def filled_polygon(surface, points, color, /): pygame.draw.polygon(surface, color, points) From 3b888d906517afeba52361038f3886b79d13b310 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Fri, 19 Jul 2024 11:41:11 +0200 Subject: [PATCH 4/8] Add deprecations to stub --- buildconfig/stubs/pygame/gfxdraw.pyi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/buildconfig/stubs/pygame/gfxdraw.pyi b/buildconfig/stubs/pygame/gfxdraw.pyi index d3592e6b7c..9ff0bd4ab6 100644 --- a/buildconfig/stubs/pygame/gfxdraw.pyi +++ b/buildconfig/stubs/pygame/gfxdraw.pyi @@ -1,29 +1,43 @@ from pygame.surface import Surface +from typing_extensions import deprecated # added in 3.13 from ._common import ColorValue, Coordinate, RectValue, Sequence +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.Surface.set_at` instead") def pixel(surface: Surface, x: int, y: int, color: ColorValue, /) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead") def hline(surface: Surface, x1: int, x2: int, y: int, color: ColorValue, /) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead") def vline(surface: Surface, x: int, y1: int, y2: int, color: ColorValue, /) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead") def line( surface: Surface, x1: int, y1: int, x2: int, y2: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.rect` instead") def rectangle(surface: Surface, rect: RectValue, color: ColorValue, /) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.rect` instead") def box(surface: Surface, rect: RectValue, color: ColorValue, /) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.circle` instead") def circle(surface: Surface, x: int, y: int, r: int, color: ColorValue, /) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.aacircle` instead") def aacircle(surface: Surface, x: int, y: int, r: int, color: ColorValue, /) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.circle` instead") def filled_circle( surface: Surface, x: int, y: int, r: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.ellipse` instead") def ellipse( surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.aaellipse` instead") # not implemented yet def aaellipse( surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.ellipse` instead") def filled_ellipse( surface: Surface, x: int, y: int, rx: int, ry: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.arc` instead") def arc( surface: Surface, x: int, @@ -33,6 +47,7 @@ def arc( atp_angle: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.arc` and `pygame.draw.line` instead") def pie( surface: Surface, x: int, @@ -42,6 +57,7 @@ def pie( atp_angle: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead") def trigon( surface: Surface, x1: int, @@ -52,6 +68,7 @@ def trigon( y3: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.aalines` instead") # should replace with aapolygon def aatrigon( surface: Surface, x1: int, @@ -62,6 +79,7 @@ def aatrigon( y3: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead") def filled_trigon( surface: Surface, x1: int, @@ -72,18 +90,23 @@ def filled_trigon( y3: int, color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead") def polygon( surface: Surface, points: Sequence[Coordinate], color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.aalines` instead") # should replace with aapolygon def aapolygon( surface: Surface, points: Sequence[Coordinate], color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead") def filled_polygon( surface: Surface, points: Sequence[Coordinate], color: ColorValue, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION.") def textured_polygon( surface: Surface, points: Sequence[Coordinate], texture: Surface, tx: int, ty: int, / ) -> None: ... +@deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.bezier` instead") # not implemented yet def bezier( surface: Surface, points: Sequence[Coordinate], steps: int, color: ColorValue, / ) -> None: ... From 4596aa6f99e89494859ce5466c5dc8f4893b2839 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Fri, 19 Jul 2024 12:01:27 +0200 Subject: [PATCH 5/8] Mark deprecated in the docs --- buildconfig/stubs/pygame/gfxdraw.pyi | 4 +- docs/reST/ref/gfxdraw.rst | 59 +++++++++++++++++++++----- docs/reST/themes/classic/elements.html | 4 +- src_py/gfxdraw.py | 8 ++-- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/buildconfig/stubs/pygame/gfxdraw.pyi b/buildconfig/stubs/pygame/gfxdraw.pyi index 9ff0bd4ab6..9e54543bc8 100644 --- a/buildconfig/stubs/pygame/gfxdraw.pyi +++ b/buildconfig/stubs/pygame/gfxdraw.pyi @@ -44,7 +44,7 @@ def arc( y: int, r: int, start_angle: int, - atp_angle: int, + stop_angle: int, color: ColorValue, / ) -> None: ... @deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.arc` and `pygame.draw.line` instead") @@ -54,7 +54,7 @@ def pie( y: int, r: int, start_angle: int, - atp_angle: int, + stop_angle: int, color: ColorValue, / ) -> None: ... @deprecated("since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead") diff --git a/docs/reST/ref/gfxdraw.rst b/docs/reST/ref/gfxdraw.rst index c997c994cf..e11ed85261 100644 --- a/docs/reST/ref/gfxdraw.rst +++ b/docs/reST/ref/gfxdraw.rst @@ -11,6 +11,9 @@ **EXPERIMENTAL!**: This API may change or disappear in later pygame releases. If you use this, your code may break with the next pygame release. +The gfxdraw module is now deprecated in favor of the draw module and all its +functions are deprecated. + The pygame package does not import gfxdraw automatically when loaded, so it must imported explicitly to be used. @@ -26,6 +29,7 @@ following formats: - a :mod:`pygame.Color` object - an ``(RGB)`` triplet (tuple/list) - an ``(RGBA)`` quadruplet (tuple/list) + - a ``"color"`` string The functions :meth:`rectangle` and :meth:`box` will accept any ``(x, y, w, h)`` sequence for their ``rect`` argument, though :mod:`pygame.Rect` instances are @@ -43,17 +47,6 @@ For example: pygame.gfxdraw.filled_circle(surf, x, y, 30, col) -.. note:: - For threading, each of the functions releases the GIL during the C part of - the call. - -.. note:: - See the :mod:`pygame.draw` module for alternative draw methods. - The ``pygame.gfxdraw`` module differs from the :mod:`pygame.draw` module in - the API it uses and the different draw functions available. - ``pygame.gfxdraw`` wraps the primitives from the library called SDL_gfx, - rather than using modified versions. - .. versionaddedold:: 1.9.0 @@ -74,6 +67,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.Surface.set_at` instead. + .. ## pygame.gfxdraw.pixel ## .. function:: hline @@ -95,6 +90,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.line` instead. + .. ## pygame.gfxdraw.hline ## .. function:: vline @@ -116,6 +113,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.line` instead. + .. ## pygame.gfxdraw.vline ## .. function:: line @@ -138,6 +137,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.line` instead. + .. ## pygame.gfxdraw.line ## .. function:: rectangle @@ -162,6 +163,8 @@ For example: always lie one pixel outside of its actual border. Therefore, these values will not be included as part of the drawing. + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.rect` instead. + .. ## pygame.gfxdraw.rectangle ## .. function:: box @@ -192,6 +195,8 @@ For example: accelerated on some platforms with both software and hardware display modes. + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.rect` instead. + .. ## pygame.gfxdraw.box ## .. function:: circle @@ -213,6 +218,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.circle` instead. + .. ## pygame.gfxdraw.circle ## .. function:: aacircle @@ -233,6 +240,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.aacircle` instead. + .. ## pygame.gfxdraw.aacircle ## .. function:: filled_circle @@ -254,6 +263,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.circle` instead. + .. ## pygame.gfxdraw.filled_circle ## .. function:: ellipse @@ -276,6 +287,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.ellipse` instead. + .. ## pygame.gfxdraw.ellipse ## .. function:: aaellipse @@ -297,6 +310,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.aaellipse` instead. + .. ## pygame.gfxdraw.aaellipse ## .. function:: filled_ellipse @@ -319,6 +334,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.ellipse` instead. + .. ## pygame.gfxdraw.filled_ellipse ## .. function:: arc @@ -347,6 +364,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.arc` instead. + .. note:: This function uses *degrees* while the :func:`pygame.draw.arc` function uses *radians*. @@ -380,6 +399,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.arc` and `pygame.draw.line` instead. + .. ## pygame.gfxdraw.pie ## .. function:: trigon @@ -407,6 +428,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.polygon` instead. + .. ## pygame.gfxdraw.trigon ## .. function:: aatrigon @@ -433,6 +456,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.aalines` instead. + .. ## pygame.gfxdraw.aatrigon ## .. function:: filled_trigon @@ -460,6 +485,8 @@ For example: :returns: ``None`` :rtype: NoneType + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.polygon` instead. + .. ## pygame.gfxdraw.filled_trigon ## .. function:: polygon @@ -493,6 +520,8 @@ For example: :raises IndexError: if ``len(coordinate) < 2`` (each coordinate must have at least 2 items) + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.polygon` instead. + .. ## pygame.gfxdraw.polygon ## .. function:: aapolygon @@ -525,6 +554,8 @@ For example: :raises IndexError: if ``len(coordinate) < 2`` (each coordinate must have at least 2 items) + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.aalines` instead. + .. ## pygame.gfxdraw.aapolygon ## .. function:: filled_polygon @@ -558,6 +589,8 @@ For example: :raises IndexError: if ``len(coordinate) < 2`` (each coordinate must have at least 2 items) + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.polygon` instead. + .. ## pygame.gfxdraw.filled_polygon ## .. function:: textured_polygon @@ -595,6 +628,8 @@ For example: :raises IndexError: if ``len(coordinate) < 2`` (each coordinate must have at least 2 items) + .. deprecated:: GFX_DEPRECATED_VERSION + .. ## pygame.gfxdraw.textured_polygon ## .. function:: bezier @@ -626,6 +661,8 @@ For example: .. note:: This function supports up to around 150-200 points before the algorithm breaks down. + .. deprecated:: GFX_DEPRECATED_VERSION Use :mod:`pygame.draw.bezier` instead. + .. ## pygame.gfxdraw.bezier ## .. ## pygame.gfxdraw ## diff --git a/docs/reST/themes/classic/elements.html b/docs/reST/themes/classic/elements.html index 486525a5db..b0d160fac7 100644 --- a/docs/reST/themes/classic/elements.html +++ b/docs/reST/themes/classic/elements.html @@ -39,8 +39,8 @@
pygame-ce documentation
#} {%- set basic = ['Color', 'display', 'draw', 'event', 'font', 'image', 'key', 'locals', 'mixer', 'mouse', 'music', 'pygame', 'Rect', 'Surface', 'time'] %} -{%- set advanced = ['BufferProxy', 'freetype', 'gfxdraw', 'midi', 'PixelArray', 'pixelcopy', 'sndarray', 'surfarray', 'cursors', 'joystick', 'mask', 'math', 'sprite', 'transform'] %} -{%- set hidden = ['sdl2_video', 'sdl2_controller', 'geometry', 'Window'] %} +{%- set advanced = ['BufferProxy', 'freetype', 'midi', 'PixelArray', 'pixelcopy', 'sndarray', 'surfarray', 'cursors', 'joystick', 'mask', 'math', 'sprite', 'transform'] %} +{%- set hidden = ['sdl2_video', 'sdl2_controller', 'geometry', 'Window', 'gfxdraw'] %} {%- if pyg_sections %}

Most useful stuff: {% set sep = joiner(" | \n") %} diff --git a/src_py/gfxdraw.py b/src_py/gfxdraw.py index 9a129ef1bf..084e14aac3 100644 --- a/src_py/gfxdraw.py +++ b/src_py/gfxdraw.py @@ -53,20 +53,20 @@ def filled_ellipse(surface, x, y, rx, ry, color, /): pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2)) -def arc(surface, x, y, r, start_angle, atp_angle, color): +def arc(surface, x, y, r, start_angle, stop_angle, color): pygame.draw.arc( surface, color, (x - r, y - r, r * 2, r * 2), - -atp_angle * _pi_quo_180, + -stop_angle * _pi_quo_180, -start_angle * _pi_quo_180, 1, ) -def pie(surface, x, y, r, start_angle, atp_angle, color): +def pie(surface, x, y, r, start_angle, stop_angle, color): start = start_angle * _pi_quo_180 - end = atp_angle * _pi_quo_180 + end = stop_angle * _pi_quo_180 pygame.draw.arc( surface, color, From bbc0ae499bbbff157952caa8cf239db62b360e99 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Sun, 21 Jul 2024 16:04:37 +0200 Subject: [PATCH 6/8] Add docstrings --- src_py/gfxdraw.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src_py/gfxdraw.py b/src_py/gfxdraw.py index 084e14aac3..78fd244f64 100644 --- a/src_py/gfxdraw.py +++ b/src_py/gfxdraw.py @@ -7,53 +7,92 @@ def pixel(surface, x, y, color, /): + """pixel(surface, x, y, color, /) -> None + draw a pixel + """ surface.set_at((x, y), color) def hline(surface, x1, x2, y, color, /): + """hline(surface, x1, x2, y, color, /) -> None + draw a horizontal line + """ pygame.draw.line(surface, color, (x1, y), (x2, y)) def vline(surface, x, y1, y2, color, /): + """vline(surface, x, y1, y2, color, /) -> None + draw a vertical line + """ pygame.draw.line(surface, color, (x, y1), (x, y2)) def line(surface, x1, y1, x2, y2, color, /): + """line(surface, x1, y1, x2, y2, color, /) -> None + draw a line + """ pygame.draw.line(surface, color, (x1, y1), (x2, y2)) def rectangle(surface, rect, color, /): + """rectangle(surface, rect, color, /) -> None + draw a rectangle + """ pygame.draw.rect(surface, color, rect, 1) def box(surface, rect, color, /): + """box(surface, rect, color, /) -> None + draw a filled rectangle + """ pygame.draw.rect(surface, color, rect) def circle(surface, x, y, r, color, /): + """circle(surface, x, y, r, color, /) -> None + draw a circle + """ pygame.draw.circle(surface, color, (x, y), r, 1) def aacircle(surface, x, y, r, color, /): + """aacircle(surface, x, y, r, color, /) -> None + draw an antialiased circle + """ pygame.draw.aacircle(surface, color, (x, y), r, 1) def filled_circle(surface, x, y, r, color, /): + """filled_circle(surface, x, y, r, color, /) -> None + draw a filled circle + """ pygame.draw.circle(surface, color, (x, y), r) def ellipse(surface, x, y, rx, ry, color, /): + """ellipse(surface, x, y, rx, ry, color, /) -> None + draw an ellipse + """ pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2), 1) # missing feature for aaellipse: pygame.draw.aaellipse +"""aaellipse(surface, x, y, rx, ry, color, /) -> None +draw an antialiased ellipse +""" def filled_ellipse(surface, x, y, rx, ry, color, /): + """filled_ellipse(surface, x, y, rx, ry, color, /) -> None + draw a filled ellipse + """ pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2)) def arc(surface, x, y, r, start_angle, stop_angle, color): + """arc(surface, x, y, r, start_angle, stop_angle, color, /) -> None + draw an arc + """ pygame.draw.arc( surface, color, @@ -65,6 +104,9 @@ def arc(surface, x, y, r, start_angle, stop_angle, color): def pie(surface, x, y, r, start_angle, stop_angle, color): + """pie(surface, x, y, r, start_angle, stop_angle, color, /) -> None + draw a pie + """ start = start_angle * _pi_quo_180 end = stop_angle * _pi_quo_180 pygame.draw.arc( @@ -84,31 +126,55 @@ def pie(surface, x, y, r, start_angle, stop_angle, color): def trigon(surface, x1, y1, x2, y2, x3, y3, color, /): + """trigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None + draw a trigon/triangle + """ pygame.draw.polygon(surface, color, ((x1, y1), (x2, y2), (x3, y3)), 1) # replace with pygame.draw.aapolygon when possible def aatrigon(surface, x1, y1, x2, y2, x3, y3, color, /): + """aatrigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None + draw an antialiased trigon/triangle + """ pygame.draw.aalines(surface, color, True, ((x1, y1), (x2, y2), (x3, y3))) def filled_trigon(surface, x1, y1, x2, y2, x3, y3, color, /): + """filled_trigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None + draw a filled trigon/triangle + """ pygame.draw.polygon(surface, color, ((x1, y1), (x2, y2), (x3, y3))) def polygon(surface, points, color, /): + """polygon(surface, points, color, /) -> None + draw a polygon + """ pygame.draw.polygon(surface, color, points, 1) # replace with pygame.draw.aapolygon when possible def aapolygon(surface, points, color, /): + """aapolygon(surface, points, color, /) -> None + draw an antialiased polygon + """ pygame.draw.aalines(surface, color, True, points) def filled_polygon(surface, points, color, /): + """filled_polygon(surface, points, color, /) -> None + draw a filled polygon + """ pygame.draw.polygon(surface, color, points) # don't know how to shim: textured_polygon +"""textured_polygon(surface, points, texture, tx, ty, /) -> None +draw a textured polygon +""" # missing feature for bezier: pygame.draw.bezier +"""bezier(surface, points, steps, color, /) -> None +draw a Bezier curve +""" From 6bb6458833013e679c33ddf13cb82b2db84a0ee3 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Sun, 21 Jul 2024 16:23:21 +0200 Subject: [PATCH 7/8] Add runtime deprecation warning --- docs/reST/ref/gfxdraw.rst | 7 ++--- src_py/gfxdraw.py | 66 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/docs/reST/ref/gfxdraw.rst b/docs/reST/ref/gfxdraw.rst index e11ed85261..a9c99b2b5e 100644 --- a/docs/reST/ref/gfxdraw.rst +++ b/docs/reST/ref/gfxdraw.rst @@ -8,11 +8,8 @@ | :sl:`pygame module for drawing shapes` -**EXPERIMENTAL!**: This API may change or disappear in later pygame releases. If -you use this, your code may break with the next pygame release. - -The gfxdraw module is now deprecated in favor of the draw module and all its -functions are deprecated. +**DEPRECATED!**: The gfxdraw module is now deprecated in favor of the draw module +and all its functions are also deprecated. The pygame package does not import gfxdraw automatically when loaded, so it must imported explicitly to be used. diff --git a/src_py/gfxdraw.py b/src_py/gfxdraw.py index 78fd244f64..ed87395f94 100644 --- a/src_py/gfxdraw.py +++ b/src_py/gfxdraw.py @@ -1,11 +1,16 @@ -import pygame +from typing_extensions import deprecated import math as _math + +import pygame from pygame._gfxdraw import * # pylint: disable=wildcard-import,unused-wildcard-import; lgtm[py/polluting-import] _pi_quo_180 = 0.01745329251994329577 +@deprecated( + "The function `pixel` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.Surface.set_at` instead" +) def pixel(surface, x, y, color, /): """pixel(surface, x, y, color, /) -> None draw a pixel @@ -13,6 +18,9 @@ def pixel(surface, x, y, color, /): surface.set_at((x, y), color) +@deprecated( + "The function `hline` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead" +) def hline(surface, x1, x2, y, color, /): """hline(surface, x1, x2, y, color, /) -> None draw a horizontal line @@ -20,6 +28,9 @@ def hline(surface, x1, x2, y, color, /): pygame.draw.line(surface, color, (x1, y), (x2, y)) +@deprecated( + "The function `vline` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead" +) def vline(surface, x, y1, y2, color, /): """vline(surface, x, y1, y2, color, /) -> None draw a vertical line @@ -27,6 +38,9 @@ def vline(surface, x, y1, y2, color, /): pygame.draw.line(surface, color, (x, y1), (x, y2)) +@deprecated( + "The function `line` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead" +) def line(surface, x1, y1, x2, y2, color, /): """line(surface, x1, y1, x2, y2, color, /) -> None draw a line @@ -34,6 +48,9 @@ def line(surface, x1, y1, x2, y2, color, /): pygame.draw.line(surface, color, (x1, y1), (x2, y2)) +@deprecated( + "The function `rectangle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.rect` instead" +) def rectangle(surface, rect, color, /): """rectangle(surface, rect, color, /) -> None draw a rectangle @@ -41,6 +58,9 @@ def rectangle(surface, rect, color, /): pygame.draw.rect(surface, color, rect, 1) +@deprecated( + "The function `box` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.rect` instead" +) def box(surface, rect, color, /): """box(surface, rect, color, /) -> None draw a filled rectangle @@ -48,6 +68,9 @@ def box(surface, rect, color, /): pygame.draw.rect(surface, color, rect) +@deprecated( + "The function `circle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.circle` instead" +) def circle(surface, x, y, r, color, /): """circle(surface, x, y, r, color, /) -> None draw a circle @@ -55,6 +78,9 @@ def circle(surface, x, y, r, color, /): pygame.draw.circle(surface, color, (x, y), r, 1) +@deprecated( + "The function `aacircle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.aacircle` instead" +) def aacircle(surface, x, y, r, color, /): """aacircle(surface, x, y, r, color, /) -> None draw an antialiased circle @@ -62,6 +88,9 @@ def aacircle(surface, x, y, r, color, /): pygame.draw.aacircle(surface, color, (x, y), r, 1) +@deprecated( + "The function `filled_circle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.circle` instead" +) def filled_circle(surface, x, y, r, color, /): """filled_circle(surface, x, y, r, color, /) -> None draw a filled circle @@ -69,6 +98,9 @@ def filled_circle(surface, x, y, r, color, /): pygame.draw.circle(surface, color, (x, y), r) +@deprecated( + "The function `ellipse` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.ellipse` instead" +) def ellipse(surface, x, y, rx, ry, color, /): """ellipse(surface, x, y, rx, ry, color, /) -> None draw an ellipse @@ -77,11 +109,15 @@ def ellipse(surface, x, y, rx, ry, color, /): # missing feature for aaellipse: pygame.draw.aaellipse +# @deprecated("The function `aaellipse` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.aaellipse` instead") # not implemented yet """aaellipse(surface, x, y, rx, ry, color, /) -> None draw an antialiased ellipse """ +@deprecated( + "The function `filled_ellipse` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.ellipse` instead" +) def filled_ellipse(surface, x, y, rx, ry, color, /): """filled_ellipse(surface, x, y, rx, ry, color, /) -> None draw a filled ellipse @@ -89,6 +125,9 @@ def filled_ellipse(surface, x, y, rx, ry, color, /): pygame.draw.ellipse(surface, color, (x - rx, y - ry, rx * 2, ry * 2)) +@deprecated( + "The function `arc` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.arc` instead" +) def arc(surface, x, y, r, start_angle, stop_angle, color): """arc(surface, x, y, r, start_angle, stop_angle, color, /) -> None draw an arc @@ -103,6 +142,9 @@ def arc(surface, x, y, r, start_angle, stop_angle, color): ) +@deprecated( + "The function `pie` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.arc` and `pygame.draw.line` instead" +) def pie(surface, x, y, r, start_angle, stop_angle, color): """pie(surface, x, y, r, start_angle, stop_angle, color, /) -> None draw a pie @@ -125,6 +167,9 @@ def pie(surface, x, y, r, start_angle, stop_angle, color): ) +@deprecated( + "The function `trigon` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead" +) def trigon(surface, x1, y1, x2, y2, x3, y3, color, /): """trigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None draw a trigon/triangle @@ -133,6 +178,9 @@ def trigon(surface, x1, y1, x2, y2, x3, y3, color, /): # replace with pygame.draw.aapolygon when possible +@deprecated( + "The function `aatrigon` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.aalines` instead" +) # should replace with aapolygon def aatrigon(surface, x1, y1, x2, y2, x3, y3, color, /): """aatrigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None draw an antialiased trigon/triangle @@ -140,6 +188,9 @@ def aatrigon(surface, x1, y1, x2, y2, x3, y3, color, /): pygame.draw.aalines(surface, color, True, ((x1, y1), (x2, y2), (x3, y3))) +@deprecated( + "The function `filled_trigon` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead" +) def filled_trigon(surface, x1, y1, x2, y2, x3, y3, color, /): """filled_trigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None draw a filled trigon/triangle @@ -147,6 +198,9 @@ def filled_trigon(surface, x1, y1, x2, y2, x3, y3, color, /): pygame.draw.polygon(surface, color, ((x1, y1), (x2, y2), (x3, y3))) +@deprecated( + "The function `polygon` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead" +) def polygon(surface, points, color, /): """polygon(surface, points, color, /) -> None draw a polygon @@ -155,6 +209,9 @@ def polygon(surface, points, color, /): # replace with pygame.draw.aapolygon when possible +@deprecated( + "The function `aapolygon` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.aalines` instead" +) # should replace with aapolygon def aapolygon(surface, points, color, /): """aapolygon(surface, points, color, /) -> None draw an antialiased polygon @@ -162,6 +219,9 @@ def aapolygon(surface, points, color, /): pygame.draw.aalines(surface, color, True, points) +@deprecated( + "The function `filled_polygon` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.polygon` instead" +) def filled_polygon(surface, points, color, /): """filled_polygon(surface, points, color, /) -> None draw a filled polygon @@ -170,11 +230,15 @@ def filled_polygon(surface, points, color, /): # don't know how to shim: textured_polygon +# @deprecated("The function `textured_polygon` is deprecated since GFX_DEPRECATED_VERSION.") """textured_polygon(surface, points, texture, tx, ty, /) -> None draw a textured polygon """ # missing feature for bezier: pygame.draw.bezier +# @deprecated("The function `bezier` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.bezier` instead") # not implemented yet """bezier(surface, points, steps, color, /) -> None draw a Bezier curve """ + +del deprecated From 24a619c4203ae79ea4418479d51b18678d23cbe8 Mon Sep 17 00:00:00 2001 From: Damiano Ricciardi Date: Sun, 21 Jul 2024 16:29:20 +0200 Subject: [PATCH 8/8] Shorten strings. --- src_py/gfxdraw.py | 48 ++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src_py/gfxdraw.py b/src_py/gfxdraw.py index ed87395f94..81e939ba9e 100644 --- a/src_py/gfxdraw.py +++ b/src_py/gfxdraw.py @@ -9,7 +9,8 @@ @deprecated( - "The function `pixel` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.Surface.set_at` instead" + "The function `pixel` is deprecated since GFX_DEPRECATED_VERSION." + "Use `pygame.Surface.set_at` instead" ) def pixel(surface, x, y, color, /): """pixel(surface, x, y, color, /) -> None @@ -19,7 +20,8 @@ def pixel(surface, x, y, color, /): @deprecated( - "The function `hline` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead" + "The function `hline` is deprecated since GFX_DEPRECATED_VERSION." + "Use `pygame.draw.line` instead" ) def hline(surface, x1, x2, y, color, /): """hline(surface, x1, x2, y, color, /) -> None @@ -29,7 +31,8 @@ def hline(surface, x1, x2, y, color, /): @deprecated( - "The function `vline` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead" + "The function `vline` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.line` instead" ) def vline(surface, x, y1, y2, color, /): """vline(surface, x, y1, y2, color, /) -> None @@ -39,7 +42,8 @@ def vline(surface, x, y1, y2, color, /): @deprecated( - "The function `line` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.line` instead" + "The function `line` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.line` instead" ) def line(surface, x1, y1, x2, y2, color, /): """line(surface, x1, y1, x2, y2, color, /) -> None @@ -49,7 +53,8 @@ def line(surface, x1, y1, x2, y2, color, /): @deprecated( - "The function `rectangle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.rect` instead" + "The function `rectangle` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.rect` instead" ) def rectangle(surface, rect, color, /): """rectangle(surface, rect, color, /) -> None @@ -59,7 +64,8 @@ def rectangle(surface, rect, color, /): @deprecated( - "The function `box` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.rect` instead" + "The function `box` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.rect` instead" ) def box(surface, rect, color, /): """box(surface, rect, color, /) -> None @@ -69,7 +75,8 @@ def box(surface, rect, color, /): @deprecated( - "The function `circle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.circle` instead" + "The function `circle` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.circle` instead" ) def circle(surface, x, y, r, color, /): """circle(surface, x, y, r, color, /) -> None @@ -79,7 +86,8 @@ def circle(surface, x, y, r, color, /): @deprecated( - "The function `aacircle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.aacircle` instead" + "The function `aacircle` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.aacircle` instead" ) def aacircle(surface, x, y, r, color, /): """aacircle(surface, x, y, r, color, /) -> None @@ -89,7 +97,8 @@ def aacircle(surface, x, y, r, color, /): @deprecated( - "The function `filled_circle` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.circle` instead" + "The function `filled_circle` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.circle` instead" ) def filled_circle(surface, x, y, r, color, /): """filled_circle(surface, x, y, r, color, /) -> None @@ -99,7 +108,8 @@ def filled_circle(surface, x, y, r, color, /): @deprecated( - "The function `ellipse` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.ellipse` instead" + "The function `ellipse` is deprecated since GFX_DEPRECATED_VERSION. " + "Use `pygame.draw.ellipse` instead" ) def ellipse(surface, x, y, rx, ry, color, /): """ellipse(surface, x, y, rx, ry, color, /) -> None @@ -110,9 +120,9 @@ def ellipse(surface, x, y, rx, ry, color, /): # missing feature for aaellipse: pygame.draw.aaellipse # @deprecated("The function `aaellipse` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.aaellipse` instead") # not implemented yet -"""aaellipse(surface, x, y, rx, ry, color, /) -> None -draw an antialiased ellipse -""" +# """aaellipse(surface, x, y, rx, ry, color, /) -> None +# draw an antialiased ellipse +# """ @deprecated( @@ -231,14 +241,14 @@ def filled_polygon(surface, points, color, /): # don't know how to shim: textured_polygon # @deprecated("The function `textured_polygon` is deprecated since GFX_DEPRECATED_VERSION.") -"""textured_polygon(surface, points, texture, tx, ty, /) -> None -draw a textured polygon -""" +# """textured_polygon(surface, points, texture, tx, ty, /) -> None +# draw a textured polygon +# """ # missing feature for bezier: pygame.draw.bezier # @deprecated("The function `bezier` is deprecated since GFX_DEPRECATED_VERSION. Use `pygame.draw.bezier` instead") # not implemented yet -"""bezier(surface, points, steps, color, /) -> None -draw a Bezier curve -""" +# """bezier(surface, points, steps, color, /) -> None +# draw a Bezier curve +# """ del deprecated