summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/imagefun
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/docs/examples/imagefun
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/docs/examples/imagefun')
-rw-r--r--kjsembed/docs/examples/imagefun/base.pngbin0 -> 1445 bytes
-rwxr-xr-xkjsembed/docs/examples/imagefun/bump.js87
-rw-r--r--kjsembed/docs/examples/imagefun/bump.ui327
-rw-r--r--kjsembed/docs/examples/imagefun/bumptest.pngbin0 -> 950 bytes
-rw-r--r--kjsembed/docs/examples/imagefun/mask-gradient.pngbin0 -> 9678 bytes
-rw-r--r--kjsembed/docs/examples/imagefun/mask-noise.pngbin0 -> 15997 bytes
-rwxr-xr-xkjsembed/docs/examples/imagefun/rotate.js26
-rwxr-xr-xkjsembed/docs/examples/imagefun/title.js36
8 files changed, 476 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/imagefun/base.png b/kjsembed/docs/examples/imagefun/base.png
new file mode 100644
index 00000000..46e60196
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/base.png
Binary files differ
diff --git a/kjsembed/docs/examples/imagefun/bump.js b/kjsembed/docs/examples/imagefun/bump.js
new file mode 100755
index 00000000..f6a0ded6
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/bump.js
@@ -0,0 +1,87 @@
+#!/usr/bin/env kjscmd
+
+function makeShape()
+{
+ var img = new Pixmap(this);
+ var mask = new Pixmap(this);
+ var painter = new Painter(this);
+
+ var brush = new Brush(this);
+ brush.setColor("black");
+ brush.setStyle(Brush.SolidBrush);
+ var pen = new Pen(this);
+ pen.setColor("black");
+
+ mask.resize(128,64);
+ img.resize(128,64);
+ img.fill("white");
+
+
+ if( painter.begin( img ) )
+ {
+ painter.setPen(pen);
+ painter.setBrush(brush);
+ painter.drawRoundRect( 2,2,126,62, 25, 25 );
+ if( painter.end() )
+ img = painter.pixmap();
+ }
+
+ img.setMask( img.createHeuristicMask(true) );
+ return img;
+}
+
+function makeGradient(size)
+{
+ var img = new Image();
+ img.gradient(size, "white", "black", img.PyramidGradient, 0);
+ return img;
+
+}
+
+function bump()
+{
+ var img1 = new Image();
+ var map = new Image();
+ var mask = new Pixmap();
+
+ img1.load( img1Loc );
+ map.load( img2Loc );
+ if ( !img1.isOk() && !map.isOk() ) {
+ var pix = makeShape();
+ img1.setPixmap(pix);
+ map = makeGradient( pix.size() );
+ mask = pix.mask();
+ }
+
+ println("Size 1: " + img1.width() + "x" + img1.height() );
+ println("Size 2: " + map.width() + "x" + map.height() );
+ var azmiuth = ui.child('azimuth').value; //135.0;
+ var elevation = ui.child('elevation').value; //45;
+ var depth = ui.child('depth').value; //3;
+ var xofs = ui.child('xofs').value; //5;
+ var yofs = ui.child('yofs').value; //5;
+ var waterlevel = ui.child('waterlevel').value; //0;
+ var ambient = ui.child('ambient').value; //0;
+ var compensate = ui.child('compensate').checked; //false;
+ var invert = ui.child('invert').checked; //false;
+ var type= ui.child('type').currentItem; //Image.Linear;
+ var tiled = ui.child('tiled').checked; //false;
+ img1.bumpmap(map, azmiuth, elevation, depth, xofs, yofs, waterlevel, ambient, compensate, invert, type, tiled);
+ var pix = img1.pixmap();
+// var pix = map.pixmap();
+// pix.setMask(mask);
+ view.pixmap = pix;
+}
+
+ var img1Loc = application.args[0];
+ var img2Loc = application.args[1];
+
+ var ui = Factory.loadui('bump.ui');
+ var go = ui.child('go');
+ var view = ui.child('view');
+
+ go.connect(go, "clicked()", this, "bump");
+
+ ui.show();
+
+ application.exec();
diff --git a/kjsembed/docs/examples/imagefun/bump.ui b/kjsembed/docs/examples/imagefun/bump.ui
new file mode 100644
index 00000000..90c5cc95
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/bump.ui
@@ -0,0 +1,327 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>Form1</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>524</width>
+ <height>445</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="5" column="0" rowspan="1" colspan="6">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>121</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>go</cstring>
+ </property>
+ <property name="text">
+ <string>Go</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="6">
+ <property name="name">
+ <cstring>view</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>2</horstretch>
+ <verstretch>2</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Depth:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>depth</cstring>
+ </property>
+ <property name="value">
+ <number>3</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="4" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel9</cstring>
+ </property>
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>Linear</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Spherical</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Sinuosidal</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>type</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="3" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>Y offset:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>yofs</cstring>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="2" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Elevation:</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput">
+ <property name="name">
+ <cstring>elevation</cstring>
+ </property>
+ <property name="value">
+ <number>45</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="2" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel7</cstring>
+ </property>
+ <property name="text">
+ <string>Ambient:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>ambient</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>X offset:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>xofs</cstring>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Azimuth:</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput">
+ <property name="name">
+ <cstring>azimuth</cstring>
+ </property>
+ <property name="value">
+ <number>135</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6</cstring>
+ </property>
+ <property name="text">
+ <string>Water level:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>waterlevel</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox" row="4" column="5">
+ <property name="name">
+ <cstring>tiled</cstring>
+ </property>
+ <property name="text">
+ <string>Tiled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="2" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>invert</cstring>
+ </property>
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>compensate</cstring>
+ </property>
+ <property name="text">
+ <string>Compensate</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>
diff --git a/kjsembed/docs/examples/imagefun/bumptest.png b/kjsembed/docs/examples/imagefun/bumptest.png
new file mode 100644
index 00000000..b6954838
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/bumptest.png
Binary files differ
diff --git a/kjsembed/docs/examples/imagefun/mask-gradient.png b/kjsembed/docs/examples/imagefun/mask-gradient.png
new file mode 100644
index 00000000..67fe031f
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/mask-gradient.png
Binary files differ
diff --git a/kjsembed/docs/examples/imagefun/mask-noise.png b/kjsembed/docs/examples/imagefun/mask-noise.png
new file mode 100644
index 00000000..c7d8bb72
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/mask-noise.png
Binary files differ
diff --git a/kjsembed/docs/examples/imagefun/rotate.js b/kjsembed/docs/examples/imagefun/rotate.js
new file mode 100755
index 00000000..c7869017
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/rotate.js
@@ -0,0 +1,26 @@
+#!/usr/bin/env kjscmd
+
+// Applies a rotate of 90 degrees to the image
+function apply_rotate( img )
+{
+ var foo = img.Rotate90;
+ println(foo);
+ img.rotate(foo);
+ return img;
+}
+
+if ( application.args.length == 0 ) {
+ throw 'Usage:\n\timageviewer imgfile ...';
+}
+else {
+ var loc = application.args[0];
+ var img = new Image();
+ img.load( loc );
+ if ( !img.isOk() ) {
+ throw 'Failed to load image ' + loc;
+ }
+
+ img = apply_rotate( img );
+
+ img.save( loc );
+}
diff --git a/kjsembed/docs/examples/imagefun/title.js b/kjsembed/docs/examples/imagefun/title.js
new file mode 100755
index 00000000..749899be
--- /dev/null
+++ b/kjsembed/docs/examples/imagefun/title.js
@@ -0,0 +1,36 @@
+#!/usr/bin/env kjscmd
+
+var textlayer = new Pixmap();
+var painter = new Painter();
+
+var w = 100;
+var h = 100;
+var test = "This is a test";
+var pn = new Pen(this);
+var bsh = new Brush(this);
+
+bsh.setColor("red");
+
+pn.setWidth(2);
+pn.setColor("red");
+
+textlayer.resize( w,h);
+textlayer.fill("white");
+if (painter.begin(textlayer) )
+{
+ painter.setPen(pn);
+ painter.setBrush(bsh);
+ painter.drawRoundRect( 5, 5, w-5, h-5, 25, 25 );
+ if( painter.end() )
+ {
+ var lbl = new QLabel();
+ var img = new Image(this);
+ img.setPixmap( painter.pixmap() );
+
+ img.emboss(0,1);
+ lbl.pixmap=img.pixmap();
+ lbl.show();
+ application.exec();
+
+ }
+}