Mercurial > audlegacy-plugins
annotate src/paranormal/drawing.c @ 1420:40136e537bd9
wav: update to new tuple API.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 10 Aug 2007 06:23:10 -0500 |
parents | 8aab955fb114 |
children | 3b034150d31e |
rev | line source |
---|---|
193 | 1 #include <math.h> |
2 | |
192 | 3 #include "paranormal.h" |
4 #include "actuators.h" | |
5 #include "pn_utils.h" | |
6 | |
7 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
|
8 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
|
9 { |
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
|
10 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
|
11 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
|
12 |
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
|
13 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
|
14 } |
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
|
15 |
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
|
16 void |
192 | 17 pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value) |
18 { | |
19 gint x0 = _x0; | |
20 gint y0 = _y0; | |
21 gint x1 = _x1; | |
22 gint y1 = _y1; | |
23 | |
193 | 24 gint dx = x1 - x0; |
192 | 25 gint dy = y1 - y0; |
26 | |
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(x0, y0, value); |
193 | 28 |
29 if (dx != 0) | |
192 | 30 { |
193 | 31 gfloat m = (gfloat) dy / (gfloat) dx; |
32 gfloat b = y0 - m * x0; | |
33 | |
34 dx = (x1 > x0) ? 1 : - 1; | |
192 | 35 while (x0 != x1) |
193 | 36 { |
37 x0 += dx; | |
268 | 38 y0 = m * x0 + b; |
193 | 39 |
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
|
40 pn_draw_dot(x0, y0, value); |
193 | 41 } |
192 | 42 } |
43 } |