Widget Wednesdays #24

This week’s widget is, as suggested in an earlier post, a result of exploring the attic. Years ago I posted a simple program that uses an iterative loop to create a huge number of lovely looking patterns.

Unfortunately that code was written in Java, so it no longer runs on the Web. So this evening I reimplemented it in Javascript. It lives again!

As you move your mouse around, vast numbers of patterns are displayed. Some mouse positions produce beautifully symmetric results, others just result in a mess.

The core code is two lines that look something like the following, which get repeated 8000 times to make the point (x,y) trace out a pattern. The loop starts with x=y=t=0, and (X,Y) is your cursor position:

t += ( pow(x*x*Y, X) + pow(y*y/Y, Y) ) / 200;
lineTo(x += cos(t), y += sin(t));

I love the emergent nature of it all — how a multitude of patterns can arise from something so simple.

You can try it out here.

One thought on “Widget Wednesdays #24”

  1. Fun! Along similar lines:

    https://saccade.com/rtor/

    The “Torus” tab in particular.

    Ironically, this is also a re-write. I created the original while taking a class on creating apps in Flash, then wrote it in JavaScript when Flash went away. So far the JavaScript version has lasted a decade.

Leave a Reply

Your email address will not be published. Required fields are marked *