annotate src/paranormal/general.c @ 328:a4d2caa1da63 trunk

[svn] Well I think it's pretty
author nazca
date Mon, 04 Dec 2006 01:07:59 -0800
parents 8f4dc0d63925
children a7c98f237b03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
1 /* FIXME: what to name this file? */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
2
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
3 #ifdef HAVE_CONFIG_H
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
4 # include <config.h>
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
5 #endif
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
6
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
7 #include "paranormal.h"
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
8 #include "actuators.h"
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
9 #include "pn_utils.h"
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
10
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
11 /* **************** general_fade **************** */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
12 static struct pn_actuator_option_desc general_fade_opts[] =
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
13 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
14 { "amount", "The amount by which the color index of each "
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
15 "pixel should be decreased by each frame (MAX 255)",
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
16 OPT_TYPE_INT, { ival: 3 } },
175
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
17 { NULL }
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
18 };
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
19
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
20 static void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
21 general_fade_exec (const struct pn_actuator_option *opts,
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
22 gpointer data)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
23 {
177
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
24 int amt = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 3 : opts[0].val.ival;
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
25 int i, j;
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 for (j=0; j<pn_image_data->height; j++)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
28 for (i=0; i<pn_image_data->width; i++)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
29 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] =
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
30 CAPLO (pn_image_data->surface[0][PN_IMG_INDEX (i, j)]
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
31 - amt, 0);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
32 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
33
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
34 struct pn_actuator_desc builtin_general_fade =
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
35 {
155
adf9f4b26039 [svn] - user-friendly names (UI side unimplemented still)
nenolod
parents: 149
diff changeset
36 "general_fade", "Fade-out", "Decreases the color index of each pixel",
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
37 0, general_fade_opts,
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
38 NULL, NULL, general_fade_exec
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
39 };
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
40
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
41 /* **************** general_blur **************** */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
42 /* FIXME: add a variable radius */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
43 /* FIXME: SPEEEED */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
44 static void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
45 general_blur_exec (const struct pn_actuator_option *opts,
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
46 gpointer data)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
47 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
48 int i,j;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
49 register guchar *srcptr = pn_image_data->surface[0];
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
50 register guchar *destptr = pn_image_data->surface[1];
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
51 register int sum;
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 for (j=0; j<pn_image_data->height; j++)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
54 for (i=0; i<pn_image_data->width; i++)
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 sum = *(srcptr)<<2;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
57
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
58 /* top */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
59 if (j > 0)
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 sum += *(srcptr-pn_image_data->width)<<1;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
62 if (i > 0)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
63 sum += *(srcptr-pn_image_data->width-1);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
64 if (i < pn_image_data->width-1)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
65 sum += *(srcptr-pn_image_data->width+1);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
66 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
67 /* bottom */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
68 if (j < pn_image_data->height-1)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
69 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
70 sum += *(srcptr+pn_image_data->width)<<1;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
71 if (i > 0)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
72 sum += *(srcptr+pn_image_data->width-1);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
73 if (i < pn_image_data->width-1)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
74 sum += *(srcptr+pn_image_data->width+1);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
75 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
76 /* left */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
77 if (i > 0)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
78 sum += *(srcptr-1)<<1;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
79 /* right */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
80 if (i < pn_image_data->width-1)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
81 sum += *(srcptr+1)<<1;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
82
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
83 *destptr++ = (guchar)(sum >> 4);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
84 srcptr++;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
85 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
86
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
87 pn_swap_surfaces ();
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
88 }
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 struct pn_actuator_desc builtin_general_blur =
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
91 {
155
adf9f4b26039 [svn] - user-friendly names (UI side unimplemented still)
nenolod
parents: 149
diff changeset
92 "general_blur", "Blur", "A simple 1 pixel radius blur",
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
93 0, NULL,
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
94 NULL, NULL, general_blur_exec
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
95 };
174
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
96
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
97 /* **************** general_mosaic **************** */
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
98 /* FIXME: add a variable radius */
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
99 /* FIXME: SPEEEED */
175
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
100 static struct pn_actuator_option_desc general_mosaic_opts[] =
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
101 {
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
102 { "radius", "The pixel radius that should be used for the effect.",
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
103 OPT_TYPE_INT, { ival: 6 } },
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
104 { NULL }
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
105 };
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
106
174
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
107 static void
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
108 general_mosaic_exec (const struct pn_actuator_option *opts,
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
109 gpointer data)
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
110 {
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
111 int i,j;
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
112 register guchar *srcptr = pn_image_data->surface[0];
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
113 register guchar *destptr = pn_image_data->surface[1];
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
114 register int sum;
177
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
115 int radius = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 6 : opts[0].val.ival;
174
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
116
175
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
117 for (j=0; j<pn_image_data->height; j += radius)
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
118 for (i=0; i<pn_image_data->width; i += radius)
174
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
119 {
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
120 int ii = 0, jj = 0;
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
121 guchar bval = 0;
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
122
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
123 /* find the brightest colour */
175
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
124 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++)
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
125 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++)
174
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
126 {
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
127 guchar val = srcptr[PN_IMG_INDEX(i + ii, j + jj)];
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
128
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
129 if (val > bval)
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
130 bval = val;
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
131 }
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
132
175
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
133 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++)
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
134 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++)
174
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
135 {
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
136 destptr[PN_IMG_INDEX(i + ii, j + jj)] = bval;
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
137 }
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
138 }
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
139
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
140 pn_swap_surfaces ();
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
141 }
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
142
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
143 struct pn_actuator_desc builtin_general_mosaic =
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
144 {
176
c93118f6ef27 [svn] - update Mosaic effect helptext.
nenolod
parents: 175
diff changeset
145 "general_mosaic", "Mosaic", "A simple mosaic effect.",
175
5635841a0686 [svn] - make mosaic sizable.
nenolod
parents: 174
diff changeset
146 0, general_mosaic_opts,
174
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
147 NULL, NULL, general_mosaic_exec
3d98be3d74c2 [svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents: 155
diff changeset
148 };
177
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
149
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
150 /* **************** general_clear **************** */
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
151 static void
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
152 general_clear_exec (const struct pn_actuator_option *opts,
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
153 gpointer data)
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
154 {
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
155 memset(pn_image_data->surface[0], '\0',
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
156 (pn_image_data->height * pn_image_data->width));
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
157 }
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
158
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
159 struct pn_actuator_desc builtin_general_clear =
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
160 {
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
161 "general_clear", "Clear Surface", "Clears the surface.",
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
162 0, NULL,
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
163 NULL, NULL, general_clear_exec
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
164 };
6880934d11bf [svn] - add "Clear Surface" instruction.
nenolod
parents: 176
diff changeset
165
179
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
166 /* **************** general_noop **************** */
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
167 static void
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
168 general_noop_exec (const struct pn_actuator_option *opts,
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
169 gpointer data)
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
170 {
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
171 return;
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
172 }
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
173
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
174 struct pn_actuator_desc builtin_general_noop =
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
175 {
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
176 "general_noop", "Do Nothing", "Does absolutely nothing.",
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
177 0, NULL,
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
178 NULL, NULL, general_noop_exec
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
179 };
b44ab11a64c2 [svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents: 177
diff changeset
180
181
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
181 /* **************** general_invert **************** */
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
182 static void
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
183 general_invert_exec (const struct pn_actuator_option *opts,
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
184 gpointer data)
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
185 {
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
186 int i, j;
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
187
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
188 for (j=0; j < pn_image_data->height; j++)
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
189 for (i=0; i < pn_image_data->width; i++)
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
190 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] =
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
191 255 - pn_image_data->surface[0][PN_IMG_INDEX (i, j)];
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
192 }
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
193
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
194 struct pn_actuator_desc builtin_general_invert =
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
195 {
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
196 "general_invert", "Value Invert", "Performs a value invert.",
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
197 0, NULL,
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
198 NULL, NULL, general_invert_exec
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
199 };
156d6c875ef0 [svn] - add value invert filter
nenolod
parents: 179
diff changeset
200
182
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
201 /* **************** general_replace **************** */
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
202 static struct pn_actuator_option_desc general_replace_opts[] =
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
203 {
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
204 { "start", "The beginning colour value that should be replaced by the value of out.",
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
205 OPT_TYPE_INT, { ival: 250 } },
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
206 { "end", "The ending colour value that should be replaced by the value of out.",
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
207 OPT_TYPE_INT, { ival: 255 } },
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
208 { "out", "The colour value that in is replaced with.",
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
209 OPT_TYPE_INT, { ival: 0 } },
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
210 { NULL }
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
211 };
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
212
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
213 static void
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
214 general_replace_exec (const struct pn_actuator_option *opts,
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
215 gpointer data)
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
216 {
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
217 register int i, j;
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
218 register guchar val;
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
219 guchar begin = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 250 : opts[0].val.ival;
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
220 guchar end = opts[1].val.ival > 255 || opts[1].val.ival < 0 ? 255 : opts[1].val.ival;
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
221 guchar out = opts[2].val.ival > 255 || opts[2].val.ival < 0 ? 0 : opts[2].val.ival;
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
222
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
223 for (j=0; j < pn_image_data->height; j++)
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
224 for (i=0; i < pn_image_data->width; i++)
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
225 {
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
226 val = pn_image_data->surface[0][PN_IMG_INDEX (i, j)];
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
227 if (val >= begin && val <= end)
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
228 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] = out;
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
229 }
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
230 }
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
231
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
232 struct pn_actuator_desc builtin_general_replace =
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
233 {
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
234 "general_replace", "Value Replace", "Performs a value replace on a range of values.",
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
235 0, general_replace_opts,
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
236 NULL, NULL, general_replace_exec
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
237 };
6048abdac7d1 [svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents: 181
diff changeset
238
271
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
239 /* **************** general_swap **************** */
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
240 static void
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
241 general_swap_exec (const struct pn_actuator_option *opts,
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
242 gpointer data)
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
243 {
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
244 pn_swap_surfaces ();
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
245 }
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
246
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
247 struct pn_actuator_desc builtin_general_swap =
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
248 {
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
249 "general_swap", "Swap Surface", "Swaps the surface.",
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
250 0, NULL,
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
251 NULL, NULL, general_swap_exec
b166ce84af57 [svn] - add swap surface
nenolod
parents: 182
diff changeset
252 };
272
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
253
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
254 /* **************** general_copy **************** */
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
255 static void
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
256 general_copy_exec (const struct pn_actuator_option *opts,
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
257 gpointer data)
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
258 {
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
259 memcpy(pn_image_data->surface[1], pn_image_data->surface[0],
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
260 (pn_image_data->width * pn_image_data->height));
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
261 }
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
262
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
263 struct pn_actuator_desc builtin_general_copy =
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
264 {
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
265 "general_copy", "Copy Surface", "Copies the surface to the other surface.",
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
266 0, NULL,
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
267 NULL, NULL, general_copy_exec
d8cefe8ce6e6 [svn] - add copy surface
nenolod
parents: 271
diff changeset
268 };
278
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
269
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
270 /* **************** general_flip **************** */
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
271 static struct pn_actuator_option_desc general_flip_opts[] =
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
272 {
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
273 { "direction", "Negative is horizontal, positive is vertical.",
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
274 OPT_TYPE_INT, { ival: -1 } },
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
275 { NULL }
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
276 };
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
277
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
278 static void
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
279 general_flip_exec (const struct pn_actuator_option *opts,
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
280 gpointer data)
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
281 {
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
282 gint x, y;
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
283
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
284 if (opts[0].val.ival < 0)
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
285 {
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
286 for (y = 0; y < pn_image_data->height; y++)
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
287 for (x = 0; x < pn_image_data->width; x++)
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
288 {
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
289 pn_image_data->surface[1][PN_IMG_INDEX(pn_image_data->width - x, y)] =
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
290 pn_image_data->surface[0][PN_IMG_INDEX(x, y)];
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
291 }
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
292 }
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
293 else
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
294 {
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
295 for (y = 0; y < pn_image_data->height; y++)
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
296 for (x = 0; x < pn_image_data->width; x++)
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
297 {
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
298 pn_image_data->surface[1][PN_IMG_INDEX(x, pn_image_data->height - y)] =
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
299 pn_image_data->surface[0][PN_IMG_INDEX(x, y)];
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
300 }
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
301 }
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
302
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
303 pn_swap_surfaces ();
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
304 }
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
305
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
306 struct pn_actuator_desc builtin_general_flip =
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
307 {
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
308 "general_flip", "Flip Surface", "Flips the surface.",
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
309 0, general_flip_opts,
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
310 NULL, NULL, general_flip_exec
8f4dc0d63925 [svn] - add surface flip
nenolod
parents: 272
diff changeset
311 };