Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Sine wave interference patterns

A nice visualization from Simon Wittber's recipe
from appuifw import *
import e32, random
from math import *

app.body = c = Canvas()
width, height =  c.size
freq = random.choice([25., 50., 100., 200., 400.])

for y in range(height):
    for x in range(width):
        z1 = sin(x/freq*1.7*pi)
        z2 = sin((x/3+y)/freq*1.5*pi)
        z3 = sin(y/freq*0.1*pi)

        z = abs(z1+z2+z3)*255
        c.point((x,y), (z,z/4,z*4))
c.text((5, height-12), u'Freq = %d' %freq, 0xffffff)

e32.ao_sleep(5)    # wait 5 sec then quit

See a screenshot here.
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS