g = ( rgb >> 8 ) & 0xff;
b = rgb & 0xff;
}
+
+/*!
+ Name: scaleColor [static public]
+ Desc: Returns the color specified by the index between min (blue) and max (red).
+*/
+QColor Qtx::scaleColor( const int index, const int min, const int max )
+{
+ static const int HUE[10] = {230, 210, 195, 180, 160, 80, 60, 50, 30, 0};
+
+ int hue = HUE[0];
+
+ if ( min != max )
+ {
+ double aPosition = 9.0 * ( index - min ) / ( max - min );
+ if ( aPosition > 0.0 )
+ {
+ if ( aPosition >= 9.0 )
+ hue = HUE[9];
+ else
+ {
+ int idx = (int)aPosition;
+ hue = HUE[idx] + int( ( aPosition - idx ) * ( HUE[idx + 1] - HUE[idx] ) );
+ }
+ }
+ }
+
+ return QColor( hue, 255, 255, QColor::Hsv );
+}
+
+/*!
+ Name: scaleColors [static public]
+ Desc: Returns the 'num' number of colors from blue to red.
+*/
+void Qtx::scaleColors( const int num, QValueList<QColor>& lst )
+{
+ lst.clear();
+ for ( int i = 0; i < num; i++ )
+ lst.append( scaleColor( i, 0, num - 1 ) );
+}
static void rgbSet( const int, QColor& );
static void rgbSet( const int, int&, int&, int& );
+
+ static QColor scaleColor( const int, const int, const int );
+ static void scaleColors( const int, QValueList<QColor>& );
};
#endif
if ( colorMode() == User )
res = color( idx );
else
- res = QColor( hueFromValue( idx, 0, intervalsNumber() - 1 ), 255, 255, QColor::Hsv );
+ res = Qtx::scaleColor( idx, 0, intervalsNumber() - 1 );
return res;
}
return srt;
}
-//================================================================
-// Function : hueFromValue
-// Purpose :
-//================================================================
-
-int QtxColorScale::hueFromValue( const int value, const int min, const int max ) const
-{
- static const int HUE[10] = {230, 210, 195, 180, 160, 80, 60, 50, 30, 0};
-
- if ( min == max )
- return HUE[0];
-
- double aPosition = 9.0 * ( value - min ) / ( max - min );
-
- if ( aPosition <= 0. )
- return HUE[0];
-
- if ( aPosition >= 9. )
- return HUE[9];
-
- int idx = (int)aPosition;
-
- return HUE[idx] + int( ( aPosition - idx ) * ( HUE[idx + 1] - HUE[idx] ) );
-}
-
#if QT_VER == 3
/*********************************************************************
const bool, const bool, const bool ) const;
QSize calculateSize( const bool, const int,
const bool, const bool, const bool ) const;
- int hueFromValue( const int, const int, const int ) const;
friend class Dock;