You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
3.9 KiB
131 lines
3.9 KiB
11 years ago
|
import org.trinitydesktop.qt.*;
|
||
|
import org.trinitydesktop.koala.*;
|
||
15 years ago
|
|
||
|
//
|
||
|
// Simple little hack to show off blending effects.
|
||
|
//
|
||
|
// (C) KDE Artistic Cristian Tibirna <tibirna@kde.org>
|
||
|
//
|
||
|
|
||
|
/**
|
||
|
* Class to test KImageEffect blending effects.
|
||
|
*
|
||
|
* This is a translation to java from kblendtest.cpp in the tests library
|
||
13 years ago
|
* of tdeui source.
|
||
15 years ago
|
*
|
||
12 years ago
|
* @see TDEApplication
|
||
15 years ago
|
* @see KImageEffect
|
||
|
*
|
||
|
* @author Cristian Tibirna <tibirna@kde.org>, java translation Kenneth J. Pouncey, kjpou@hotmail.com
|
||
|
* @version 0.1
|
||
|
*/
|
||
|
|
||
|
public class KBlendTest {
|
||
|
|
||
|
public static void main(String[] args) {
|
||
12 years ago
|
TDECmdLineArgs.init(args, "kblendtest", "KBlendTest", "It blends!", "0.1");
|
||
12 years ago
|
TDEApplication app = new TDEApplication();
|
||
15 years ago
|
KBlendWidget w = new KBlendWidget(null,"KBlendTest");
|
||
|
w.setCaption(app.name());
|
||
|
app.setMainWidget(w);
|
||
|
w.show();
|
||
|
app.exec();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
public static class KBlendWidget extends TQWidget {
|
||
15 years ago
|
|
||
13 years ago
|
TQImage image;
|
||
|
TQColor bgnd;
|
||
15 years ago
|
|
||
|
String testImage = "testimage.png";
|
||
|
|
||
13 years ago
|
public KBlendWidget (TQWidget parent, String name) {
|
||
15 years ago
|
|
||
|
// change the colors to see the effects.
|
||
13 years ago
|
// bgnd = new TQColor(TQColor.qRgb(255, 255, 255));
|
||
15 years ago
|
bgnd = Qt.blue();
|
||
|
// bgnd = Qt.red();
|
||
|
|
||
13 years ago
|
image = new TQImage(testImage);
|
||
15 years ago
|
|
||
|
resize(image.width()*2+60, image.height()*3+80);
|
||
|
setBackgroundColor(bgnd);
|
||
|
}
|
||
|
|
||
13 years ago
|
protected void paintEvent(TQPaintEvent pe ) {
|
||
15 years ago
|
|
||
|
long it, ft;
|
||
|
String say = "";
|
||
|
|
||
13 years ago
|
image = new TQImage(testImage);
|
||
15 years ago
|
|
||
13 years ago
|
TQPainter p = new TQPainter(this);
|
||
15 years ago
|
|
||
|
p.setPen(Qt.black());
|
||
|
|
||
|
// you see here use of anti_dir param (blend from down to up, here)
|
||
|
it = System.currentTimeMillis();
|
||
|
KImageEffect.blend(image, 0.2f, bgnd, KImageEffect.VerticalGradient,true);
|
||
|
ft = System.currentTimeMillis();
|
||
|
say = (ft - it) + " ms, Vertical";
|
||
|
p.drawImage(20, 20, image);
|
||
|
p.drawText(5 , 15, say);
|
||
|
|
||
13 years ago
|
image = new TQImage(testImage);
|
||
15 years ago
|
|
||
|
// here a negative initial intensity is used (1/2 of image is unaffected)
|
||
|
it = System.currentTimeMillis();
|
||
|
KImageEffect.blend(image, -0.5f, bgnd, KImageEffect.HorizontalGradient);
|
||
|
ft = System.currentTimeMillis();
|
||
|
say = (ft - it) + " ms, Horizontal";
|
||
|
p.drawImage(40+image.width(), 20, image);
|
||
|
p.drawText(15+image.width() , 15, say);
|
||
|
|
||
13 years ago
|
image = new TQImage(testImage);
|
||
15 years ago
|
|
||
|
it = System.currentTimeMillis();
|
||
|
KImageEffect.blend(image, 0.0f, bgnd, KImageEffect.DiagonalGradient,true);
|
||
|
ft = System.currentTimeMillis();
|
||
|
say = (ft - it) + " ms, Diagonal";
|
||
|
p.drawImage(20, 40+image.height(), image);
|
||
|
p.drawText(5 , 35+image.height(), say);
|
||
|
|
||
13 years ago
|
image = new TQImage(testImage);
|
||
15 years ago
|
|
||
|
it = System.currentTimeMillis();
|
||
|
KImageEffect.blend(image, 0.1f, bgnd, KImageEffect.CrossDiagonalGradient);
|
||
|
ft = System.currentTimeMillis();
|
||
|
say = (ft - it) + " ms, CrossDiagonal";
|
||
|
p.drawImage(40+image.width(), 40+image.height(), image);
|
||
|
p.drawText(25+image.width() , 35 + image.height(), say);
|
||
|
|
||
13 years ago
|
image = new TQImage(testImage);
|
||
15 years ago
|
|
||
|
it = System.currentTimeMillis();
|
||
|
KImageEffect.blend(image, -0.6f, bgnd, KImageEffect.RectangleGradient);
|
||
|
ft = System.currentTimeMillis();
|
||
|
say = (ft - it) + " ms, Rectangle";
|
||
|
p.drawImage(20, 60+2*image.height(), image);
|
||
|
p.drawText(5 , 55+2*image.height(), say);
|
||
|
|
||
13 years ago
|
image = new TQImage(testImage);
|
||
15 years ago
|
|
||
|
it = System.currentTimeMillis();
|
||
|
KImageEffect.blend(image, 0.2f, bgnd, KImageEffect.EllipticGradient);
|
||
|
ft = System.currentTimeMillis();
|
||
|
say = (ft - it) + " ms, Elliptic";
|
||
|
p.drawImage(40+image.width(), 60+2*image.height(), image);
|
||
|
p.drawText(25+image.width(), 55+2*image.height(), say);
|
||
|
p.end();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
qtjava.initialize();
|
||
11 years ago
|
tdejava.initialize();
|
||
15 years ago
|
}
|
||
|
|
||
|
}
|