Mercurial > audlegacy-plugins
annotate src/paranormal/xform.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 | a509498d76b9 |
children | f1b6f1b2cdb3 |
rev | line source |
---|---|
1892
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
1 /* |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
2 * paranormal: iterated pipeline-driven visualization plugin |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
3 * Copyright (c) 2006, 2007 William Pitcock <nenolod@dereferenced.org> |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
4 * Portions copyright (c) 2001 Jamie Gennis <jgennis@mindspring.com> |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
5 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
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:
367
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:
367
diff
changeset
|
8 * the Free Software Foundation; under version 2 of the License. |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
9 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
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:
367
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
13 * GNU General Public License for more details. |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
14 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
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:
367
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:
367
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:
367
diff
changeset
|
18 */ |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
367
diff
changeset
|
19 |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
20 /* FIXME: allow for only using an xform on part of the img? */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
21 /* FIXME: perhaps combine these into a single vector field |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
22 so that only 1 apply_xform needs to be done for as many |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
23 of these as someone wants to use */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
24 |
1943
56bb18dd3fdd
paranormal: CONFIG_H removal
William Pitcock <nenolod@atheme.org>
parents:
1892
diff
changeset
|
25 #include <config.h> |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
26 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
27 #include <math.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
28 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
29 #include <glib.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
30 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
31 #include "paranormal.h" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
32 #include "actuators.h" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
33 #include "pn_utils.h" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
34 |
333 | 35 #include "libcalc/calc.h" |
36 | |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
37 struct xform_vector |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
38 { |
189
772ad5bc7050
[svn] - now working on amd64/little-endian. no idea how it was working in bigendian mode, though.
nenolod
parents:
188
diff
changeset
|
39 gint32 offset; /* the offset of the top left pixel */ |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
40 guint16 w; /* 4:4:4:4 NE, NW, SE, SW pixel weights |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
41 The total should be 16 */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
42 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
43 /* if offset < 0 then w is the color index to |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
44 which the pixel will be set */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
45 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
46 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
47 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
48 xfvec (float x, float y, struct xform_vector *v) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
49 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
50 float xd, yd; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
51 int weight[4]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
52 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
53 if (x >= pn_image_data->width-1 || y >= pn_image_data->height-1 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
54 || x < 0 || y < 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
55 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
56 v->offset = -1; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
57 v->w = 0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
58 return; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
59 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
60 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
61 v->offset = PN_IMG_INDEX (floor(x), floor(y)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
62 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
63 xd = x - floor (x); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
64 yd = y - floor (y); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
65 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
66 weight[3] = xd * yd * 16; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
67 weight[2] = (1-xd) * yd * 16; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
68 weight[1] = xd * (1-yd) * 16; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
69 weight[0] = 16 - weight[3] - weight[2] - weight[1]; /* just in case */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
70 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
71 v->w = (weight[0]<<12) | (weight[1]<<8) | (weight[2]<<4) | weight[3]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
72 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
73 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
74 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
75 apply_xform (struct xform_vector *vfield) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
76 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
77 int i; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
78 struct xform_vector *v; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
79 register guchar *srcptr; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
80 register guchar *destptr; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
81 register int color; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
82 |
334
a9f1bd76a3e6
[svn] - apply_xform(): check for NULL vfield (broken scripts)
nenolod
parents:
333
diff
changeset
|
83 if (vfield == NULL) |
a9f1bd76a3e6
[svn] - apply_xform(): check for NULL vfield (broken scripts)
nenolod
parents:
333
diff
changeset
|
84 return; |
a9f1bd76a3e6
[svn] - apply_xform(): check for NULL vfield (broken scripts)
nenolod
parents:
333
diff
changeset
|
85 |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
86 for (i=0, v=vfield, destptr=pn_image_data->surface[1]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
87 i<pn_image_data->width*pn_image_data->height; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
88 i++, v++, destptr++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
89 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
90 /* off the screen */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
91 if (v->offset < 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
92 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
93 *destptr = (guchar)v->w; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
94 continue; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
95 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
96 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
97 srcptr = pn_image_data->surface[0] + v->offset; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
98 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
99 /* exactly on the pixel */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
100 if (v->w == 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
101 *destptr = *srcptr; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
102 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
103 /* gotta blend the points */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
104 else |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
105 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
106 color = *srcptr * (v->w>>12); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
107 color += *++srcptr * ((v->w>>8) & 0x0f); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
108 color += *(srcptr+=pn_image_data->width) * (v->w & 0x0f); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
109 color += *(--srcptr) * ((v->w>>4) & 0x0f); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
110 color >>= 4; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
111 *destptr = (guchar)color; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
112 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
113 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
114 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
115 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
116 /* **************** xform_spin **************** */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
117 /* FIXME: Describe these better, how they are backwards */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
118 /* FIXME: better name? */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
119 struct pn_actuator_option_desc xform_spin_opts[] = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
120 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
121 { "angle", "The angle of rotation", OPT_TYPE_FLOAT, { fval: -8.0 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
122 { "r_add", "The number of pixels by which the r coordinate will be " |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
123 "increased (before scaling)", OPT_TYPE_FLOAT, { fval: 0.0 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
124 { "r_scale", "The amount by which the r coordinate of each pixel will " |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
125 "be scaled", OPT_TYPE_FLOAT, { fval: 1.0 } }, |
188 | 126 { NULL } |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
127 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
128 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
129 struct xform_spin_data |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
130 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
131 int width, height; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
132 struct xform_vector *vfield; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
133 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
134 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
135 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
136 xform_spin_init (gpointer *data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
137 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
138 *data = g_new0 (struct xform_spin_data, 1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
139 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
140 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
141 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
142 xform_spin_cleanup (gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
143 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
144 struct xform_spin_data *d = (struct xform_spin_data *) data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
145 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
146 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
147 if (d) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
148 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
149 if (d->vfield) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
150 g_free (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
151 g_free (d); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
152 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
153 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
154 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
155 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
156 xform_spin_exec (const struct pn_actuator_option *opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
157 gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
158 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
159 struct xform_spin_data *d = (struct xform_spin_data*)data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
160 float i, j; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
161 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
162 if (d->width != pn_image_data->width |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
163 || d->height != pn_image_data->height) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
164 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
165 d->width = pn_image_data->width; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
166 d->height = pn_image_data->height; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
167 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
168 if (d->vfield) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
169 g_free (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
170 |
188 | 171 d->vfield = g_malloc0 (sizeof(struct xform_vector) |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
172 * d->width * d->height); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
173 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
174 for (j=-(pn_image_data->height>>1)+1; j<=pn_image_data->height>>1; j++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
175 for (i=-(pn_image_data->width>>1); i<pn_image_data->width>>1; i++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
176 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
177 float r, t = 0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
178 float x, y; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
179 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
180 r = sqrt (i*i + j*j); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
181 if (r) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
182 t = asin (j/r); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
183 if (i < 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
184 t = M_PI - t; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
185 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
186 t += opts[0].val.fval * M_PI/180.0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
187 r += opts[1].val.fval; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
188 r *= opts[2].val.fval; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
189 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
190 x = (r * cos (t)) + (pn_image_data->width>>1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
191 y = (pn_image_data->height>>1) - (r * sin (t)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
192 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
193 xfvec (x, y, &d->vfield |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
194 [PN_IMG_INDEX ((pn_image_data->width>>1)+(int)rint(i), |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
195 ((pn_image_data->height>>1)-(int)rint(j)))]); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
196 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
197 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
198 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
199 apply_xform (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
200 pn_swap_surfaces (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
201 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
202 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
203 struct pn_actuator_desc builtin_xform_spin = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
204 { |
155
adf9f4b26039
[svn] - user-friendly names (UI side unimplemented still)
nenolod
parents:
149
diff
changeset
|
205 "xform_spin", "Spin Transform", |
adf9f4b26039
[svn] - user-friendly names (UI side unimplemented still)
nenolod
parents:
149
diff
changeset
|
206 "Rotates and radially scales the image", |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
207 0, xform_spin_opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
208 xform_spin_init, xform_spin_cleanup, xform_spin_exec |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
209 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
210 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
211 /* **************** xform_ripple **************** */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
212 struct pn_actuator_option_desc xform_ripple_opts[] = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
213 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
214 { "angle", "The angle of rotation", OPT_TYPE_FLOAT, { fval: 0 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
215 { "ripples", "The number of ripples that fit on the screen " |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
216 "(horizontally)", OPT_TYPE_FLOAT, { fval: 8 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
217 { "base_speed", "The minimum number of pixels to move each pixel", |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
218 OPT_TYPE_FLOAT, { fval: 1 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
219 { "mod_speed", "The maximum number of pixels by which base_speed" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
220 " will be modified", OPT_TYPE_FLOAT, { fval: 1 } }, |
188 | 221 { NULL } |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
222 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
223 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
224 struct xform_ripple_data |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
225 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
226 int width, height; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
227 struct xform_vector *vfield; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
228 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
229 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
230 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
231 xform_ripple_init (gpointer *data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
232 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
233 *data = g_new0 (struct xform_ripple_data, 1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
234 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
235 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
236 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
237 xform_ripple_cleanup (gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
238 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
239 struct xform_ripple_data *d = (struct xform_ripple_data*) data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
240 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
241 if (d) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
242 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
243 if (d->vfield) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
244 g_free (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
245 g_free (d); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
246 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
247 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
248 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
249 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
250 xform_ripple_exec (const struct pn_actuator_option *opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
251 gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
252 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
253 struct xform_ripple_data *d = (struct xform_ripple_data*)data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
254 float i, j; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
255 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
256 if (d->width != pn_image_data->width |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
257 || d->height != pn_image_data->height) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
258 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
259 d->width = pn_image_data->width; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
260 d->height = pn_image_data->height; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
261 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
262 if (d->vfield) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
263 g_free (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
264 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
265 d->vfield = g_malloc (sizeof(struct xform_vector) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
266 * d->width * d->height); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
267 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
268 for (j=-(pn_image_data->height>>1)+1; j<=pn_image_data->height>>1; j++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
269 for (i=-(pn_image_data->width>>1); i<pn_image_data->width>>1; i++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
270 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
271 float r, t = 0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
272 float x, y; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
273 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
274 r = sqrt (i*i + j*j); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
275 if (r) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
276 t = asin (j/r); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
277 if (i < 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
278 t = M_PI - t; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
279 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
280 t += opts[0].val.fval * M_PI/180.0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
281 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
282 if (r > 4)//(pn_image_data->width/(2*opts[1].val.fval))) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
283 r -= opts[2].val.fval + (opts[3].val.fval/2) * |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
284 (1 + sin ((r/(pn_image_data->width/(2*opts[1].val.fval)))*M_PI)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
285 /* else if (r > 4) */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
286 /* r *= r/(pn_image_data->width/opts[1].val.fval); */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
287 else /* don't let it explode */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
288 r = 1000000; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
289 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
290 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
291 x = (r * cos (t)) + (pn_image_data->width>>1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
292 y = (pn_image_data->height>>1) - (r * sin (t)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
293 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
294 xfvec (x, y, &d->vfield |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
295 [PN_IMG_INDEX ((pn_image_data->width>>1)+(int)rint(i), |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
296 ((pn_image_data->height>>1)-(int)rint(j)))]); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
297 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
298 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
299 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
300 apply_xform (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
301 pn_swap_surfaces (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
302 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
303 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
304 struct pn_actuator_desc builtin_xform_ripple = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
305 { |
155
adf9f4b26039
[svn] - user-friendly names (UI side unimplemented still)
nenolod
parents:
149
diff
changeset
|
306 "xform_ripple", "Ripple Transform", "Creates an ripple effect", |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
307 0, xform_ripple_opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
308 xform_ripple_init, xform_ripple_cleanup, xform_ripple_exec |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
309 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
310 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
311 /* **************** xform_bump_spin **************** */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
312 struct pn_actuator_option_desc xform_bump_spin_opts[] = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
313 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
314 { "angle", "The angle of rotation", OPT_TYPE_FLOAT, { fval: 0 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
315 { "bumps", "The number of bumps that on the image", |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
316 OPT_TYPE_FLOAT, { fval: 8 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
317 { "base_scale", "The base radial scale", |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
318 OPT_TYPE_FLOAT, { fval: 0.95 } }, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
319 { "mod_scale", "The maximum amount that should be " |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
320 "added to the base_scale to create the 'bump' effect", |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
321 OPT_TYPE_FLOAT, { fval: .1 } }, |
188 | 322 { NULL } |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
323 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
324 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
325 struct xform_bump_spin_data |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
326 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
327 int width, height; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
328 struct xform_vector *vfield; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
329 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
330 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
331 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
332 xform_bump_spin_init (gpointer *data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
333 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
334 *data = g_new0 (struct xform_bump_spin_data, 1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
335 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
336 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
337 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
338 xform_bump_spin_cleanup (gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
339 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
340 struct xform_bump_spin_data *d = (struct xform_bump_spin_data*) data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
341 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
342 if (d) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
343 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
344 if (d->vfield) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
345 g_free (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
346 g_free (d); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
347 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
348 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
349 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
350 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
351 xform_bump_spin_exec (const struct pn_actuator_option *opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
352 gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
353 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
354 struct xform_bump_spin_data *d = (struct xform_bump_spin_data*)data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
355 float i, j; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
356 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
357 if (d->width != pn_image_data->width |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
358 || d->height != pn_image_data->height) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
359 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
360 d->width = pn_image_data->width; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
361 d->height = pn_image_data->height; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
362 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
363 if (d->vfield) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
364 g_free (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
365 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
366 d->vfield = g_malloc (sizeof(struct xform_vector) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
367 * d->width * d->height); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
368 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
369 for (j=-(pn_image_data->height>>1)+1; j<=pn_image_data->height>>1; j++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
370 for (i=-(pn_image_data->width>>1); i<pn_image_data->width>>1; i++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
371 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
372 float r, t = 0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
373 float x, y; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
374 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
375 r = sqrt (i*i + j*j); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
376 if (r) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
377 t = asin (j/r); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
378 if (i < 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
379 t = M_PI - t; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
380 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
381 t += opts[0].val.fval * M_PI/180.0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
382 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
383 r *= opts[2].val.fval + opts[3].val.fval |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
384 * (1 + sin (t*opts[1].val.fval)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
385 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
386 x = (r * cos (t)) + (pn_image_data->width>>1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
387 y = (pn_image_data->height>>1) - (r * sin (t)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
388 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
389 xfvec (x, y, &d->vfield |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
390 [PN_IMG_INDEX ((pn_image_data->width>>1)+(int)rint(i), |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
391 ((pn_image_data->height>>1)-(int)rint(j)))]); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
392 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
393 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
394 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
395 apply_xform (d->vfield); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
396 pn_swap_surfaces (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
397 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
398 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
399 struct pn_actuator_desc builtin_xform_bump_spin = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
400 { |
155
adf9f4b26039
[svn] - user-friendly names (UI side unimplemented still)
nenolod
parents:
149
diff
changeset
|
401 "xform_bump_spin", "Bump Transform", |
adf9f4b26039
[svn] - user-friendly names (UI side unimplemented still)
nenolod
parents:
149
diff
changeset
|
402 "Rotate the image at a varying speed to create " |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
403 "the illusion of bumps", |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
404 0, xform_bump_spin_opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
405 xform_bump_spin_init, xform_bump_spin_cleanup, xform_bump_spin_exec |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
406 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
407 |
273
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
408 /* **************** xform_halfrender **************** */ |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
409 struct pn_actuator_option_desc xform_halfrender_opts[] = |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
410 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
411 { "direction", "Negative is horizontal, positive is vertical.", |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
412 OPT_TYPE_INT, { ival: 1 } }, |
275
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
413 { "render_twice", "Render the second image.", |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
414 OPT_TYPE_BOOLEAN, { bval: TRUE } }, |
273
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
415 { NULL } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
416 }; |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
417 |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
418 static void |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
419 xform_halfrender_exec (const struct pn_actuator_option *opts, |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
420 gpointer data) |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
421 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
422 gint x, y; |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
423 |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
424 if (opts[0].val.ival < 0) |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
425 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
426 for (y = 0; y < pn_image_data->height; y += 2) |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
427 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
428 for (x = 0; x < pn_image_data->width; x++) |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
429 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
430 pn_image_data->surface[1][PN_IMG_INDEX(x, y / 2)] = |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
431 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; |
275
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
432 if (opts[1].val.bval) |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
433 { |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
434 pn_image_data->surface[1][PN_IMG_INDEX(x, (y / 2) + (pn_image_data->height / 2))] = |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
435 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
436 } |
273
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
437 } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
438 } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
439 } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
440 else |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
441 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
442 for (y = 0; y < pn_image_data->height; y++) |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
443 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
444 for (x = 0; x < pn_image_data->width; x += 2) |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
445 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
446 pn_image_data->surface[1][PN_IMG_INDEX(x / 2, y)] = |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
447 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; |
275
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
448 if (opts[1].val.bval) |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
449 { |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
450 pn_image_data->surface[1][PN_IMG_INDEX((x / 2) + (pn_image_data->width / 2), y)] = |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
451 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; |
a1517b09cb3a
[svn] - add an option to make it only render the downscaled image.
nenolod
parents:
273
diff
changeset
|
452 } |
273
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
453 } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
454 } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
455 } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
456 |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
457 pn_swap_surfaces (); |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
458 } |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
459 |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
460 struct pn_actuator_desc builtin_xform_halfrender = |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
461 { |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
462 "xform_halfrender", "Halfrender Transform", |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
463 "Divides the surface in half and renders it twice.", |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
464 0, xform_halfrender_opts, |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
465 NULL, NULL, xform_halfrender_exec |
fac0b72ee0de
[svn] - add halfrender transform, and a new preset which demonstrates what it can do.
nenolod
parents:
189
diff
changeset
|
466 }; |
333 | 467 |
468 /* **************** xform_movement **************** */ | |
469 struct pn_actuator_option_desc xform_movement_opts[] = | |
470 { | |
471 { "formula", "The formula to evaluate.", | |
365 | 472 OPT_TYPE_STRING, { sval: "r = r * cos(r); d = sin(d);" } }, |
473 { "polar", "Whether the coordinates are polar or not.", | |
474 OPT_TYPE_BOOLEAN, { bval: TRUE } }, | |
333 | 475 { NULL } |
476 }; | |
477 | |
478 typedef struct { | |
479 int width, height; /* Previous width and height. */ | |
480 struct xform_vector *vfield; | |
481 } PnMovementData; | |
482 | |
483 static void | |
484 xform_movement_init (gpointer *data) | |
485 { | |
486 *data = g_new0(PnMovementData, 1); | |
487 } | |
488 | |
489 static void | |
490 xform_movement_cleanup (gpointer data) | |
491 { | |
492 PnMovementData *d = (PnMovementData *) data; | |
493 | |
494 if (d) | |
495 { | |
496 if (d->vfield) | |
497 g_free (d->vfield); | |
498 g_free (d); | |
499 } | |
500 } | |
501 | |
365 | 502 inline void |
503 xform_trans_polar (struct xform_vector *vfield, gint x, gint y, | |
504 expression_t *expr, symbol_dict_t *dict) | |
505 { | |
506 gdouble *rf, *df; | |
507 gdouble xf, yf; | |
508 gint xn, yn; | |
509 | |
510 rf = dict_variable(dict, "r"); | |
511 df = dict_variable(dict, "d"); | |
512 | |
513 /* Points (xf, yf) must be in a (-1..1) square. */ | |
514 xf = 2.0 * x / (pn_image_data->width - 1) - 1.0; | |
515 yf = 2.0 * y / (pn_image_data->height - 1) - 1.0; | |
516 | |
517 /* Now, convert to polar coordinates r and d. */ | |
518 *rf = hypot(xf, yf); | |
519 *df = atan2(yf, xf); | |
520 | |
521 /* Run the script. */ | |
522 expr_execute(expr, dict); | |
523 | |
524 /* Back to (-1..1) square. */ | |
525 xf = (*rf) * cos ((*df)); | |
526 yf = (*rf) * sin ((*df)); | |
527 | |
528 /* Convert back to physical coordinates. */ | |
529 xn = (int)(((xf + 1.0) * (pn_image_data->width - 1) / 2) + 0.5); | |
530 yn = (int)(((yf + 1.0) * (pn_image_data->height - 1) / 2) + 0.5); | |
531 | |
532 if (xn < 0 || xn >= pn_image_data->width || yn < 0 || yn >= pn_image_data->height) | |
533 { | |
534 xn = x; yn = y; | |
535 } | |
536 | |
537 xfvec (xn, yn, &vfield[PN_IMG_INDEX (x, y)]); | |
538 } | |
539 | |
540 inline void | |
541 xform_trans_literal (struct xform_vector *vfield, gint x, gint y, | |
542 expression_t *expr, symbol_dict_t *dict) | |
543 { | |
544 gint xn, yn; | |
2186 | 545 gdouble *xf = dict_variable(dict, "x"); |
546 gdouble *yf = dict_variable(dict, "y"); | |
365 | 547 |
548 /* Points (xf, yf) must be in a (-1..1) square. */ | |
549 *xf = 2.0 * x / (pn_image_data->width - 1) - 1.0; | |
550 *yf = 2.0 * y / (pn_image_data->height - 1) - 1.0; | |
551 | |
552 /* Run the script. */ | |
553 expr_execute(expr, dict); | |
554 | |
555 /* Convert back to physical coordinates. */ | |
556 xn = (int)(((*xf + 1.0) * (pn_image_data->width - 1) / 2) + 0.5); | |
557 yn = (int)(((*yf + 1.0) * (pn_image_data->height - 1) / 2) + 0.5); | |
558 | |
559 if (xn < 0 || xn >= pn_image_data->width || yn < 0 || yn >= pn_image_data->height) | |
560 { | |
561 xn = x; yn = y; | |
562 } | |
563 | |
564 xfvec (xn, yn, &vfield[PN_IMG_INDEX (x, y)]); | |
565 } | |
566 | |
333 | 567 static void |
568 xform_movement_exec (const struct pn_actuator_option *opts, | |
569 gpointer odata) | |
570 { | |
571 PnMovementData *d = (PnMovementData *) odata; | |
365 | 572 void (*transform_func)(struct xform_vector *, gint, gint, expression_t *, symbol_dict_t *) = |
573 opts[1].val.bval == TRUE ? xform_trans_polar : xform_trans_literal; | |
333 | 574 |
575 if (d->width != pn_image_data->width | |
576 || d->height != pn_image_data->height) | |
577 { | |
578 gint i, j; | |
579 gdouble *rf, *df; | |
580 expression_t *expr; | |
581 symbol_dict_t *dict; | |
582 | |
583 d->width = pn_image_data->width; | |
584 d->height = pn_image_data->height; | |
585 | |
586 if (d->vfield) | |
587 { | |
588 g_free (d->vfield); | |
589 d->vfield = NULL; | |
590 } | |
591 | |
592 if (opts[0].val.sval == NULL) | |
593 return; | |
594 | |
595 dict = dict_new(); | |
596 expr = expr_compile_string(opts[0].val.sval, dict); | |
597 if (!expr) | |
598 { | |
599 dict_free(dict); | |
600 return; | |
601 } | |
602 | |
603 rf = dict_variable(dict, "r"); | |
604 df = dict_variable(dict, "d"); | |
605 | |
606 d->vfield = g_malloc (sizeof(struct xform_vector) | |
607 * d->width * d->height); | |
608 | |
609 for (j = 0; j < pn_image_data->height; j++) | |
610 for (i = 0; i < pn_image_data->width; i++) | |
611 { | |
365 | 612 transform_func(d->vfield, i, j, expr, dict); |
333 | 613 } |
614 } | |
615 | |
616 apply_xform (d->vfield); | |
617 pn_swap_surfaces (); | |
618 } | |
619 | |
620 struct pn_actuator_desc builtin_xform_movement = | |
621 { | |
622 "xform_movement", "Movement Transform", | |
623 "A customizable blitter.", | |
624 0, xform_movement_opts, | |
625 xform_movement_init, xform_movement_cleanup, xform_movement_exec | |
626 }; | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
627 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
628 /* **************** xform_dynmovement **************** */ |
337 | 629 /* FIXME: really slow */ |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
630 struct pn_actuator_option_desc xform_dynmovement_opts[] = |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
631 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
632 { "init_script", "The formula to evaluate on init.", |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
633 OPT_TYPE_STRING, { sval: "" } }, |
366 | 634 { "beat_script", "The formula to evaluate on each beat.", |
635 OPT_TYPE_STRING, { sval: "" } }, | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
636 { "frame_script", "The formula to evaluate on each frame.", |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
637 OPT_TYPE_STRING, { sval: "" } }, |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
638 { "point_script", "The formula to evaluate.", |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
639 OPT_TYPE_STRING, { sval: "d = 0.15;" } }, |
365 | 640 { "polar", "Whether or not the coordinates to use are polar.", |
641 OPT_TYPE_BOOLEAN, { bval: TRUE } }, | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
642 { NULL } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
643 }; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
644 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
645 typedef struct { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
646 int width, height; /* Previous width and height. */ |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
647 expression_t *expr_init; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
648 expression_t *expr_frame; |
366 | 649 expression_t *expr_beat; |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
650 expression_t *expr_point; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
651 symbol_dict_t *dict; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
652 struct xform_vector *vfield; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
653 } PnDynMovementData; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
654 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
655 static void |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
656 xform_dynmovement_init (gpointer *data) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
657 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
658 *data = g_new0(PnDynMovementData, 1); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
659 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
660 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
661 static void |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
662 xform_dynmovement_cleanup (gpointer data) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
663 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
664 PnDynMovementData *d = (PnDynMovementData *) data; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
665 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
666 if (d) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
667 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
668 if (d->expr_init) |
337 | 669 expr_free (d->expr_init); |
367 | 670 if (d->expr_beat) |
671 expr_free (d->expr_beat); | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
672 if (d->expr_frame) |
337 | 673 expr_free (d->expr_frame); |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
674 if (d->expr_point) |
337 | 675 expr_free (d->expr_point); |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
676 if (d->dict) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
677 dict_free (d->dict); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
678 if (d->vfield) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
679 g_free (d->vfield); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
680 g_free (d); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
681 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
682 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
683 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
684 static void |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
685 xform_dynmovement_exec (const struct pn_actuator_option *opts, |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
686 gpointer odata) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
687 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
688 PnDynMovementData *d = (PnDynMovementData *) odata; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
689 gint i, j; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
690 gdouble *rf, *df; |
365 | 691 void (*transform_func)(struct xform_vector *, gint, gint, expression_t *, symbol_dict_t *) = |
367 | 692 opts[4].val.bval == TRUE ? xform_trans_polar : xform_trans_literal; |
693 gboolean make_table = FALSE; | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
694 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
695 if (d->width != pn_image_data->width |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
696 || d->height != pn_image_data->height) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
697 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
698 d->width = pn_image_data->width; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
699 d->height = pn_image_data->height; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
700 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
701 if (d->vfield) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
702 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
703 g_free (d->vfield); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
704 d->vfield = NULL; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
705 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
706 |
367 | 707 if (opts[3].val.sval == NULL) |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
708 return; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
709 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
710 if (!d->dict) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
711 d->dict = dict_new(); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
712 else |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
713 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
714 dict_free(d->dict); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
715 d->dict = dict_new(); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
716 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
717 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
718 if (d->expr_init) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
719 { |
337 | 720 expr_free(d->expr_init); |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
721 d->expr_init = NULL; |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
722 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
723 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
724 /* initialize */ |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
725 d->expr_init = expr_compile_string(opts[0].val.sval, d->dict); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
726 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
727 if (d->expr_init != NULL) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
728 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
729 expr_execute(d->expr_init, d->dict); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
730 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
731 |
367 | 732 d->expr_beat = expr_compile_string(opts[1].val.sval, d->dict); |
733 d->expr_frame = expr_compile_string(opts[2].val.sval, d->dict); | |
734 d->expr_point = expr_compile_string(opts[3].val.sval, d->dict); | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
735 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
736 d->vfield = g_malloc (sizeof(struct xform_vector) |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
737 * d->width * d->height); |
367 | 738 |
739 make_table = TRUE; | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
740 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
741 |
337 | 742 rf = dict_variable(d->dict, "r"); |
743 df = dict_variable(d->dict, "d"); | |
744 | |
367 | 745 if (*opts[2].val.sval != '\0' || pn_new_beat) |
746 make_table = TRUE; | |
747 | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
748 /* run the on-frame script. */ |
367 | 749 if (make_table == TRUE) |
366 | 750 { |
367 | 751 if (d->expr_beat != NULL) |
366 | 752 expr_execute(d->expr_beat, d->dict); |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
753 |
366 | 754 if (d->expr_frame != NULL) |
755 expr_execute(d->expr_frame, d->dict); | |
756 | |
757 for (j = 0; j < pn_image_data->height; j++) | |
758 for (i = 0; i < pn_image_data->width; i++) | |
759 { | |
760 transform_func(d->vfield, i, j, d->expr_point, d->dict); | |
761 } | |
762 } | |
336
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
763 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
764 apply_xform (d->vfield); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
765 pn_swap_surfaces (); |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
766 } |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
767 |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
768 struct pn_actuator_desc builtin_xform_dynmovement = |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
769 { |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
770 "xform_dynmovement", "Dynamic Movement Transform", |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
771 "A customizable blitter.", |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
772 0, xform_dynmovement_opts, |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
773 xform_dynmovement_init, xform_dynmovement_cleanup, xform_dynmovement_exec |
8554beb862c0
[svn] - implement AVS-like Trans / Dynamic Movement
nenolod
parents:
334
diff
changeset
|
774 }; |