コード例 #1
0
ファイル: ovgabuf2.cpp プロジェクト: mecirt/7k2
//------------- Start of function VgaBuf::indicator --------------//
//
// <int>   x1, y1, x2, y2 = coordination of the indicator
// <float> curValue       = the value of the bar
// <float> maxValue       = max value, the bar width = maxBarWidth * curValue / maxValue
// <int>   indiColor      = color of the indicator
// [int]   backColor      = background color
//                          (default : vga.color_down)
//			    (-2 if don't paint background color)
//
void VgaBuf::indicator(int x1, int y1, int x2, int y2, float curValue,
		    float maxValue, int indiColor, int backColor)
{
   if( backColor == -1 )
      backColor = color_down;

	int cutPoint;
	if( curValue <= 0.0f )
		cutPoint = x1;
	else if( curValue >= maxValue )
		cutPoint = x2 + 1;
	else
		cutPoint = x1 + int(float(x2 - x1 + 1) * curValue / maxValue);

	if( cutPoint > x1 )
	{
		int cutHeight = (y1 * 5 + y2 * 3) / 8;		// cut at 3/8 of between y1 and y2
		err_when( y2 - y1 - 1 < 4 );

		LinearCounter brightness;
		brightness.init( y1, 0, cutHeight, MAX_BRIGHTNESS_ADJUST_DEGREE-2 );		// glowing
		int y;
		for( y=y1; y <= cutHeight; y++, brightness.inc() )
		{
			barW_fast( x1, y, cutPoint, y, vga.vga_color_table->get_table(brightness.y)[indiColor]);
		}

		brightness.init( cutHeight, MAX_BRIGHTNESS_ADJUST_DEGREE-2, y2, -MAX_BRIGHTNESS_ADJUST_DEGREE/2 );		//
		for( ; y<=y2; ++y, brightness.inc() )
		{
			barW_fast( x1, y, cutPoint, y, vga.vga_color_table->get_table(brightness.y)[indiColor]);
		}
	}

	if( cutPoint <= x2 )
	{
		bar( cutPoint, y1, x2, y2, backColor );
	}
}
コード例 #2
0
ファイル: ovgabuf2.cpp プロジェクト: 112212/7k2
//------------- Start of function VgaBuf::indicator --------------//
//
// <int>   x1, y1, x2, y2 = coordination of the indicator
// <float> curValue       = the value of the bar
// <float> maxValue       = max value, the bar width = maxBarWidth * curValue / maxValue
// <int>   indiColor      = color of the indicator
// [int]   backColor      = background color
//                          (default : vga.color_down)
//			    (-2 if don't paint background color)
//
void VgaBuf::indicator(int x1, int y1, int x2, int y2, float curValue,
		    float maxValue, int indiColor, int backColor)
{
   if( backColor == -1 )
      backColor = color_down;

	/*
   if( curValue > maxValue )
		curValue = maxValue;

   if( curValue > 0 )
   {
      int barWidth = (int) ((float)(x2-x1) * curValue / maxValue);

		int halfHeight = (y2-y1+1)/2-1;
		int tx2        = x1+barWidth;
		int y;

		indiColor+=halfHeight;

		for( y=y1 ; y<y1+halfHeight ; y++, indiColor-- )
			bar( x1, y, tx2, y, indiColor );

		for( ; y<=y2 ; y++, indiColor++ )
			bar( x1, y, tx2, y, indiColor );

		if( backColor != -2 )	// -2 if don't paint background color
		{
			if( x1+barWidth < x2 )
			bar( x1+barWidth+1, y1, x2, y2, backColor );
		}
	}
	else
	{
		if( backColor != -2 )	// -2 if don't paint background color
			bar( x1, y1, x2, y2, backColor );
   }
	*/

	int cutPoint;
	if( curValue <= 0.0f )
		cutPoint = x1;
	else if( curValue >= maxValue )
		cutPoint = x2 + 1;
	else
		cutPoint = x1 + int(float(x2 - x1 + 1) * curValue / maxValue);

	if( cutPoint > x1 )
	{
		if( is_front )
			mouse.hide_area( x1, y1, cutPoint, y2 );

		int cutHeight = (y1 * 5 + y2 * 3) / 8;		// cut at 3/8 of between y1 and y2
		err_when( y2 - y1 - 1 < 4 );

		LinearCounter brightness;
		brightness.init( y1, 0, cutHeight, MAX_BRIGHTNESS_ADJUST_DEGREE-2 );		// glowing
		int y;
		for( y=y1; y <= cutHeight; y++, brightness.inc() )
		{
			barW_fast( x1, y, cutPoint, y, vga.vga_color_table->get_table(brightness.y)[indiColor]);
		}

		brightness.init( cutHeight, MAX_BRIGHTNESS_ADJUST_DEGREE-2, y2, -MAX_BRIGHTNESS_ADJUST_DEGREE/2 );		//
		for( ; y<=y2; ++y, brightness.inc() )
		{
			barW_fast( x1, y, cutPoint, y, vga.vga_color_table->get_table(brightness.y)[indiColor]);
		}

		if( is_front )
			mouse.show_area();
	}

	if( cutPoint <= x2 )
	{
		bar( cutPoint, y1, x2, y2, backColor );
	}
}