annotate src/paranormal/drawing.c @ 2284:d19b53359b24

cleaned up the sndfile wav plugin, currently limiting it ONLY TO WAV PLAYBACK. if somebody is more experienced with it and wants to restore the other formats, go ahead (maybe change the name of the plugin too?).
author mf0102 <0102@gmx.at>
date Wed, 09 Jan 2008 15:41:22 +0100
parents 3b034150d31e
children f1b6f1b2cdb3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3b034150d31e Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents: 1174
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
20 #include <math.h>
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
21
192
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
22 #include "paranormal.h"
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
23 #include "actuators.h"
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
24 #include "pn_utils.h"
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
25
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
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
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
36 pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value)
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
37 {
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
38 gint x0 = _x0;
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
39 gint y0 = _y0;
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
40 gint x1 = _x1;
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
41 gint y1 = _y1;
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
42
193
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
43 gint dx = x1 - x0;
192
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
44 gint dy = y1 - y0;
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
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
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
47
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
48 if (dx != 0)
192
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
49 {
193
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
50 gfloat m = (gfloat) dy / (gfloat) dx;
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
51 gfloat b = y0 - m * x0;
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
52
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
53 dx = (x1 > x0) ? 1 : - 1;
192
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
54 while (x0 != x1)
193
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
55 {
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
56 x0 += dx;
268
a1be19f8de1f [svn] - calculate FPS for frame limiter
nenolod
parents: 193
diff changeset
57 y0 = m * x0 + b;
193
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
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
4b48e6e9b3cb [svn] - rewrite line drawing algorithm for speed
nenolod
parents: 192
diff changeset
60 }
192
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
61 }
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents:
diff changeset
62 }