| 1 |
/* Libvisual-plugins - Standard plugins for libvisual |
| 2 |
* |
| 3 |
* Copyright (C) 2000, 2001 Remi Arquier <[email protected]> |
| 4 |
* |
| 5 |
* Authors: Remi Arquier <[email protected]> |
| 6 |
* Dennis Smit <[email protected]> |
| 7 |
* |
| 8 |
* $Id: pal.c,v 1.5 2005/12/20 18:49:12 synap Exp $ |
| 9 |
* |
| 10 |
* This program is free software; you can redistribute it and/or modify |
| 11 |
* it under the terms of the GNU General Public License as |
| 12 |
* published by the Free Software Foundation; either version 2 |
| 13 |
* of the License, or (at your option) any later version. |
| 14 |
* |
| 15 |
* This program is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License |
| 21 |
* along with this program; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
*/ |
| 24 |
|
| 25 |
#include <stdlib.h> |
| 26 |
#include <math.h> |
| 27 |
|
| 28 |
#include "def.h" |
| 29 |
#include "struct.h" |
| 30 |
#include "analyser_struct.h" |
| 31 |
#include "jess.h" |
| 32 |
|
| 33 |
const float __magic = 2.0 * PI / 256; |
| 34 |
|
| 35 |
uint8_t courbes_palette(JessPrivate *priv, uint8_t i, int no_courbe) |
| 36 |
{ |
| 37 |
/* Optimisation par Karl Soulabaille */ |
| 38 |
switch(no_courbe) |
| 39 |
{ |
| 40 |
case 0: |
| 41 |
return (i * i * i) >> 16; |
| 42 |
break; |
| 43 |
case 1: |
| 44 |
return (i * i) >> 8; |
| 45 |
break; |
| 46 |
case 2: |
| 47 |
return (uint8_t) i ; |
| 48 |
break; |
| 49 |
case 3: |
| 50 |
return (uint8_t) (128 * fabs(sin(__magic * i))); |
| 51 |
break; |
| 52 |
case 4: |
| 53 |
return 0; |
| 54 |
break; |
| 55 |
} |
| 56 |
return 0; |
| 57 |
} |
| 58 |
|
| 59 |
void random_palette(JessPrivate *priv) |
| 60 |
{ |
| 61 |
int i,j,k,l; |
| 62 |
|
| 63 |
again_mister: |
| 64 |
; |
| 65 |
|
| 66 |
if (priv->conteur.psy == 1) |
| 67 |
i = 5; |
| 68 |
else |
| 69 |
i = 3; |
| 70 |
|
| 71 |
j=visual_random_context_int(priv->rcontext) % i; |
| 72 |
k=visual_random_context_int(priv->rcontext) % i; |
| 73 |
l=visual_random_context_int(priv->rcontext) % i; |
| 74 |
|
| 75 |
priv->conteur.triplet = j+10*k+100*l; |
| 76 |
|
| 77 |
if ((j==k) || (j==l) || (l==k)) |
| 78 |
goto again_mister; |
| 79 |
|
| 80 |
for (i = 0; i < 256; i++){ |
| 81 |
priv->jess_pal.colors[i].r = courbes_palette(priv, i, j); |
| 82 |
priv->jess_pal.colors[i].g = courbes_palette(priv, i, k); |
| 83 |
priv->jess_pal.colors[i].b = courbes_palette(priv, i, l); |
| 84 |
} |
| 85 |
} |
| 86 |
|