Beispiel #1
0
void MarbleLineEditPrivate::createProgressAnimation()
{
    // Size parameters
    qreal const h = m_iconSize / 2.0; // Half of the icon size
    qreal const q = h / 2.0; // Quarter of the icon size
    qreal const d = 7.5; // Circle diameter
    qreal const r = d / 2.0; // Circle radius

    // Canvas parameters
    QImage canvas( m_iconSize, m_iconSize, QImage::Format_ARGB32 );
    QPainter painter( &canvas );
    painter.setRenderHint( QPainter::Antialiasing, true );
    painter.setPen( QColor ( Qt::gray ) );
    painter.setBrush( QColor( Qt::white ) );

    // Create all frames
    for( double t = 0.0; t < 2 * M_PI; t += M_PI / 8.0 ) {
        canvas.fill( Qt::transparent );
        QRectF firstCircle( h - r + q * cos( t ), h - r + q * sin( t ), d, d );
        QRectF secondCircle( h - r + q * cos( t + M_PI ), h - r + q * sin( t + M_PI ), d, d );
        painter.drawEllipse( firstCircle );
        painter.drawEllipse( secondCircle );
        m_progressAnimation.push_back( QPixmap::fromImage( canvas ) );
    }
}
Beispiel #2
0
void GoToDialogPrivate::createProgressAnimation()
{
    bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
    int const iconSize = smallScreen ? 32 : 16;

    // Size parameters
    qreal const h = iconSize / 2.0; // Half of the icon size
    qreal const q = h / 2.0; // Quarter of the icon size
    qreal const d = 7.5; // Circle diameter
    qreal const r = d / 2.0; // Circle radius

    // Canvas parameters
    QImage canvas( iconSize, iconSize, QImage::Format_ARGB32 );
    QPainter painter( &canvas );
    painter.setRenderHint( QPainter::Antialiasing, true );
    painter.setPen( QColor ( Qt::gray ) );
    painter.setBrush( QColor( Qt::white ) );

    // Create all frames
    for( double t = 0.0; t < 2 * M_PI; t += M_PI / 8.0 ) {
        canvas.fill( Qt::transparent );
        QRectF firstCircle( h - r + q * cos( t ), h - r + q * sin( t ), d, d );
        QRectF secondCircle( h - r + q * cos( t + M_PI ), h - r + q * sin( t + M_PI ), d, d );
        painter.drawEllipse( firstCircle );
        painter.drawEllipse( secondCircle );
        m_progressAnimation.push_back( QIcon( QPixmap::fromImage( canvas ) ) );
    }
}
Beispiel #3
0
int score(int dimension, char board[26][26], char colour, int i, int j){
    int score=0;
    char diffColour;
    int numRow, numCol;
    char row, col;
    bool legal = false;
    row = 'a'+i;
    col = 'a'+j;
    if (colour == 'W')
        diffColour ='B';
    if (colour == 'B')
        diffColour = 'W';
    int deltaRow, deltaCol;
    for(deltaRow=-1;deltaRow<=1;deltaRow++){
        for(deltaCol=-1;deltaCol<=1;deltaCol++){
            if((deltaRow!=0)||(deltaCol!=0)){
                if (checkLegalInDirection(board, dimension, row, col, colour, deltaRow, deltaCol)==true){
                    legal = true;
                    numRow = i;
                    numCol = j;
                    numRow += deltaRow;
                    numCol += deltaCol;
                    while (board[numRow][numCol] == diffColour){
                        score ++;
                        numRow += deltaRow;
                        numCol += deltaCol;
                    }
                }
            }
        }
    }
    if(legal == true){
        if (firstCircle(dimension, board, i, j) == true){
            if (strategyCorner(dimension, board, i, j) == true)
                score+=1000;
            else if ((i = 1)||(i = dimension-2)||(j = 1)||(j = dimension-2))
                score-=100;
            else 
                score+=100;
        }
        else if (secondCircle(dimension, board, i, j) == true){
            if (strategyStar(dimension, board, i, j) == true)
                score-=1000;
            else
                score+=50;
        }
        else if (thirdCircle(dimension, board, i,j) == true){
            score+=50;
        }
        else{
            
        }
    }
    else
        score = 0;
    return score;
}