<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: sine code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 09 Oct 2008 19:22:49 GMT</pubDate>
    <description>DZone Snippets: sine code</description>
    <item>
      <title>Sine wave interference patterns</title>
      <link>http://snippets.dzone.com/posts/show/720</link>
      <description>A nice visualization from Simon Wittber's &lt;a href=http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334696&gt;recipe&lt;/a&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from appuifw import *&lt;br /&gt;import e32, random&lt;br /&gt;from math import *&lt;br /&gt;&lt;br /&gt;app.body = c = Canvas()&lt;br /&gt;width, height =  c.size&lt;br /&gt;freq = random.choice([25., 50., 100., 200., 400.])&lt;br /&gt;&lt;br /&gt;for y in range(height):&lt;br /&gt;    for x in range(width):&lt;br /&gt;        z1 = sin(x/freq*1.7*pi)&lt;br /&gt;        z2 = sin((x/3+y)/freq*1.5*pi)&lt;br /&gt;        z3 = sin(y/freq*0.1*pi)&lt;br /&gt;&lt;br /&gt;        z = abs(z1+z2+z3)*255&lt;br /&gt;        c.point((x,y), (z,z/4,z*4))&lt;br /&gt;c.text((5, height-12), u'Freq = %d' %freq, 0xffffff)&lt;br /&gt;&lt;br /&gt;e32.ao_sleep(5)    # wait 5 sec then quit&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;See a screenshot &lt;a href=http://www.flickr.com/photos/korakot/43547841/&gt;here&lt;/a&gt;.</description>
      <pubDate>Fri, 16 Sep 2005 01:14:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/720</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
