Exemplo n.º 1
0
QImage KIconEffect::apply(const QImage &img, int effect, float value,
                          const QColor &col, const QColor &col2, bool trans) const
{
    QImage image = img;
    if (effect >= LastEffect) {
        qWarning() << "Illegal icon effect: " << effect;
        return image;
    }
    if (value > 1.0) {
        value = 1.0;
    } else if (value < 0.0) {
        value = 0.0;
    }
    switch (effect) {
    case ToGray:
        toGray(image, value);
        break;
    case DeSaturate:
        deSaturate(image, value);
        break;
    case Colorize:
        colorize(image, col, value);
        break;
    case ToGamma:
        toGamma(image, value);
        break;
    case ToMonochrome:
        toMonochrome(image, col, col2, value);
        break;
    }
    if (trans == true) {
        semiTransparent(image);
    }
    return image;
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void testApp::draw(){
    
    ofSetRectMode(OF_RECTMODE_CORNER);
    ofColor semiTransparent(0, 0, 0, 255.0 * 0.003);
    ofFill();
    ofSetColor(semiTransparent);
    ofRect(0,0, ofGetWindowWidth(), ofGetWindowHeight());
    
    mFbo.begin();
    
    // to prevent uncleared video memory!
    ofSetColor(255, 255, 255, 0);
    ofClear(255, 255, 255, 0);
    
    ofPushMatrix();{
    ofTranslate( pos );
    ofRotate( ofGetElapsedTimeMillis() * 0.001);
    
    float hue;
    
    for (int i =0; i < 40; i++){
        
        
        hue = ofMap(i, 0, 40, 0, 255);
        
        ofColor c;
        c.setHsb( hue, 255, 255);
        
        angle = sin(scaledTime + i);
        
        float newAmp = ofMap(angle, -1, 1, 40, 200);
        
        float x = cos(ofDegToRad(360/40 * i)) * newAmp;
        float y = sin(ofDegToRad(360/40 * i)) * newAmp;
        
        ofPushMatrix();
        ofSetColor(c);
        ofCircle(x, y, 1);
        ofPopMatrix();
        
    }
    }ofPopMatrix();
    
    mFbo.end();
    
    ofSetColor(255);
    mFbo.draw(0,0);
    mFbo.draw(0,100);
    mFbo.draw(100,100);
    mFbo.draw(100,0);
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void testApp::draw(){
//    ofBackground(100,100, 100, 255 * 0.1);

    ofPushMatrix();
        ofColor semiTransparent (100,100,100, 255.0*0.1);
        ofSetColor(semiTransparent);
        ofSetRectMode(OF_RECTMODE_CORNER);
        ofRect(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
    ofPopMatrix();
    
    for(int i = 0; i<rectlist.size(); i ++){
        rectlist[i].draw();
    }

}
Exemplo n.º 4
0
QPixmap KIconEffect::apply(const QPixmap &pixmap, int effect, float value,
                           const QColor &col, const QColor &col2, bool trans) const
{
    QPixmap result;

    if (effect >= LastEffect) {
        qWarning() << "Illegal icon effect: " << effect;
        return result;
    }

    if ((trans == true) && (effect == NoEffect)) {
        result = pixmap;
        semiTransparent(result);
    } else if (effect != NoEffect) {
        QImage tmpImg = pixmap.toImage();
        tmpImg = apply(tmpImg, effect, value, col, col2, trans);
        result = QPixmap::fromImage(tmpImg);
    } else {
        result = pixmap;
    }

    return result;
}
Exemplo n.º 5
0
MainWindow::MainWindow()
    : m_currentView(0),
      m_currentRootObject(0),
      m_transparent(false)
{
    QVBoxLayout *layout = new QVBoxLayout;

    QGroupBox *groupBox = new QGroupBox(tr("Type"));
    QVBoxLayout *vbox = new QVBoxLayout;
    m_radioView = new QRadioButton(tr("QQuickView in a window container (direct)"));
    m_radioWidget = new QRadioButton(tr("QQuickWidget (indirect through framebuffer objects)"));
    vbox->addWidget(m_radioWidget);
    vbox->addWidget(m_radioView);
    m_radioWidget->setChecked(true);
    m_state = Unknown;
    connect(m_radioWidget, &QRadioButton::toggled, this, &MainWindow::updateView);
    connect(m_radioView, &QRadioButton::toggled, this, &MainWindow::updateView);
    groupBox->setLayout(vbox);

    layout->addWidget(groupBox);

    m_checkboxMultiSample = new QCheckBox(tr("Multisample (4x)"));
    connect(m_checkboxMultiSample, &QCheckBox::toggled, this, &MainWindow::updateView);
    layout->addWidget(m_checkboxMultiSample);

    m_labelStatus = new QLabel;
    layout->addWidget(m_labelStatus);

    qmlRegisterType<FbItem>("fbitem", 1, 0, "FbItem");

    QWidget *quickContainer = new QWidget;
    layout->addWidget(quickContainer);
    layout->setStretchFactor(quickContainer, 8);
    m_containerLayout = new QVBoxLayout;
    quickContainer->setLayout(m_containerLayout);

    // Add an overlay widget to demonstrate that it will _not_ work with
    // QQuickView, whereas it is perfectly fine with QQuickWidget.
    QPalette semiTransparent(QColor(255,0,0,128));
    semiTransparent.setBrush(QPalette::Text, Qt::white);
    semiTransparent.setBrush(QPalette::WindowText, Qt::white);

    m_overlayLabel = new QLabel("This is a\nsemi-transparent\n overlay widget\nwhich is placed\non top\n of the Quick\ncontent.", this);
    m_overlayLabel->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
    m_overlayLabel->setAutoFillBackground(true);
    m_overlayLabel->setPalette(semiTransparent);
    QFont f = font();
    f.setPixelSize(QFontInfo(f).pixelSize()*2);
    f.setWeight(QFont::Bold);
    m_overlayLabel->setFont(f);
    m_overlayLabel->hide();

    m_checkboxOverlayVisible = new QCheckBox(tr("Show widget overlay"));
    connect(m_checkboxOverlayVisible, &QCheckBox::toggled, m_overlayLabel, &QWidget::setVisible);
    layout->addWidget(m_checkboxOverlayVisible);

    m_checkboxTransparent = new QCheckBox(tr("Transparent background in QQuickWidget"));
    connect(m_radioWidget, &QCheckBox::toggled, m_checkboxTransparent, &QWidget::setEnabled);
#ifdef Q_OS_LINUX
    connect(m_checkboxTransparent, &QCheckBox::toggled, this, &MainWindow::onTransparentChanged);
    layout->addWidget(m_checkboxTransparent);
#endif

    setLayout(layout);

    updateView();
}