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 66cbe1a3b25ba7d4c3361d420fa9de364c02557e (commit) from 446922190513e6535202e8f45ab897bc622390ee (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/66cbe1a3b25ba7d4c3361d420fa9de364c025...
commit 66cbe1a3b25ba7d4c3361d420fa9de364c02557e Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Sun Jan 22 19:46:51 2012 +0100
First implementation of partial ellipse (plus some angle-related utils).
diff --git a/include/core/GP_AngleUtils.h b/include/core/GP_AngleUtils.h new file mode 100644 index 0000000..f896b37 --- /dev/null +++ b/include/core/GP_AngleUtils.h @@ -0,0 +1,30 @@ +/***************************************************************************** + * 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 Cyril Hrubis metan@ucw.cz * + * Copyright (c) 2012 Jiri Dluhos jiri.bluebear.dluhos@gmail.com * + * * + *****************************************************************************/ + +#ifndef GP_ANGLE_UTILS_H +#define GP_ANGLE_UTILS_H + +double GP_NormalizeAngle(double phi); +int GP_AngleInRange(double angle, double start, double end); + +#endif No newline at end of file diff --git a/libs/core/GP_AngleUtils.c b/libs/core/GP_AngleUtils.c new file mode 100644 index 0000000..f1c279b --- /dev/null +++ b/libs/core/GP_AngleUtils.c @@ -0,0 +1,49 @@ +/***************************************************************************** + * 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) 2011 Tomas Gavenciak gavento@ucw.cz * + * Copyright (C) 2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2012 Jiri Dluhos jiri.bluebear.dluhos@gmail.com * + * * + *****************************************************************************/ + +#include "GP_AngleUtils.h" + +#include <math.h> + +double GP_NormalizeAngle(double phi) +{ + // clamp angle to <-2*pi, 2*pi> + double phi2 = fmod(phi, 2*M_PI); + + // clamp angle to <0, 2*pi> + if (phi2 < 0) + phi2 += 2*M_PI; + + return phi2; +} + +int GP_AngleInRange(double angle, double start, double end) +{ + if (start < end) { + return (angle >= start && angle <= end); + } else { + return (angle >= start && angle <= 2*M_PI) + || (angle >= 0 && angle <= end); + } +} No newline at end of file diff --git a/libs/gfx/GP_PartialEllipse.c b/libs/gfx/GP_PartialEllipse.c new file mode 100644 index 0000000..5415a58 --- /dev/null +++ b/libs/gfx/GP_PartialEllipse.c @@ -0,0 +1,53 @@ +/***************************************************************************** + * 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-2012 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include "GP_Gfx.h" +#include "core/GP_FnPerBpp.h" + +#include "algo/PartialEllipse.algo.h" + +/* Generate drawing functions for various bit depths. */ +GP_DEF_DRAW_FN_PER_BPP(GP_PartialEllipse_Raw, DEF_PARTIAL_ELLIPSE_FN) + +void GP_PartialEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, int start, int end, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_FN_PER_BPP_CONTEXT(GP_PartialEllipse_Raw, context, context, + xcenter, ycenter, a, b, start, end, pixel); +} + +void GP_PartialEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, int start, int end, 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_PartialEllipse_Raw(context, xcenter, ycenter, a, b, start, end, pixel); +} No newline at end of file diff --git a/libs/gfx/algo/PartialEllipse.algo.h b/libs/gfx/algo/PartialEllipse.algo.h new file mode 100644 index 0000000..b87826e --- /dev/null +++ b/libs/gfx/algo/PartialEllipse.algo.h @@ -0,0 +1,68 @@ +/***************************************************************************** + * 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 * + * * + *****************************************************************************/ + +#include "core/GP_AngleUtils.h" + +#include <math.h> + +/* + * This macro defines a partial ellipse 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_PARTIAL_ELLIPSE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int a, int b, + int start, int end, PIXVAL_T pixval) +{ + double startAngle = GP_NormalizeAngle(2*M_PI*(start / 360000.0)); + double endAngle = GP_NormalizeAngle(2*M_PI*(end / 360000.0)); ++ int x; + for (x = -a; x <= a; x++) { + double angle = acos(((double) x) / a); + double y = floor(b*sin(angle)); + if (GP_AngleInRange(angle, startAngle, endAngle)) { + PUTPIXEL(context, xcenter+x, ycenter-y, pixval); + } + if (GP_AngleInRange(2*M_PI - angle, startAngle, endAngle)) { + PUTPIXEL(context, xcenter+x, ycenter+y, pixval); + } + } ++ int y; + for (y = -b; y <= b; y++) { + double angle = asin(((double) y) / b); + double x = floor(a*cos(angle)); + if (GP_AngleInRange(angle, startAngle, endAngle)) { + PUTPIXEL(context, xcenter+x, ycenter-y, pixval); + } + if (GP_AngleInRange(M_PI - angle, startAngle, endAngle)) { + PUTPIXEL(context, x center-x, ycenter-y, pixval); + } + } +} No newline at end of file
-----------------------------------------------------------------------
Summary of changes: .../GP_DefaultFont.h => core/GP_AngleUtils.h} | 14 ++-- libs/core/{GP_GetPutPixel.c => GP_AngleUtils.c} | 38 ++++++----- libs/gfx/{GP_Arc.c => GP_PartialEllipse.c} | 34 ++++------ .../algo/{Line.algo.h => PartialEllipse.algo.h} | 72 ++++++++------------ 4 files changed, 69 insertions(+), 89 deletions(-) copy include/{text/GP_DefaultFont.h => core/GP_AngleUtils.h} (87%) copy libs/core/{GP_GetPutPixel.c => GP_AngleUtils.c} (74%) copy libs/gfx/{GP_Arc.c => GP_PartialEllipse.c} (73%) copy libs/gfx/algo/{Line.algo.h => PartialEllipse.algo.h} (66%)
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.