Exemplo n.º 1
0
void Tray::paintIcon( int mergePixels, bool force )
{
    // skip redrawing the same pixmap
    static int mergePixelsCache = 0;
    if ( mergePixels == mergePixelsCache && !force )
         return;
    mergePixelsCache = mergePixels;

    if ( mergePixels < 0 )
        return blendOverlay( baseIcon );

    // make up the grayed icon
    if ( !grayedIcon )
    {
        QImage tmpTrayIcon = baseIcon->toImage();
        KIconEffect::semiTransparent( tmpTrayIcon );
        grayedIcon = new QPixmap( QPixmap::fromImage( tmpTrayIcon ) );
    }
    if ( mergePixels == 0 )
        return blendOverlay( grayedIcon );

    // make up the alternate icon (use hilight color but more saturated)
    if ( !alternateIcon )
    {
        QImage tmpTrayIcon = baseIcon->toImage();
        // eros: this looks cool with dark red blue or green but sucks with
        // other colors (such as kde default's pale pink..). maybe the effect
        // or the blended color has to be changed..
        QLabel label; //just a hack to get the palette
        QColor saturatedColor = label.palette().color(QPalette::Active, QPalette::Highlight);
        int hue, sat, value;
        saturatedColor.getHsv( &hue, &sat, &value );
        saturatedColor.setHsv( hue, (sat + 510) / 3, value );
        KIconEffect::colorize( tmpTrayIcon, saturatedColor/* Qt::blue */, 0.9 );
        alternateIcon = new QPixmap( QPixmap::fromImage( tmpTrayIcon ) );
    }
    if ( mergePixels >= alternateIcon->height() )
        return blendOverlay( alternateIcon );

    // mix [ grayed <-> colored ] icons
    QPixmap tmpTrayPixmap( *alternateIcon );
    QPainter paint;
    paint.begin( &tmpTrayPixmap );
    paint.drawPixmap( 0, 0, *grayedIcon, 0, 0,
        alternateIcon->width(), alternateIcon->height() - mergePixels );
    paint.end();

    blendOverlay( &tmpTrayPixmap );
}
Exemplo n.º 2
0
void ParkScene::_draw(float time)
{
	float camTime = time / Duration();
	mat4 mPersp = perspective(mix(45.0f, endFov, myx(camTime)), demo.aspect, 0.5f, 1000.0f);
	mat4 mCamera = lookAt(interpolatePath(oCamPath, endCamPos * 0.1f, camTime), interpolatePath(oLookPath, endLookAt * 0.1f, camTime), mix(vec3(0, 1, 0), endUp, myx(camTime)));

	setDepthMode(DEPTH_FULL);
	for (int i = 0; i < ARRAY_SIZE(tPark); i++) {
		GlslShader *sDraw = sPark[i];
		sDraw->bind();
		sDraw->uniform("u_matrix", mPersp * mCamera);
		sDraw->uniform("u_modelview", mCamera);
		sDraw->uniform("u_projection", mPersp);
		sDraw->uniform("u_alpha", 1.0f);
		sDraw->bindTexture("tex", tPark[i], 0);
		oPark->draw(i);
		sDraw->unbind();
	}
	if (time > Duration() - SceneTime::park2ink) {
		setBlendMode(BLEND_ALPHA);
		sDrawOverlay->bind();
		sDrawOverlay->uniform("u_matrix", mat4(1));
		sDrawOverlay->uniform("u_modelview", mCamera);
		sDrawOverlay->uniform("u_projection", mPersp);
		sDrawOverlay->bindFbo("tex", gFullScreenFbo, 0);
		blendOverlay(oInkBlotOverlay, mPersp * mCamera, pow(clamp((time - Duration() + ovlBlendTime) / ovlBlendTime, 0.0f, 1.0f), 2.0f));
		sDrawOverlay->unbind();
		setBlendMode(NO_BLEND);
	}
	setDepthMode(NO_DEPTH);
}
Exemplo n.º 3
0
void
amaroK::TrayIcon::paintIcon( int mergePixels, bool force )
{
    // skip redrawing the same pixmap
    static int mergePixelsCache = 0;
    if ( mergePixels == mergePixelsCache && !force )
         return;
    mergePixelsCache = mergePixels;

    if ( mergePixels < 0 )
        return blendOverlay( baseIcon );

    // make up the grayed icon
    if ( grayedIcon.isNull() )
    {
        QImage tmpTrayIcon = baseIcon.convertToImage();
        KIconEffect::semiTransparent( tmpTrayIcon );
        grayedIcon = tmpTrayIcon;
    }
    if ( mergePixels == 0 )
        return blendOverlay( grayedIcon );

    // make up the alternate icon (use hilight color but more saturated)
    if ( alternateIcon.isNull() )
    {
        QImage tmpTrayIcon = baseIcon.convertToImage();
        // eros: this looks cool with dark red blue or green but sucks with
        // other colors (such as kde default's pale pink..). maybe the effect
        // or the blended color has to be changed..
        QColor saturatedColor = palette().active().highlight();
        int hue, sat, value;
        saturatedColor.getHsv( &hue, &sat, &value );
        saturatedColor.setHsv( hue, sat > 200 ? 200 : sat, value < 100 ? 100 : value );
        KIconEffect::colorize( tmpTrayIcon, saturatedColor/* Qt::blue */, 0.9 );
        alternateIcon = tmpTrayIcon;
    }
    if ( mergePixels >= alternateIcon.height() )
        return blendOverlay( alternateIcon );

    // mix [ grayed <-> colored ] icons
    QPixmap tmpTrayPixmap = alternateIcon;
    copyBlt( &tmpTrayPixmap, 0,0, &grayedIcon, 0,0,
            alternateIcon.width(), alternateIcon.height() - mergePixels );
    blendOverlay( tmpTrayPixmap );
}