annotate src/paranormal-ng/cmaps.c @ 3158:8b97f9560dc3

More clean-up of roll-up code (should fix bug #37; if not, it's a WM problem).
author John Lindgren <john.lindgren@tds.net>
date Fri, 01 May 2009 16:59:54 -0400
parents f1b6f1b2cdb3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /*
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 * paranormal: iterated pipeline-driven visualization plugin
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 * Copyright (c) 2006, 2007 William Pitcock <nenolod@dereferenced.org>
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 * Portions copyright (c) 2001 Jamie Gennis <jgennis@mindspring.com>
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 *
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8 * the Free Software Foundation; under version 2 of the License.
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 *
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 * GNU General Public License for more details.
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 *
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2078
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18 */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20 #include <config.h>
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 #include <glib.h>
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24 #include "paranormal.h"
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25 #include "actuators.h"
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27 #include "libcalc/calc.h"
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29 #define STD_CMAP_OPTS { "low_index", "The lowest index of the \
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30 color map that should be altered", OPT_TYPE_COLOR_INDEX, { ival: 0 } },\
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31 { "high_index", "The highest index of the color map that should be \
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32 altered", OPT_TYPE_COLOR_INDEX, { ival: 255 } }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34 static struct pn_color black = {0, 0, 0};
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 static struct pn_color white = {255, 255, 255};
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37 /* **************** cmap generation funcs **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39 cmap_gen_gradient (int step, const struct pn_color *a,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 const struct pn_color *b,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41 struct pn_color *c)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43 c->r = a->r + step * ((((float)b->r) - ((float)a->r)) / 256.0);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44 c->g = a->g + step * ((((float)b->g) - ((float)a->g)) / 256.0);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45 c->b = a->b + step * ((((float)b->b) - ((float)a->b)) / 256.0);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48 /* **************** cmap_gradient **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49 static struct pn_actuator_option_desc cmap_gradient_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51 STD_CMAP_OPTS,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 { "lcolor", "The low color used in the gradient generation",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53 OPT_TYPE_COLOR, { cval: {0, 0, 0} } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
54 { "hcolor", "The high color used in the gradient generation",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
55 OPT_TYPE_COLOR, { cval: {0, 0, 0} } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
56 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
57 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
58
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
59 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
60 cmap_gradient_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
61 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 int i;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65 for (i=opts[0].val.ival; i<=opts[1].val.ival; i++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 cmap_gen_gradient (((i-opts[0].val.ival)<<8)/(opts[1].val.ival
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67 - opts[0].val.ival),
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
68 &opts[2].val.cval, &opts[3].val.cval,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
69 &pn_image_data->cmap[i]);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
70 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
71
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
72 struct pn_actuator_desc builtin_cmap_gradient =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
73 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
74 "cmap_gradient",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
75 "Normal colourmap",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
76 "Sets the colormap to a gradient going from <lcolor> to "
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
77 "<hcolor>",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 0, cmap_gradient_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
79 NULL, NULL, cmap_gradient_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
80 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
81
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82 /* **************** cmap_bwgradient **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83 static struct pn_actuator_option_desc cmap_bwgradient_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
84 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
85 STD_CMAP_OPTS,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
86 { "color", "The intermediate color to use in the gradient",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
87 OPT_TYPE_COLOR, { cval: {191, 191, 191} } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
88 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
90
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
91 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
92 cmap_bwgradient_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
93 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
94 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
95 int i;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
97 for (i=opts[0].val.ival; i<128 && i<=opts[1].val.ival; i++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
98 cmap_gen_gradient (i<<1, &black, &opts[2].val.cval,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99 &pn_image_data->cmap[i]);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
101 for (i=128; i<256 && i<=opts[1].val.ival; i++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
102 cmap_gen_gradient ((i-128)<<1, &opts[2].val.cval, &white,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
103 &pn_image_data->cmap[i]);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
104 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
106 struct pn_actuator_desc builtin_cmap_bwgradient =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
107 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108 "cmap_bwgradient",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
109 "Value-based colourmap",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 "Sets the colormap to a gradient going from black to "
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111 "white, via an intermediate color",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112 0, cmap_bwgradient_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113 NULL, NULL, cmap_bwgradient_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
115
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116 /* **************** cmap_dynamic **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117 static struct pn_actuator_option_desc cmap_dynamic_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 STD_CMAP_OPTS,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 { "script", "The script to run on each step.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121 OPT_TYPE_STRING, { sval: "red = red + 0.01; blue = blue + 0.01; green = green + 0.01;" } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125 typedef struct {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126 expression_t *expr;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127 symbol_dict_t *dict;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128 } PnDynamicColourmapData;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131 cmap_dynamic_init(gpointer *data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
133 *data = g_new0(PnDynamicColourmapData, 1);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
134 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137 cmap_dynamic_cleanup(gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
138 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139 PnDynamicColourmapData *d = (PnDynamicColourmapData *) data;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141 if (d->expr)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 expr_free(d->expr);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143 if (d->dict)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 dict_free(d->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146 g_free(d);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
147 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 cmap_dynamic_exec(const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 PnDynamicColourmapData *d = (PnDynamicColourmapData *) data;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154 gint i, j;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
155 gdouble *rf, *bf, *gf, *inf;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156 gint rn, bn, gn;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
158 if (!d->dict && !d->expr)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
159 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160 d->dict = dict_new();
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 if (!d->dict)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162 return;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 d->expr = expr_compile_string(opts[2].val.sval, d->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165 if (!d->expr)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
166 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 dict_free(d->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
168 d->dict = NULL;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
169 return;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
170 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
171 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173 rf = dict_variable(d->dict, "red");
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
174 gf = dict_variable(d->dict, "green");
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
175 bf = dict_variable(d->dict, "blue");
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
176 inf = dict_variable(d->dict, "index");
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178 for (i = opts[0].val.ival; i < 255 && i <= opts[1].val.ival; i++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
179 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
180 *inf = ((gdouble)i / 255.0);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
181
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
182 expr_execute(d->expr, d->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
183
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
184 /* Convert rf/bf/gf to realworld values. */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
185 rn = (gdouble)(*rf * 255);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
186 gn = (gdouble)(*gf * 255);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
187 bn = (gdouble)(*bf * 255);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
188
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
189 pn_image_data->cmap[i].r = rn;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
190 pn_image_data->cmap[i].g = gn;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
191 pn_image_data->cmap[i].b = bn;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
192 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
193 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
194
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
195 struct pn_actuator_desc builtin_cmap_dynamic =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
196 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
197 "cmap_dynamic",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
198 "Dynamic Colourmap",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
199 "Scriptable colourmap modifier.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
200 0, cmap_dynamic_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
201 cmap_dynamic_init, cmap_dynamic_cleanup, cmap_dynamic_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
202 };