Mercurial > audlegacy-plugins
annotate src/paranormal/drawing.c @ 3024:965c0df4ae84
Patch from John Lindgren to skip corrupted frames, from Debian bug #514674.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Thu, 09 Apr 2009 23:58:13 +0100 |
parents | f1b6f1b2cdb3 |
children |
rev | line source |
---|---|
1892
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
1 /* |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
2 * paranormal: iterated pipeline-driven visualization plugin |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
3 * Copyright (c) 2006, 2007 William Pitcock <nenolod@dereferenced.org> |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
4 * Portions copyright (c) 2001 Jamie Gennis <jgennis@mindspring.com> |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
5 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
8 * the Free Software Foundation; under version 2 of the License. |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
9 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
13 * GNU General Public License for more details. |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
14 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
2835 | 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
1892
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
18 */ |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
1174
diff
changeset
|
19 |
193 | 20 #include <math.h> |
21 | |
192 | 22 #include "paranormal.h" |
23 #include "actuators.h" | |
24 #include "pn_utils.h" | |
25 | |
26 void | |
304
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
27 pn_draw_dot (guint x, guint y, guchar value) |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
28 { |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
29 if (x > pn_image_data->width || x < 0 || y > pn_image_data->height || y < 0) |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
30 return; |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
31 |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
32 pn_image_data->surface[0][PN_IMG_INDEX(x, y)] = value; |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
33 } |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
34 |
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
35 void |
192 | 36 pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value) |
37 { | |
38 gint x0 = _x0; | |
39 gint y0 = _y0; | |
40 gint x1 = _x1; | |
41 gint y1 = _y1; | |
42 | |
193 | 43 gint dx = x1 - x0; |
192 | 44 gint dy = y1 - y0; |
45 | |
304
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
46 pn_draw_dot(x0, y0, value); |
193 | 47 |
48 if (dx != 0) | |
192 | 49 { |
193 | 50 gfloat m = (gfloat) dy / (gfloat) dx; |
51 gfloat b = y0 - m * x0; | |
52 | |
53 dx = (x1 > x0) ? 1 : - 1; | |
192 | 54 while (x0 != x1) |
193 | 55 { |
56 x0 += dx; | |
268 | 57 y0 = m * x0 + b; |
193 | 58 |
304
3d0b7ca9c8eb
[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
nenolod
parents:
298
diff
changeset
|
59 pn_draw_dot(x0, y0, value); |
193 | 60 } |
192 | 61 } |
62 } |