Mixer: Use a four color gradient for meters.

pull/116/head
Jonathan Moore Liles 2013-06-19 18:46:47 -07:00
parent 6adf6a9389
commit 07161196bd
2 changed files with 24 additions and 6 deletions

View File

@ -53,7 +53,20 @@ DPM::DPM ( int X, int Y, int W, int H, const char *L ) :
/* initialize gradients */
if ( DPM::_gradient[ 0 ] == 0 )
DPM::blend( FL_GREEN, FL_RED );
{
int breaks[] = {0,60,70,80,90,127};
Fl_Color cols[] = {
fl_rgb_color( 45,58,64),
fl_rgb_color( 84,181,195 ),
fl_rgb_color( 122,200,211 ),
fl_rgb_color( 178,213,212 ),
fl_rgb_color( 209,213,179 ),
fl_rgb_color( 250, 40, 30 )
};
DPM::blend( 6, breaks, cols );
}
box( FL_FLAT_BOX );
color( FL_BACKGROUND_COLOR );
@ -170,7 +183,7 @@ DPM::draw ( void )
for ( int p = lo; p <= hi; p++ )
{
Fl_Color c;
if ( p > v && p != pv )
c = dim_div_color( p );
else if ( p != clipv )
@ -208,6 +221,7 @@ DPM::draw ( void )
fl_line( X, yy, X + W - 1, yy );
}
}
/* } */
/* else */
/* { */

View File

@ -88,12 +88,16 @@ public:
static
void
blend ( Fl_Color min, Fl_Color max )
blend ( int nbreaks, int* b, Fl_Color *c )
{
for ( int i = 128; i-- ; )
_gradient[ i ] = fl_color_average( max, min, i / (float)128 );
for ( int i = 0; i < nbreaks - 1; i++ )
{
int k = 0;
for ( int j = b[i]; j <= b[i+1]; j++, k++ )
_gradient[ j ] = fl_color_average( c[i+1], c[i], ( k ) / (float)(b[i+1] - b[i] ));
}
for ( int i = 128; i-- ; )
for ( int i = 0; i < 127; i++ )
_dim_gradient[ i ] = fl_color_average( FL_BLACK, _gradient[ i ], _dim );
}
};