This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 2f824b15387739be5c32dd417b6fabbf54234bc8 (commit) via 0c88946ef930d04eb2c3ea3afe202ab8248150b4 (commit) from 36a72a1ec467da8e2b49ed57e98be58f911d01f7 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/2f824b15387739be5c32dd417b6fabbf54234...
commit 2f824b15387739be5c32dd417b6fabbf54234bc8 Merge: 0c88946 36a72a1 Author: BlueBear jiri.bluebear.dluhos@gmail.com Date: Sun Dec 11 15:03:47 2011 +0100
Merge branch 'master' of git://repo.or.cz/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/0c88946ef930d04eb2c3ea3afe202ab824815...
commit 0c88946ef930d04eb2c3ea3afe202ab8248150b4 Author: BlueBear jiri.bluebear.dluhos@gmail.com Date: Sun Dec 11 15:03:04 2011 +0100
Added first support for arcs (currently with very strange syntax).
diff --git a/include/gfx/GP_Arc.h b/include/gfx/GP_Arc.h new file mode 100644 index 0000000..dfec46e --- /dev/null +++ b/include/gfx/GP_Arc.h @@ -0,0 +1,48 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim 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 * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#ifndef GP_ARC_H +#define GP_ARC_H + +#include "core/GP_Context.h" + +#define GP_QUADRANT_MINUSMINUS 1 +#define GP_QUADRANT_PLUSMINUS 2 +#define GP_QUADRANT_MINUSPLUS 4 +#define GP_QUADRANT_PLUSPLUS 8 + +void GP_Arc(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, int quadrant_mask, + int low_dx, int low_dy, + int high_dx, int high_dy, + GP_Pixel pixel); + +void GP_Arc_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, int quadrant_mask, + int low_dx, int low_dy, + int high_dx, int high_dy, + GP_Pixel pixel); + +#endif /* GP_ARC_H */ diff --git a/libs/gfx/GP_Arc.c b/libs/gfx/GP_Arc.c new file mode 100644 index 0000000..c64d94d --- /dev/null +++ b/libs/gfx/GP_Arc.c @@ -0,0 +1,63 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim 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 * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include "GP_Gfx.h" +#include "core/GP_FnPerBpp.h" + +#include "algo/Arc.algo.h" + +/* Generate drawing functions for various bit depths. */ +GP_DEF_DRAW_FN_PER_BPP(GP_Arc_Raw, DEF_ARC_FN) + +void GP_Arc_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, int quadrant_mask, + int low_dx, int low_dy, + int high_dx, int high_dy, + GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_FN_PER_BPP_CONTEXT(GP_Arc_Raw, context, context, + xcenter, ycenter, a, b, quadrant_mask, + low_dx, low_dy, high_dx, high_dy, + pixel); +} + +void GP_Arc(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, int quadrant_mask, + int low_dx, int low_dy, + int high_dx, int high_dy, + GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + /* recalculate center point and swap a and b when axes are swapped */ + GP_TRANSFORM_POINT(context, xcenter, ycenter); + GP_TRANSFORM_SWAP(context, a, b); + + GP_Arc_Raw(context, xcenter, ycenter, a, b, quadrant_mask, + low_dx, low_dy, high_dx, high_dy, + pixel); +} diff --git a/libs/gfx/algo/Arc.algo.h b/libs/gfx/algo/Arc.algo.h new file mode 100644 index 0000000..1681ce8 --- /dev/null +++ b/libs/gfx/algo/Arc.algo.h @@ -0,0 +1,84 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim 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 * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +/* + * The elliptical arc algorithm; a generalization of an ellipse that allows + * to draw only part of it. The math is exactly the same, only it has + * additional tests of what part to draw. + */ + +/* + * This macro defines an elliptic arc drawing function. + * Arguments: + * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL) + * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) + * PUTPIXEL - a pixel drawing function f(context, x, y, pixval) + * FN_NAME - name of the function to be defined + */ +#define DEF_ARC_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, + unsigned int a, unsigned int b, int quadrant_mask, + int low_dx, int low_dy, int high_dx, int high_dy, + PIXVAL_T pixval) +{ + /* Precompute quadratic terms. */ + int a2 = a*a; + int b2 = b*b; ++ int x, y, error; + for (x = 0, error = -b2*a, y = b; y >= 0; y--) { + while (error < 0) { ++ /* Calculate error(x+1) from error(x). */ + error += 2*x*b2 + b2; + x++; ++ if ((x*low_dy >= y*low_dx) && (x*high_dy <= y*high_dx)) { + if (quadrant_mask & GP_QUADRANT_MINUSMINUS) + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + if (quadrant_mask & GP_QUADRANT_PLUSMINUS) + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); + if (quadrant_mask & GP_QUADRANT_MINUSPLUS) + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + if (quadrant_mask & GP_QUADRANT_PLUSPLUS) + PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + } + } ++ /* Calculate error(y-1) from error(y). */ + error += -2*y*a2 + a2; ++ if ((x*low_dy >= y*low_dx) && (x*high_dy <= y*high_dx)) { + if (quadrant_mask & GP_QUADRANT_MINUSMINUS) + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + if (quadrant_mask & GP_QUADRANT_PLUSMINUS) + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); + if (quadrant_mask & GP_QUADRANT_MINUSPLUS) + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + if (quadrant_mask & GP_QUADRANT_PLUSPLUS) + PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + } + } +}
-----------------------------------------------------------------------
Summary of changes: include/gfx/{GP_Line.h => GP_Arc.h} | 25 ++++++--- libs/gfx/{GP_Line.c => GP_Arc.c} | 33 ++++++++---- libs/gfx/algo/{Ellipse.algo.h => Arc.algo.h} | 76 ++++++++++---------------- 3 files changed, 68 insertions(+), 66 deletions(-) copy include/gfx/{GP_Line.h => GP_Arc.h} (77%) copy libs/gfx/{GP_Line.c => GP_Arc.c} (68%) copy libs/gfx/algo/{Ellipse.algo.h => Arc.algo.h} (59%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.