<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jappit.com &#187; effects</title>
	<atom:link href="http://www.jappit.com/blog/tag/effects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jappit.com/blog</link>
	<description>Mobile blog by Alessandro La Rosa</description>
	<lastBuildDate>Wed, 23 Nov 2011 10:38:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ImageFx: first commercial application is out!</title>
		<link>http://www.jappit.com/blog/2008/10/13/imagefx-first-commercial-application-is-out/</link>
		<comments>http://www.jappit.com/blog/2008/10/13/imagefx-first-commercial-application-is-out/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 11:23:35 +0000</pubDate>
		<dc:creator>pit</dc:creator>
				<category><![CDATA[advertising]]></category>
		<category><![CDATA[cool stuff]]></category>
		<category><![CDATA[j2me]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[fx]]></category>
		<category><![CDATA[image library]]></category>
		<category><![CDATA[imagefx]]></category>
		<category><![CDATA[java me]]></category>
		<category><![CDATA[transitions]]></category>

		<guid isPermaLink="false">http://www.jappit.com/blog/?p=163</guid>
		<description><![CDATA[ImageFx is a Java ME library that allows you to easily add animated transitions between different Images. And today Systema Mutui, the first commercial applications that makes use of it, has finally been launched The application itself is a simple animation that promotes bank services and allows users to share the animation itself with a [...]]]></description>
			<content:encoded><![CDATA[<p><a title="ImageFx launch" href="http://www.jappit.com/blog/2008/06/06/imagefx-j2me-image-effects-library/">ImageFx</a> is a <strong>Java ME library</strong> that allows you to <strong>easily add animated transitions between different Images</strong>.</p>
<p>And today <strong>Systema Mutui</strong>, the <strong>first commercial applications</strong> that makes use of it, has finally <strong>been launched</strong> <img src='http://www.jappit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img class="alignnone" title="Systema Mutui screenshot" src="http://www.jappit.com/images/blog/uploads/systema_mutui.jpg" alt="" /></p>
<p>The application itself is a <strong>simple animation</strong> that promotes bank services and allows users to share the animation itself with a friend. Obviously, <a title="ImageFx transitions examples" href="http://www.jappit.com/index.php?page=emulator&amp;midlet=image_fx" target="_blank">ImageFx transitions</a> were used to <strong>make the whole animation nicer</strong> <img src='http://www.jappit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To get further details about <strong>ImageFx API features</strong>, you can access its <strong>full JavaDocs</strong> here: <a title="ImageFx JavaDocs" href="http://www.jappit.com/j2me/imagefx/doc/" target="_blank">ImageFx JavaDocs</a>. For any other infos, feel free to <a title="About us page" href="http://www.jappit.com/index.php?page=about_us" target="_blank">contact me</a>!</p>]]></content:encoded>
			<wfw:commentRss>http://www.jappit.com/blog/2008/10/13/imagefx-first-commercial-application-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a color fading text in J2ME</title>
		<link>http://www.jappit.com/blog/2008/06/18/create-color-fading-text-in-j2me/</link>
		<comments>http://www.jappit.com/blog/2008/06/18/create-color-fading-text-in-j2me/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 11:40:54 +0000</pubDate>
		<dc:creator>pit</dc:creator>
				<category><![CDATA[j2me]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[colors]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[fading]]></category>
		<category><![CDATA[forumnokia]]></category>
		<category><![CDATA[fx]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[transitions]]></category>

		<guid isPermaLink="false">http://www.jappit.com/blog/?p=51</guid>
		<description><![CDATA[It&#8217;s time for new effects! Today we&#8217;ll see how to implement and and use text that changes multiple colors with a fading effect. You can see it in action here: J2ME text color fade effect in action. So, let&#8217;s start defining our ColorFadeText class. The code We start defining the necessary properties: //will hold the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time for new effects! <img src='http://www.jappit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Today we&#8217;ll see how to implement and and use <strong>text that changes multiple colors with a fading effect</strong>. You can see it in action here: <a title="Sample midlet using ColorFadeText class" href="http://www.jappit.com/index.php?page=emulator&#038;midlet=color_fade_text">J2ME text color fade effect in action</a>.</p>
<p><img src="http://www.jappit.com/images/blog/uploads/j2me_color_fade_text.gif" alt="Color Fading Text screenshot" /></p>
<p>So, let&#8217;s start defining our <strong>ColorFadeText </strong>class.</p>
<h3>The code</h3>
<p>We start defining the necessary <strong>properties</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//will hold the colors to fade</span>
<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> colors <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//duration of a single fade</span>
<span style="color: #000066; font-weight: bold;">int</span> fadeDuration <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//effect start time</span>
<span style="color: #000066; font-weight: bold;">long</span> startTime <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//property used to check if effect has started</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> started <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//the text to be drawn</span>
<span style="color: #003399;">String</span> text <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now, we define the main <strong>constructor</strong>, that will accept the following arguments:</p>
<ul>
<li>the <strong>text </strong>to be drawn</li>
<li>an int[] array containing the <strong>colors </strong>to fade into</li>
<li>the <strong>duration </strong>of a single fade</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> ColorFadeText<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> text, <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> colors, <span style="color: #000066; font-weight: bold;">int</span> fadeDuration<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>colors.<span style="color: #006633;">length</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You must define at least 1 color&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">text</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">colors</span> <span style="color: #339933;">=</span> colors<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fadeDuration</span> <span style="color: #339933;">=</span> fadeDuration<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The effect <strong>start()</strong> method will simply set the startTime value to current time and the started property to true</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	startTime <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	started <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then, we have the <strong>paint()</strong> method, that will be used to paint the text on the given Graphics instance:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> paint<span style="color: #009900;">&#40;</span><span style="color: #003399;">Graphics</span> g, <span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y, <span style="color: #000066; font-weight: bold;">int</span> anchor<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>started<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">long</span> diff <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> startTime<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> module <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">%</span> fadeDuration<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> colorIndex <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">/</span> fadeDuration<span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> colors.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> midColor <span style="color: #339933;">=</span> midColor<span style="color: #009900;">&#40;</span>
			colors<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>colorIndex <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> colors.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span>,
			colors<span style="color: #009900;">&#91;</span>colorIndex<span style="color: #009900;">&#93;</span>,
			module,
			fadeDuration
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		g.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>midColor<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #009900;">&#123;</span>
		g.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>colors<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	g.<span style="color: #006633;">drawString</span><span style="color: #009900;">&#40;</span>text, x, y, anchor<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The following utility method will be the one actually used <strong>to get the current text color</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> midColor<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> color1, <span style="color: #000066; font-weight: bold;">int</span> color2, <span style="color: #000066; font-weight: bold;">int</span> prop, <span style="color: #000066; font-weight: bold;">int</span> max<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">int</span> red <span style="color: #339933;">=</span>
		<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>color1 <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> 0xff<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> prop <span style="color: #339933;">+</span>
		<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>color2 <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> 0xff<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>max <span style="color: #339933;">-</span> prop<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> max<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">int</span> green <span style="color: #339933;">=</span>
		<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>color1 <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> 0xff<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> prop <span style="color: #339933;">+</span>
		<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>color2 <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> 0xff<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>max <span style="color: #339933;">-</span> prop<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> max<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">int</span> blue <span style="color: #339933;">=</span>
		<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>color1 <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> 0xff<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> prop <span style="color: #339933;">+</span>
		<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>color2 <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> 0xff<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>max <span style="color: #339933;">-</span> prop<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> max<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">int</span> color <span style="color: #339933;">=</span> red <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">16</span> <span style="color: #339933;">|</span> green <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">8</span> <span style="color: #339933;">|</span> blue<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">return</span> color<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>How to use it?</h3>
<p>Using the <strong>ColorFadeText </strong>object is quite simple, since it&#8217;ll be very similar to use a common String. Just follow this plain steps.</p>
<p><strong>1. </strong><strong>Create </strong>a ColorFadeText instance</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">ColorFadeText text <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ColorFadeText<span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">&quot;I'M A FADING TEXT!&quot;</span>,
	<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span>0xff0000, 0x00ff00, 0x0000ff, 0xff00ff<span style="color: #009900;">&#125;</span>,
	<span style="color: #cc66cc;">1000</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>2. </strong><strong>Start </strong>it&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">text.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>3. </strong>And then, in your Canvas paint() method, <strong>paint </strong>it, using the same arguments used by Graphics drawString() method (adding a reference to the Graphics instance of course):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">text.<span style="color: #006633;">paint</span><span style="color: #009900;">&#40;</span>g,
	getWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>,
	<span style="color: #cc66cc;">2</span>,
	<span style="color: #003399;">Graphics</span>.<span style="color: #006633;">HCENTER</span> <span style="color: #339933;">|</span> <span style="color: #003399;">Graphics</span>.<span style="color: #006633;">TOP</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Just a side note: since it&#8217;s an animated effect, you&#8217;ll need to <strong>repaint it quite frequently</strong>, so, for example, you can use a Thread to periodically call Canvas repaint() method.</p>
<h3>Source code download</h3>
<p>You can download <strong>source code </strong>of ColorFadeText, and of a sample Canvas that makes use of it:</p>
<ul>
<li><a title="ColorFadeText class source code" href="http://www.jappit.com/uploads/src/ColorFadeText.java">ColorFadeText.java</a>: main class source code</li>
<li><a title="AnimatedTextCanvas class source code" href="http://www.jappit.com/uploads/src/AnimatedTextCanvas.java">AnimatedTextCanvas.java</a>: a Canvas using the ColorFadeText object</li>
</ul>
<p>This article is also available on <strong>Forum Nokia Wiki</strong>: <a title="How to create a color fading text in Java ME" href="http://wiki.forum.nokia.com/index.php/How_to_create_a_color_fading_text_in_Java_ME" target="_blank">How to create a color fading text in Java ME</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.jappit.com/blog/2008/06/18/create-color-fading-text-in-j2me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ImageFx: J2ME image effects library</title>
		<link>http://www.jappit.com/blog/2008/06/06/imagefx-j2me-image-effects-library/</link>
		<comments>http://www.jappit.com/blog/2008/06/06/imagefx-j2me-image-effects-library/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 13:37:57 +0000</pubDate>
		<dc:creator>pit</dc:creator>
				<category><![CDATA[j2me]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[animations]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[image fx]]></category>
		<category><![CDATA[j2me api]]></category>
		<category><![CDATA[j2me library]]></category>
		<category><![CDATA[transitions]]></category>

		<guid isPermaLink="false">http://www.jappit.com/blog/?p=46</guid>
		<description><![CDATA[After two tutorials on Image animations in J2ME, I&#8217;ve finally decided to put together a library to easily integrate Image effects in a Java ME application. This first release is very very early, and is intended to be tested and to allow developers to give their feedbacks about it, so It&#8217;d be possible to modify [...]]]></description>
			<content:encoded><![CDATA[<p>After <a title="J2ME image sliding transitions" href="http://www.jappit.com/blog/2008/05/22/j2me-image-effects-part-2-sliding-transitions/">two</a> <a title="J2ME image explosion effect" href="http://www.jappit.com/blog/2008/05/20/let-your-images-explode-in-j2me/">tutorials</a> on Image animations in J2ME, I&#8217;ve finally decided to put together a <strong>library to easily integrate Image effects in a Java ME application</strong>. This first release is very very early, and is intended to be tested and to allow developers to give their feedbacks about it, so It&#8217;d be possible to modify and improve it.</p>
<p><img src="http://www.jappit.com/images/blog/uploads/imagefx_banner.gif" alt="ImageFx Banner" width="400" height="149" /></p>
<p>Currently supported effects are visible on the <a title="ImageFx in action" href="http://www.jappit.com/index.php?page=emulator&amp;midlet=image_fx">emulator page</a>, and are:</p>
<ul>
<li><strong>BlindsFx</strong></li>
<li><strong>ExplodeFx</strong></li>
<li><strong>PuzzleFx</strong></li>
<li><strong>ShakeFx</strong></li>
<li><strong>SlideFx</strong></li>
<li><strong>SpiralFx</strong></li>
<li><strong>WaveFx</strong></li>
<li><strong>WipeFx</strong></li>
</ul>
<h3>How to use it?</h3>
<p>Let&#8217;s start from a simple usage example. We start creating an Image, and then using it to create an AnimatedImage instance:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Image</span> baseImage <span style="color: #339933;">=</span> <span style="color: #003399;">Image</span>.<span style="color: #006633;">createImage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/base.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
AnimatedImage animated <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AnimatedImage<span style="color: #009900;">&#40;</span>baseImage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now, we have created an <strong>AnimatedImage</strong>, that is the base class that will allow us to apply effects to <strong>Image</strong>s.</p>
<p>Now, we can create an effect (that will be a subclass of <strong>ImageFx</strong>) and apply it to our AnimatedImage:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">ImageFx fx <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PuzzleFx<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span>, <span style="color: #cc66cc;">8</span>, ImageFx.<span style="color: #006633;">TYPE_IN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
animated.<span style="color: #006633;">setFx</span><span style="color: #009900;">&#40;</span>fx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this example, we have chosen a <strong>PuzzleFx </strong>effect, that will show (or hide, depending on Fx type) our image piece by piece. As you can check on <a title="PuzzleFx JavaDocs" href="http://www.jappit.com/j2me/imagefx/doc/com/jappit/imagefx/fxs/PuzzleFx.html" target="_blank">JavaDocs page for PuzzleFx class</a>, first 2 arguments represent the horizontal and vertical pieces to split the Image into, while the last one is the type of the Fx itself.</p>
<p>Now, our AnimatedImage is ready to be animated. To start the animation, simply call the AnimatedImage <strong>start()</strong> method, passing as argument the <strong>effect duration in milliseconds</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">animated.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span>3000L<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>About painting, you&#8217;ll simply have to call the <strong>paint()</strong> method, in a way that is really similar to Graphics drawImage():</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">animated.<span style="color: #006633;">paint</span><span style="color: #009900;">&#40;</span>g, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #003399;">Graphics</span>.<span style="color: #006633;">TOP</span> <span style="color: #339933;">|</span> <span style="color: #003399;">Graphics</span>.<span style="color: #006633;">LEFT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now, to begin using this library, you don&#8217;t really need any more infos. Just to point out some methods you can find useful in your app:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//stop() method will immediatly stop the FX</span>
fx.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//isRunning() method tells if the FX is running or not</span>
fx.<span style="color: #006633;">isRunning</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//isEnded() method tells if the FX animation is ended</span>
fx.<span style="color: #006633;">isEnded</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//and, if you want a looping effect, you can use</span>
fx.<span style="color: #006633;">setLooping</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Further information</h3>
<p>You can library JAR file here: <a title="ImageFx J2ME image effects library" href="http://www.jappit.com/uploads/j2me/ImageFx.jar">ImageFx.jar</a>. Current version requires MIDP 2.0 and CLDC 1.1 to be used (a version compatible with CLDC 1.0 will be released as soon as I&#8217;ve got time <img src='http://www.jappit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>Full API JavaDocs (still in early phase too <img src='http://www.jappit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) are also available <a title="ImageFx API JavaDocs" href="http://www.jappit.com/j2me/imagefx/doc/" target="_blank">here</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.jappit.com/blog/2008/06/06/imagefx-j2me-image-effects-library/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

