Exemple #1
0
void drawButtonText( button_t *pBut )
{
  int text;
  int l = strlen( pBut->txt );
  int size = ( l > 1 ) ? 2 : 3;
  int sink = pBut->pressed ? SD : 0;
  int background = getCenterColor( pBut );

  int width = l * size * picassoGetLetterWidth( );
  int height = size * picassoGetLetterHeight( );

  int xOff = ( pBut->x2 - pBut->x1 - width ) / 2;
  int yOff = ( pBut->y2 - pBut->y1 - height ) / 2;

  if( pBut->color == BLACK )
    text = pBut->lit ? BLACK : WHITE;
  else
    text = pBut->lit ? darkenColor( pBut->color, 30 ) : BLACK;

  picassoSetTextBackground( background );
  picassoSetTextColor( text );
  picassoSetTextSize( size );

  picassoPutText( pBut->x1+xOff+sink, pBut->y1+yOff+sink, pBut->txt );
}
// Calculate the thumb colors based on the specified background color.
void Slider::setThumbColorBasedOnColor(const GFXColor& c) {
	if(!isClear(c)) {
		if(isColorLight(c)) {
			// Light color.  Make thumb darker.
			setThumbColor(darkenColor(c,.3), GUI_OPAQUE_WHITE());
		} else {
			// Dark Color.
			setThumbColor(lightenColor(c,.3), GUI_OPAQUE_WHITE());
		}
	}
}
Exemple #3
0
void drawButton( button_t *pBut )
{
  int frame = darkenColor( pBut->color, pBut->lit ? 80 : 60 );
  int center = getCenterColor( pBut );
  int sink = pBut->pressed ? SD : 0;
  
  if( pBut->color == TRANSPARENT_KEY )
  {
    return;
  }

  if( pBut->color == BLACK ) frame = GRAY;

  picassoSetFont( 0 );  
  picassoSetTextSize( 1 );
  picassoSetColor( BLACK );

  if( sink )
  {
    picassoDrawRect( pBut->x1,pBut->y1,pBut->x2+sink,pBut->y1+sink,1 );
    picassoDrawRect( pBut->x1,pBut->y1+sink,pBut->x1+sink,pBut->y2+sink,1 );
  }
  else
  {
    picassoDrawRect( pBut->x2+1,pBut->y1,pBut->x2+SD,pBut->y2+SD,1 );
    picassoDrawRect( pBut->x1,pBut->y2+1,pBut->x2,pBut->y2+SD,1 );
  }
  
  picassoSetColor( frame );
  picassoDrawRect( pBut->x1+sink,pBut->y1+sink,pBut->x2+sink,pBut->y2+sink,0 );
  picassoSetColor( center );
  picassoDrawRect( pBut->x1+1+sink,pBut->y1+1+sink,pBut->x2-1+sink,pBut->y2-1+sink,1 );

  if( pBut->txt[0] )
  {
    drawButtonText( pBut );
  }
}
Exemple #4
0
void Buffer::darken( double factor ) {
  for( int i = 0; i < HEXAGON_LED_COUNT; i++ ) {
    setPixel( i, darkenColor( getPixel( i ), factor ) );
  }
}
Exemple #5
0
int getCenterColor( button_t *pBut )
{
  return darkenColor( pBut->color, pBut->lit ? 100 : 15 );
}