<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Ambimation</title>
	<atom:link href="http://osteele.com/archives/2008/05/ambimation/feed" rel="self" type="application/rss+xml" />
	<link>http://osteele.com/archives/2008/05/ambimation</link>
	<description>Languages of the real and artificial.</description>
	<lastBuildDate>Thu, 12 Feb 2009 00:20:28 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: oliver</title>
		<link>http://osteele.com/archives/2008/05/ambimation/comment-page-1#comment-458</link>
		<dc:creator>oliver</dc:creator>
		<pubDate>Fri, 02 May 2008 11:38:56 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/05/01/ambimation#comment-458</guid>
		<description>Thanks!  It&#039;s an OpenLaszlo application; the core looks like this:

[code language=&quot;xml&quot;]
&lt;canvas&gt;
  &lt;include href=&quot;filter-effects.lzx&quot;/&gt;
  &lt;class name=&quot;oflip&quot;
	 width=&quot;${canvas.width}&quot; height=&quot;${canvas.height}&quot;
	 resource=&quot;oflip.swf&quot; stretches=&quot;both&quot;/&gt;
    &lt;view id=&quot;outer&quot; x=&quot;${canvas.width/2}&quot; y=&quot;${canvas.height/2}&quot;&gt;
      &lt;view id=&quot;rotor&quot;&gt;
	&lt;oflip id=&quot;inner&quot;
	       x=&quot;${-canvas.width/2}&quot; y=&quot;${-canvas.height/2}&quot;
	       onclick=&quot;spin()&quot;&gt;
	  &lt;BlurFilterEffect name=&quot;fx&quot;/&gt;
	&lt;/oflip&gt;
      &lt;/view&gt;
    &lt;/view&gt;
    &lt;script&gt;
      function spin() { rotor.animate(&#039;rotation&#039;, 180, 1500, true) }
    &lt;/script&gt;
&lt;/canvas&gt;
[/code]
  
@class@ defines a view that&#039;s scaled to the canvas size and that embeds a Flash movie of the image.  The three levels of view hierarchy are because &#039;rotation&#039; is relative to the origin (the upper left corner); the @x@ and @y@ on @inner@ place the center of the image at the origin of the rotor, and the @x@ and @y@ on @outer@ place the origin of the rotor at the center of the canvas.  With matrices you rotate around a point by sandwiching the rotation between a translation and its inverse; instead I represent each transformation as a view and let the rendering engine do this, so that I can animate the @rotation@ attribute and let the animation system handle the rest.

To get the shadow, move the @x@ and @y@ from @inner@ to the definition of @oflip@ in the code above, and then make two more copies of @oflip@ right above @rotor@.  An interval timer copies the rotations from @inner@ -&gt; @s1@ -&gt; @s2@ on each frame.

[code language=&quot;xml&quot;]
      &lt;view id=&quot;shadows&quot;&gt;
        &lt;view id=&quot;s2&quot; opacity=&quot;0.25&quot;&gt;&lt;oflip/&gt;&lt;/view&gt;
        &lt;view id=&quot;s1&quot; opacity=&quot;0.5&quot;&gt;&lt;oflip/&gt;&lt;/view&gt;
      &lt;/view&gt;
[/code]

Mouse tracking uses &lt;code&gt;Math.atan2&lt;/code&gt; and the mouse position relative to &lt;code&gt;outer&lt;/code&gt;.  Motion blur animates the blur effect&#039;s blur radius up to 4 when the image is spinning and back down to 0 when it stops.  Both of these piggy-back on the same interval timer that makes the shadow.  I tried to turn off the effects when the frame rate got slow, but I don&#039;t think this worked, and I ran out of time.</description>
		<content:encoded><![CDATA[<p>Thanks!  It&#8217;s an OpenLaszlo application; the core looks like this:</p>
<p>[code language="xml"]<br />
<canvas><br />
  <include href="filter-effects.lzx"/><br />
  <class name="oflip"<br />
	 width="${canvas.width}" height="${canvas.height}"<br />
	 resource="oflip.swf" stretches="both"/><br />
    <view id="outer" x="${canvas.width/2}" y="${canvas.height/2}"><br />
      </view><view id="rotor"><br />
	<oflip id="inner"<br />
	       x="${-canvas.width/2}" y="${-canvas.height/2}"<br />
	       onclick="spin()"><br />
	  <blurfiltereffect name="fx"/><br />
	</oflip><br />
      </view></p>
<p>    <script>
      function spin() { rotor.animate('rotation', 180, 1500, true) }
    </script><br />
</canvas><br />
[/code]</p>
<p><code>class</code> defines a view that&#8217;s scaled to the canvas size and that embeds a Flash movie of the image.  The three levels of view hierarchy are because &#8216;rotation&#8217; is relative to the origin (the upper left corner); the <code>x@ and @y</code> on <code>inner</code> place the center of the image at the origin of the rotor, and the <code>x@ and @y</code> on <code>outer</code> place the origin of the rotor at the center of the canvas.  With matrices you rotate around a point by sandwiching the rotation between a translation and its inverse; instead I represent each transformation as a view and let the rendering engine do this, so that I can animate the <code>rotation</code> attribute and let the animation system handle the rest.</p>
<p>To get the shadow, move the <code>x@ and @y</code> from <code>inner</code> to the definition of <code>oflip</code> in the code above, and then make two more copies of <code>oflip</code> right above <code>rotor</code>.  An interval timer copies the rotations from <code>inner</code> -&gt; <code>s1@ -&gt; @s2</code> on each frame.</p>
<p>[code language="xml"]<br />
      <view id="shadows"><br />
        </view><view id="s2" opacity="0.25"><oflip /></view><br />
        <view id="s1" opacity="0.5"><oflip /></view></p>
<p>[/code]</p>
<p>Mouse tracking uses <code>Math.atan2</code> and the mouse position relative to <code>outer</code>.  Motion blur animates the blur effect&#8217;s blur radius up to 4 when the image is spinning and back down to 0 when it stops.  Both of these piggy-back on the same interval timer that makes the shadow.  I tried to turn off the effects when the frame rate got slow, but I don&#8217;t think this worked, and I ran out of time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://osteele.com/archives/2008/05/ambimation/comment-page-1#comment-457</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 02 May 2008 07:43:11 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/05/01/ambimation#comment-457</guid>
		<description>Isn&#039;t Scott Kim one of the people interviewed in Programmers at Work?  Cool.

Mind giving a few details on how you implemented this?</description>
		<content:encoded><![CDATA[<p>Isn&#8217;t Scott Kim one of the people interviewed in Programmers at Work?  Cool.</p>
<p>Mind giving a few details on how you implemented this?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
