void GlassLayer::draw(Graphics* const TheGraphics, const Pnt2f& TopLeft, const Pnt2f& BottomRight, const Real32 Opacity) const
{
    Pnt2f IntermediatePosition;
    Vec3f Bounds(BottomRight- TopLeft);
    
    //Setup the Blending equations properly
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    glBegin(GL_TRIANGLE_FAN);
        glColor4f(getEdgeColor().red(),getEdgeColor().green(),getEdgeColor().blue(),getEdgeColor().alpha() * Opacity);
        glVertex2f(getStartPosition().x(), getEndPosition().y());
        glColor4f(getCenterColor().red(),getCenterColor().green(),getCenterColor().blue(),getCenterColor().alpha() * Opacity);
        glVertex2fv(getStartPosition().getValues());
        for(UInt32 i(0) ; i<_Segments.size(); ++i)
        {
            IntermediatePosition.setValues(_Segments[i].x() * Bounds.x(),_Segments[i].y() * Bounds.y());
            glVertex2fv(IntermediatePosition.getValues());
        }
        glVertex2fv(getEndPosition().getValues());
    glEnd();

    glDisable(GL_BLEND);

}
示例#2
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 );
}
示例#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 );
  }
}