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/2f824b15387739be5c32dd417b6fabbf5423…
commit 2f824b15387739be5c32dd417b6fabbf54234bc8
Merge: 0c88946 36a72a1
Author: BlueBear <jiri.bluebear.dluhos(a)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/0c88946ef930d04eb2c3ea3afe202ab82481…
commit 0c88946ef930d04eb2c3ea3afe202ab8248150b4
Author: BlueBear <jiri.bluebear.dluhos(a)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(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)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(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 9800d72f27df325aa25aaa5b35851551ef010921 (commit)
from ee7841b92486c22488a2efcb8fe29ea8642f863c (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/9800d72f27df325aa25aaa5b35851551ef01…
commit 9800d72f27df325aa25aaa5b35851551ef010921
Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com>
Date: Sun Nov 27 21:30:48 2011 +0100
Slightly refined documentation for circles and ellipses.
diff --git a/doc/drawing_api.txt b/doc/drawing_api.txt
index 75a67e4..e73a07c 100644
--- a/doc/drawing_api.txt
+++ b/doc/drawing_api.txt
@@ -79,7 +79,10 @@ void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r, GP_Pixel pixel);
--------------------------------------------------------------------------------
-Draws a circle.
+Draws a circle centered at (xcenter, ycenter) with radius 'r' (in pixels).
+
+The circle is drawn so that all affected pixels will fit into a square
+specified by points (xcenter-r, ycenter-r, xcenter+r, ycenter+r), inclusive.
[source,c]
--------------------------------------------------------------------------------
@@ -89,6 +92,10 @@ void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
Draws a filled circle.
+The set of pixels affected by 'GP_FillCircle()' is exactly the same as if
+drawing the circle boundary using GP_Circle() and then filling all pixels
+within the boundary with the same color.
+
Rings
~~~~~
[source,c]
@@ -97,7 +104,10 @@ void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r1, GP_Size r2, GP_Pixel pixel);
--------------------------------------------------------------------------------
-Draws a ring.
+Draws a ring (two circles centered at (xcenter, ycenter) with radii 'r1' and 'r2').
+
+The result is exactly the same as calling 'GP_Circle()' with the same center
+and appropriate radii.
[source,c]
--------------------------------------------------------------------------------
@@ -119,7 +129,10 @@ void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, GP_Pixel pixel);
--------------------------------------------------------------------------------
-Draws an ellipse.
+Draws an axis-aligned ellipse.
+
+The ellipse is drawn so that all affected pixels will fit into a rectangle
+specified by points (xcenter-a, ycenter-b, xcenter+a, ycenter+b), inclusive.
[source,c]
--------------------------------------------------------------------------------
@@ -127,7 +140,7 @@ void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, GP_Pixel pixel);
--------------------------------------------------------------------------------
-Draws a filled ellipse.
+Draws a filled axis-aligned ellipse.
Triangles
~~~~~~~~~
-----------------------------------------------------------------------
Summary of changes:
doc/drawing_api.txt | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 ee7841b92486c22488a2efcb8fe29ea8642f863c (commit)
from c2d53d78b138cc441a28c025b8899f6d3b80f29e (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/ee7841b92486c22488a2efcb8fe29ea8642f…
commit ee7841b92486c22488a2efcb8fe29ea8642f863c
Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com>
Date: Sun Nov 27 20:23:07 2011 +0100
More precise documentation of line drawing functions and subcontexts.
diff --git a/doc/context.txt b/doc/context.txt
index a98d21a..38a8efb 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -99,8 +99,9 @@ void GP_ContextFree(GP_Context *context);
The 'GP_ContextAlloc()' allocates context and initalizes the context
structure. The orientation flags are all set to 0 and the rest of the metadata
-are calculated accordingly to width, height and pixel_type. The bitmap
-(context->pixels) is not initalized.
+are calculated accordingly to width, height and pixel_type. A bitmap with
+appropriate size is allocated and stored in context->pixels; the initial
+contents of the bitmap are undefined.
The 'GP_ContextCopy()' allocates and initalizes a copy of the context passed
as argument. If 'flag' is not zero, the bitmap (context->pixels) is copied
@@ -112,12 +113,12 @@ In both cases the resulting context should later be freed with
Subcontext
~~~~~~~~~~
-Given a rectangular area inside of any context subcontext could be created.
-The resulting context could be used for all context operations (including
-subcontext creation). The only difference between allocated context and
-subcontext of such context is that the 'GP_ContextFree()' doesn't call
-'free()' on subcontext pixels (which as a matter of a fact is a pointer that
-points somewhere into to allocated area).
+A subcontext is a context that refers to a rectangular area within another
+context. Subcontexts can be used as any other context (including creating
+another subcontexts).
+
+Calling GP_ContextFree() on a subcontext is safe; the bitmap is not freed as
+it belongs to another context; it will be freed with the hosting context.
[source,c]
-------------------------------------------------------------------------------
@@ -129,12 +130,12 @@ GP_Context *GP_ContextSubContext(GP_Context *context, GP_Context *subcontext,
Creates subcontext of a context. The rectangular area must fit into the context.
-If subcontext pointer is 'NULL' the context structure is allocated otherwise
+If subcontext pointer is 'NULL', the context structure is allocated; otherwise
the metadata are filled into the context structure pointed by subcontext
pointer.
-In both cases pointer to subcontext or NULL (in case of 'malloc(2)' failure) is
-returned.
+In both cases, the call returns either a pointer to the new subcontext,
+or NULL on failure (when there is not enough memory).
Conversions
~~~~~~~~~~~
diff --git a/doc/drawing_api.txt b/doc/drawing_api.txt
index 6cfd7e8..75a67e4 100644
--- a/doc/drawing_api.txt
+++ b/doc/drawing_api.txt
@@ -9,8 +9,8 @@ Fill
void GP_Fill(GP_Context *context, GP_Pixel pixel);
--------------------------------------------------------------------------------
-Fills the context bitmap. This has the same effect as calling
-'GP_FillRect(context, 0, 0, context->w, context->h, pixel)'.
+Fills the whole context bitmap with the specified pixel value. This has the
+same effect as calling 'GP_FillRect(context, 0, 0, context->w, context->h, pixel)'.
Lines
~~~~~
@@ -20,30 +20,45 @@ Lines
void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
GP_Pixel pixel);
-void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
- GP_Pixel pixel);
-
void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
GP_Pixel pixel);
--------------------------------------------------------------------------------
-Draws a horizontal line. The 'GP_HLine()' function is an alias for
-'GP_HLineXXY()'.
+Draws a horizontal line from (x0, y) to (x1, y), inclusive. The coordinates
+x0, x1 can be specified in any order.
+
+'GP_HLine()' is an alias for 'GP_HLineXXY()'.
[source,c]
--------------------------------------------------------------------------------
-void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1,
+void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
GP_Pixel pixel);
+--------------------------------------------------------------------------------
-void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h,
+Draws a horizontal line from (x, y) to (x+w-1, y), inclusive.
+
+
+[source,c]
+--------------------------------------------------------------------------------
+void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1,
GP_Pixel pixel);
void GP_VLine(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1,
GP_Pixel pixel);
--------------------------------------------------------------------------------
-Draws a vertical line. The 'GP_VLine()' function is an alias for
-'GP_VLineXYY()'.
+Draws a vertical line from (x, y0) to (x, y1), inclusive. The coordinates
+y0, y1 can be specified in any order.
+
+'GP_VLine()' is an alias for 'GP_VLineXYY()'.
+
+--------------------------------------------------------------------------------
+void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h,
+ GP_Pixel pixel);
+
+--------------------------------------------------------------------------------
+
+Draws a vertical line from (x, y) to (x, y+h-1), inclusive.
[source,c]
--------------------------------------------------------------------------------
@@ -51,7 +66,9 @@ void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
--------------------------------------------------------------------------------
-Draws a line from (x0, y0) to (x1, y1), inclusive.
+Draws a line from (x0, y0) to (x1, y1), inclusive. The starting and ending
+point can be specified in any order (the implementation guarantees that
+exactly the same set of pixels will be drawn in both cases).
Circles
~~~~~~~
-----------------------------------------------------------------------
Summary of changes:
doc/context.txt | 23 ++++++++++++-----------
doc/drawing_api.txt | 41 +++++++++++++++++++++++++++++------------
2 files changed, 41 insertions(+), 23 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")