2 * Copyright (C) <2003> iOS-Software
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include "goom_tools.h"
25 #include "drawmethods.h"
26 #include "goom_plugin_info.h"
28 static inline unsigned char
29 lighten (unsigned char value, float power)
32 float t = (float) val * log10 (power) / 2.0;
35 val = (int) t; /* (32.0f * log (t)); */
47 lightencolor (guint32 * col, float power)
51 color = (unsigned char *) col;
52 *color = lighten (*color, power);
54 *color = lighten (*color, power);
56 *color = lighten (*color, power);
58 *color = lighten (*color, power);
64 genline (int id, float param, GMUnitPointer * l, int rx, int ry)
70 for (i = 0; i < 512; i++) {
71 l[i].x = ((float) i * rx) / 512.0f;
73 l[i].angle = G_PI / 2.0f;
77 for (i = 0; i < 512; i++) {
78 l[i].y = ((float) i * ry) / 512.0f;
84 for (i = 0; i < 512; i++) {
87 l[i].angle = 2.0f * G_PI * (float) i / 512.0f;
88 cosa = param * cos (l[i].angle);
89 sina = param * sin (l[i].angle);
90 l[i].x = ((float) rx / 2.0f) + cosa;
91 l[i].y = (float) ry / 2.0f + sina;
102 return (230 << (ROUGE * 8)) | (120 << (VERT * 8)) | (18 << (BLEU * 8));
104 return (120 << (VERT * 8)) | (252 << (ROUGE * 8)) | (18 << (BLEU * 8));
106 return (160 << (VERT * 8)) | (236 << (ROUGE * 8)) | (40 << (BLEU * 8));
108 return (40 << (BLEU * 8)) | (220 << (ROUGE * 8)) | (140 << (VERT * 8));
110 return (200 << (VERT * 8)) | (80 << (ROUGE * 8)) | (18 << (BLEU * 8));
112 return (250 << (BLEU * 8)) | (30 << (VERT * 8)) | (80 << (ROUGE * 8));
114 return (16 << (BLEU * 8)) | (16 << (VERT * 8)) | (16 << (ROUGE * 8));
120 goom_lines_set_res (GMLine * gml, int rx, int ry)
126 genline (gml->IDdest, gml->param, gml->points2, rx, ry);
132 goom_lines_move (GMLine * l)
135 unsigned char *c1, *c2;
137 for (i = 0; i < 512; i++) {
138 l->points[i].x = (l->points2[i].x + 39.0f * l->points[i].x) / 40.0f;
139 l->points[i].y = (l->points2[i].y + 39.0f * l->points[i].y) / 40.0f;
141 (l->points2[i].angle + 39.0f * l->points[i].angle) / 40.0f;
144 c1 = (unsigned char *) &l->color;
145 c2 = (unsigned char *) &l->color2;
146 for (i = 0; i < 4; i++) {
151 *c1 = (unsigned char) ((cc1 * 63 + cc2) >> 6);
156 l->power += l->powinc;
157 if (l->power < 1.1f) {
159 l->powinc = (float) (goom_irand (l->goomInfo->gRandom, 20) + 10) / 300.0f;
161 if (l->power > 17.5f) {
163 l->powinc = -(float) (goom_irand (l->goomInfo->gRandom, 20) + 10) / 300.0f;
166 l->amplitude = (99.0f * l->amplitude + l->amplitudeF) / 100.0f;
170 goom_lines_switch_to (GMLine * gml, int IDdest,
171 float param, float amplitude, int col)
173 genline (IDdest, param, gml->points2, gml->screenX, gml->screenY);
174 gml->IDdest = IDdest;
176 gml->amplitudeF = amplitude;
177 gml->color2 = getcouleur (col);
181 goom_lines_init (PluginInfo * goomInfo, int rx, int ry,
182 int IDsrc, float paramS, int coulS, int IDdest, float paramD, int coulD)
184 GMLine *l = (GMLine *) malloc (sizeof (GMLine));
186 l->goomInfo = goomInfo;
188 l->points = (GMUnitPointer *) malloc (512 * sizeof (GMUnitPointer));
189 l->points2 = (GMUnitPointer *) malloc (512 * sizeof (GMUnitPointer));
195 l->amplitude = l->amplitudeF = 1.0f;
197 genline (IDsrc, paramS, l->points, rx, ry);
198 genline (IDdest, paramD, l->points2, rx, ry);
200 l->color = getcouleur (coulS);
201 l->color2 = getcouleur (coulD);
209 goom_lines_switch_to (l, IDdest, paramD, 1.0f, coulD);
215 goom_lines_free (GMLine ** l)
217 free ((*l)->points2);
224 goom_lines_draw (PluginInfo * plug, GMLine * line, gint16 data[512], Pixel * p)
228 guint32 color = line->color;
229 GMUnitPointer *pt = &(line->points[0]);
231 float cosa = cos (pt->angle) / 1000.0f;
232 float sina = sin (pt->angle) / 1000.0f;
234 lightencolor (&color, line->power);
236 x1 = (int) (pt->x + cosa * line->amplitude * data[0]);
237 y1 = (int) (pt->y + sina * line->amplitude * data[0]);
239 for (i = 1; i < 512; i++) {
241 GMUnitPointer *pt = &(line->points[i]);
243 float cosa = cos (pt->angle) / 1000.0f;
244 float sina = sin (pt->angle) / 1000.0f;
246 x2 = (int) (pt->x + cosa * line->amplitude * data[i]);
247 y2 = (int) (pt->y + sina * line->amplitude * data[i]);
249 plug->methods.draw_line (p, x1, y1, x2, y2, color, line->screenX,
255 goom_lines_move (line);