diff options
Diffstat (limited to 'src/post/goom/lines.c')
-rw-r--r-- | src/post/goom/lines.c | 297 |
1 files changed, 61 insertions, 236 deletions
diff --git a/src/post/goom/lines.c b/src/post/goom/lines.c index e7a9b60e0..5d3d2dba6 100644 --- a/src/post/goom/lines.c +++ b/src/post/goom/lines.c @@ -1,10 +1,5 @@ /* * lines.c - * iTunesXPlugIn - * - * Created by guillaum on Tue Aug 14 2001. - * Copyright (c) 2001 __CompanyName__. All rights reserved. - * */ #include "lines.h" @@ -16,192 +11,43 @@ extern unsigned int resolx, c_resoly; -#define DRAWMETHOD DRAWMETHOD_PLUS(*p,*p,col) - -static void -draw_line (int *data, int x1, int y1, int x2, int y2, int col, int screenx, - int screeny) +static inline unsigned char +lighten (unsigned char value, float power) { - int x, y, dx, dy, yy, xx; - int *p; - -/* DATA32 *p; */ -/* DATA8 aaa, nr, ng, nb, rr, gg, bb, aa, na; */ - - /* clip to top edge */ - if ((y1 < 0) && (y2 < 0)) - return; - if (y1 < 0) { - x1 += (y1 * (x1 - x2)) / (y2 - y1); - y1 = 0; - } - if (y2 < 0) { - x2 += (y2 * (x1 - x2)) / (y2 - y1); - y2 = 0; - } - /* clip to bottom edge */ - if ((y1 >= screeny) && (y2 >= screeny)) - return; - if (y1 >= screeny) { - x1 -= ((screeny - y1) * (x1 - x2)) / (y2 - y1); - y1 = screeny - 1; - } - if (y2 >= screeny) { - x2 -= ((screeny - y2) * (x1 - x2)) / (y2 - y1); - y2 = screeny - 1; - } - /* clip to left edge */ - if ((x1 < 0) && (x2 < 0)) - return; - if (x1 < 0) { - y1 += (x1 * (y1 - y2)) / (x2 - x1); - x1 = 0; - } - if (x2 < 0) { - y2 += (x2 * (y1 - y2)) / (x2 - x1); - x2 = 0; - } - /* clip to right edge */ - if ((x1 >= screenx) && (x2 >= screenx)) - return; - if (x1 >= screenx) { - y1 -= ((screenx - x1) * (y1 - y2)) / (x2 - x1); - x1 = screenx - 1; - } - if (x2 >= screenx) { - y2 -= ((screenx - x2) * (y1 - y2)) / (x2 - x1); - x2 = screenx - 1; - } - dx = x2 - x1; - dy = y2 - y1; - if (x1 > x2) { - int tmp; - - tmp = x1; - x1 = x2; - x2 = tmp; - tmp = y1; - y1 = y2; - y2 = tmp; - dx = x2 - x1; - dy = y2 - y1; - } + int val = value; + float t = (float) val * log10(power) / 2.0; - /* vertical line */ - if (dx == 0) { - if (y1 < y2) { - p = &(data[(screenx * y1) + x1]); - for (y = y1; y <= y2; y++) { - DRAWMETHOD; - p += screenx; - } - } - else { - p = &(data[(screenx * y2) + x1]); - for (y = y2; y <= y1; y++) { - DRAWMETHOD; - p += screenx; - } - } - return; - } - /* horizontal line */ - if (dy == 0) { - if (x1 < x2) { - p = &(data[(screenx * y1) + x1]); - for (x = x1; x <= x2; x++) { - DRAWMETHOD; - p++; - } - return; - } - else { - p = &(data[(screenx * y1) + x2]); - for (x = x2; x <= x1; x++) { - DRAWMETHOD; - p++; - } - return; - } - } - /* 1 */ - /* \ */ - /* \ */ - /* 2 */ - if (y2 > y1) { - /* steep */ - if (dy > dx) { - dx = ((dx << 16) / dy); - x = x1 << 16; - for (y = y1; y <= y2; y++) { - xx = x >> 16; - p = &(data[(screenx * y) + xx]); - DRAWMETHOD; - if (xx < (screenx - 1)) { - p++; -/* DRAWMETHOD; */ - } - x += dx; - } - return; - } - /* shallow */ - else { - dy = ((dy << 16) / dx); - y = y1 << 16; - for (x = x1; x <= x2; x++) { - yy = y >> 16; - p = &(data[(screenx * yy) + x]); - DRAWMETHOD; - if (yy < (screeny - 1)) { - p += screeny; -/* DRAWMETHOD; */ - } - y += dy; - } - } + if (t > 0) { + val = (int) t; // (32.0f * log (t)); + if (val > 255) + val = 255; + if (val < 0) + val = 0; + return val; } - /* 2 */ - /* / */ - /* / */ - /* 1 */ else { - /* steep */ - if (-dy > dx) { - dx = ((dx << 16) / -dy); - x = (x1 + 1) << 16; - for (y = y1; y >= y2; y--) { - xx = x >> 16; - p = &(data[(screenx * y) + xx]); - DRAWMETHOD; - if (xx < (screenx - 1)) { - p--; -/* DRAWMETHOD; */ - } - x += dx; - } - return; - } - /* shallow */ - else { - dy = ((dy << 16) / dx); - y = y1 << 16; - for (x = x1; x <= x2; x++) { - yy = y >> 16; - p = &(data[(screenx * yy) + x]); - DRAWMETHOD; - if (yy < (screeny - 1)) { - p += screeny; -/* DRAWMETHOD; */ - } - y += dy; - } - return; - } + return 0; } } static void +lightencolor (int *col, float power) +{ + unsigned char *color; + + color = (unsigned char *) col; + *color = lighten (*color, power); + color++; + *color = lighten (*color, power); + color++; + *color = lighten (*color, power); + color++; + *color = lighten (*color, power); +} + + + +void genline (int id, float param, GMUnitPointer * l, int rx, int ry) { int i; @@ -235,23 +81,23 @@ genline (int id, float param, GMUnitPointer * l, int rx, int ry) } } -static guint32 getcouleur (int mode) +guint32 getcouleur (int mode) { switch (mode) { case GML_RED: - return (230 << (ROUGE * 8)) | (120 << (VERT * 8)); + return (230 << (ROUGE * 8)) | (120 << (VERT * 8)) | (10 << (BLEU * 8)); case GML_ORANGE_J: - return (120 << (VERT * 8)) | (252 << (ROUGE * 8)); + return (120 << (VERT * 8)) | (252 << (ROUGE * 8)) | (10 << (BLEU * 8)); case GML_ORANGE_V: return (160 << (VERT * 8)) | (236 << (ROUGE * 8)) | (40 << (BLEU * 8)); case GML_BLEUBLANC: return (40 << (BLEU * 8)) | (220 << (ROUGE * 8)) | (140 << (VERT * 8)); case GML_VERT: - return (200 << (VERT * 8)) | (80 << (ROUGE * 8)); + return (200 << (VERT * 8)) | (80 << (ROUGE * 8)) | (10 << (BLEU * 8)); case GML_BLEU: return (250 << (BLEU * 8)) | (30 << (VERT * 8)) | (80 << (ROUGE * 8)); case GML_BLACK: - return 0x10 << (BLEU * 8); + return 0x5 << (BLEU * 8); } return 0; } @@ -260,6 +106,8 @@ void goom_lines_set_res (GMLine * gml, int rx, int ry) { if (gml != NULL) { + //int i; + gml->screenX = rx; gml->screenY = ry; @@ -268,7 +116,7 @@ goom_lines_set_res (GMLine * gml, int rx, int ry) } -static void +void goom_lines_move (GMLine * l) { int i; @@ -294,58 +142,28 @@ goom_lines_move (GMLine * l) } l->power += l->powinc; - if (l->power < -2.6f) { - l->power = -2.6f; - l->powinc = (float) (iRAND (20) + 10) / 600.0f; + if (l->power < 1.1f) { + l->power = 1.1f; + l->powinc = (float) (iRAND (20) + 10) / 300.0f; } - if (l->power > 0.6f) { - l->power = 0.6f; - l->powinc = -(float) (iRAND (20) + 10) / 600.0f; + if (l->power > 17.5f) { + l->power = 17.5f; + l->powinc = -(float) (iRAND (20) + 10) / 300.0f; } + + l->amplitude = (99.0f * l->amplitude + l->amplitudeF) / 100.0f; } void -goom_lines_switch_to (GMLine * gml, int IDdest, float param, int col) +goom_lines_switch_to (GMLine * gml, int IDdest, + float param, float amplitude, int col) { genline (IDdest, param, gml->points2, gml->screenX, gml->screenY); gml->IDdest = IDdest; gml->param = param; + gml->amplitudeF = amplitude; gml->color2 = getcouleur (col); -/* printf ("couleur %d : %x\n",col,gml->color2); */ -} - -static inline unsigned char -lighten (unsigned char value, float power) -{ - int val = value; - float t = exp ((float) val / 32.0f) + power; - - if (t > 0) { - val = (int) (32.0f * log (t)); - if (val > 255) - val = 255; - if (val < 0) - val = 0; - return val; - } - else { - return 0; - } -} - -static void -lightencolor (int *col, float power) -{ - unsigned char *color; - - color = (unsigned char *) col; - *color = lighten (*color, power); - color++; - *color = lighten (*color, power); - color++; - *color = lighten (*color, power); - color++; - *color = lighten (*color, power); +// printf ("couleur %d : %x\n",col,gml->color2); } GMLine * @@ -353,6 +171,10 @@ goom_lines_init (int rx, int ry, int IDsrc, float paramS, int coulS, int IDdest, float paramD, int coulD) { + //int i; + //unsigned char *color; + //unsigned char power = 4; + GMLine *l = (GMLine *) malloc (sizeof (GMLine)); l->points = (GMUnitPointer *) malloc (512 * sizeof (GMUnitPointer)); @@ -361,6 +183,8 @@ goom_lines_init (int rx, int ry, l->IDdest = IDdest; l->param = paramD; + + l->amplitude = l->amplitudeF = 1.0f; genline (IDsrc, paramS, l->points, rx, ry); genline (IDdest, paramD, l->points2, rx, ry); @@ -374,7 +198,7 @@ goom_lines_init (int rx, int ry, l->power = 0.0f; l->powinc = 0.01f; - goom_lines_switch_to (l, IDdest, paramD, coulD); + goom_lines_switch_to (l, IDdest, paramD, 1.0f, coulD); return l; } @@ -400,8 +224,8 @@ goom_lines_draw (GMLine * line, gint16 data[512], unsigned int *p) lightencolor (&color, line->power); - x1 = (int) (pt->x + cosa * data[0]); - y1 = (int) (pt->y + sina * data[0]); + x1 = (int) (pt->x + cosa * line->amplitude * data[0]); + y1 = (int) (pt->y + sina * line->amplitude * data[0]); for (i = 1; i < 512; i++) { int x2, y2; @@ -410,11 +234,12 @@ goom_lines_draw (GMLine * line, gint16 data[512], unsigned int *p) float cosa = cos (pt->angle) / 1000.0f; float sina = sin (pt->angle) / 1000.0f; - x2 = (int) (pt->x + cosa * data[i]); - y2 = (int) (pt->y + sina * data[i]); + x2 = (int) (pt->x + cosa * line->amplitude * data[i]); + y2 = (int) (pt->y + sina * line->amplitude * data[i]); draw_line (p, x1, y1, x2, y2, color, line->screenX, line->screenY); DRAWMETHOD_DONE (); + x1 = x2; y1 = y2; } |