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 ccc06e628a27ed616222e32e32f0378644e0aae0 (commit) via 72671e58dfa51460b3328d901326fe217f0c2f8c (commit) from 1d8b9f67ffd1b38ef96f2b19ced13fba548c6fcb (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/ccc06e628a27ed616222e32e32f0378644e0a...
commit ccc06e628a27ed616222e32e32f0378644e0aae0 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 26 00:33:38 2013 +0100
demos: Add GP_HLineAA demo.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index cb6fe82..782eee2 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -18,7 +18,7 @@ APPS=backend_example loaders_example loaders filters_symmetry gfx_koch virtual_backend_example meta_data meta_data_dump tmp_file showimage v4l2_show v4l2_grab convolution weighted_median shapetest koch input_example fileview linetest randomshapetest fonttest- loaders_register blittest textaligntest abort + loaders_register blittest textaligntest abort sin_AA
ifeq ($(HAVE_LIBSDL),yes) APPS+=SDL_glue diff --git a/demos/c_simple/sin_AA.c b/demos/c_simple/sin_AA.c new file mode 100644 index 0000000..94b3563 --- /dev/null +++ b/demos/c_simple/sin_AA.c @@ -0,0 +1,126 @@ +/***************************************************************************** + * 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-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +/* + + Simple example that shows HLineAA() usage. + + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> + +#include <GP.h> + +static void redraw(GP_Context *context) +{ + static float param = 1; + static float param2 = 0.01; + static int flag = 1; + GP_Pixel b = GP_RGBToContextPixel(0xbe, 0xbe, 0x9e, context); + unsigned int y; + + GP_Fill(context, b); + + for (y = 0; y < context->w; y++) { + GP_Coord x0, x1, l1, l2; + + x0 = (context->w)<<7; + x1 = (context->w)<<7; + + l1 = (context->w)<<5; + l2 = (context->w)<<3; + + GP_Pixel p = GP_RGBToContextPixel(120 - 3 * param, abs(40 * param), 0, context); + + l2 *= 4.00 * y / context->h; + + l1 *= param; + + x0 += l1 * sin(param2 * y) + l2; + x1 -= l1 * cos(param2 * y) + l2; + + GP_HLineAA(context, x0, x1, y<<8, p); + } + + if (flag) { + param -= 0.02; + + if (param <= -2.40) { + flag = 0; + param2 += 0.01; + + if (param2 > 0.02) + param2 = 0.01; + } + } else { + param += 0.02; + + if (param >= 2.40) + flag = 1; + } +} + +int main(void) +{ + GP_Backend *backend; + static int pause_flag = 0; + + /* Initalize backend */ + backend = GP_BackendX11Init(NULL, 0, 0, 800, 600, "sin AA", 0); + + if (backend == NULL) { + fprintf(stderr, "Failed to initalize backendn"); + return 1; + } + + /* Wait for events */ + for (;;) { + if (!pause_flag) { + redraw(backend->context); + GP_BackendFlip(backend); + } + + GP_BackendPoll(backend); + + GP_Event ev; + + while (GP_EventGet(&ev)) { + if (ev.type == GP_EV_KEY && ev.code == GP_EV_KEY_DOWN) { + switch (ev.val.val) { + case GP_KEY_ESC: + case GP_KEY_Q: + GP_BackendExit(backend); + return 0; + case GP_KEY_P: + pause_flag = !pause_flag; + break; + } + } + } + + usleep(10000); + } + + return 0; +}
http://repo.or.cz/w/gfxprim.git/commit/72671e58dfa51460b3328d901326fe217f0c2...
commit 72671e58dfa51460b3328d901326fe217f0c2f8c Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 26 00:24:51 2013 +0100
gfx: Fix typos in previous commit.
diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t index dac3b8d..8d3240d 100644 --- a/libs/gfx/GP_HLineAA.gen.c.t +++ b/libs/gfx/GP_HLineAA.gen.c.t @@ -57,7 +57,7 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord int_x1 = TO_X_E(x1); GP_Coord int_y = GP_FP_FLOOR_TO_INT(y);
- printf("%f %f %f -> %i %i %in", GP_FP_TO_FLOAT(x0), GP_FP_TO_FLOAT(x1), GP_FP_TO_FLOAT(y), int_x0, int_x1, int_y); +// printf("%f %f %f -> %i %i %in", GP_FP_TO_FLOAT(x0), GP_FP_TO_FLOAT(x1), GP_FP_TO_FLOAT(y), int_x0, int_x1, int_y);
/* Draw the four starting and ending pixels */ unsigned int perc; @@ -72,7 +72,7 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc);
if (int_x0 != int_x1) { - w = GP_FP_RFRAC(x0 + GP_FP_1_2); + w = GP_FP_FRAC(x1 + GP_FP_1_2);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), w)); GP_MixPixel_Raw_Clipped(context, int_x1, int_y, pixel, perc);
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/Makefile | 2 +- demos/c_simple/{showimage.c => sin_AA.c} | 96 ++++++++++++++++++++++-------- libs/gfx/GP_HLineAA.gen.c.t | 4 +- 3 files changed, 73 insertions(+), 29 deletions(-) copy demos/c_simple/{showimage.c => sin_AA.c} (57%)
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.