From 230a4aefccf1e5a6a86385a38c48d20c1af30656 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Wed, 12 May 2004 22:06:02 +0000 Subject: [PATCH] added function to create blend tables --- 2d/palette.c | 21 ++++++++++++++++++++- ChangeLog | 3 +++ include/palette.h | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/2d/palette.c b/2d/palette.c index 30ed0e68a..aedfdf7db 100644 --- a/2d/palette.c +++ b/2d/palette.c @@ -1,4 +1,4 @@ -/* $Id: palette.c,v 1.10 2003-06-10 17:50:50 btb Exp $ */ +/* $Id: palette.c,v 1.11 2004-05-12 22:06:02 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -402,3 +402,22 @@ void gr_make_cthru_table(ubyte * table, ubyte r, ubyte g, ubyte b ) } } +void gr_make_blend_table(ubyte *blend_table, ubyte r, ubyte g, ubyte b) +{ + int i, j; + float alpha; + ubyte r1, g1, b1; + + for (j = 0; j < GR_FADE_LEVELS; j++) + { + alpha = 1.0 - (float)j / ((float)GR_FADE_LEVELS - 1); + for (i = 0; i < 255; i++) + { + r1 = (ubyte)((1.0 - alpha) * (float)gr_palette[i * 3 + 0] + (alpha * (float)r)); + g1 = (ubyte)((1.0 - alpha) * (float)gr_palette[i * 3 + 1] + (alpha * (float)g)); + b1 = (ubyte)((1.0 - alpha) * (float)gr_palette[i * 3 + 2] + (alpha * (float)b)); + blend_table[i + j * 256] = gr_find_closest_color(r1, g1, b1); + } + blend_table[i + j * 256] = 255; // leave white alone + } +} diff --git a/ChangeLog b/ChangeLog index f64b0e375..1a23665e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-05-12 Bradley Bell + * 2d/palette.c, include/palette.h: added function to create blend + tables + * maths/rand.c, maths/tables.c, maths/vecmat.c: formatting 2004-05-11 Bradley Bell diff --git a/include/palette.h b/include/palette.h index f1f8e6641..c105bb38c 100644 --- a/include/palette.h +++ b/include/palette.h @@ -1,4 +1,4 @@ -/* $Id: palette.h,v 1.3 2002-10-11 03:37:58 btb Exp $ */ +/* $Id: palette.h,v 1.4 2004-05-12 22:06:02 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -67,6 +67,7 @@ extern int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys ); extern int gr_palette_fade_in(ubyte *pal,int nsteps, int allow_keys ); extern void gr_palette_load( ubyte * pal ); extern void gr_make_cthru_table(ubyte * table, ubyte r, ubyte g, ubyte b ); +extern void gr_make_blend_table(ubyte *blend_table, ubyte r, ubyte g, ubyte b); extern int gr_find_closest_color_current( int r, int g, int b ); extern void gr_palette_read(ubyte * palette); extern void init_computed_colors(void);