kscope is a javascript kaleidoscope implemented using the new p5.js library. p5.js is "a new interpretation" of processing.js, which in turn was a way to execute Processing sketches in the browser. I find p5.js interesting because it offers processing-like capabilities in Javascript, without the need to write Processing's java-ish code (Processing is not Java, except when it is).

kscope started life several years ago as a Java Swing application. At some point, I converted it to a Processing sketch, then ran it on this site using processing.js. When I heard about p5.js, I thought I'd convert kscope one more time.

p5.js is fairly new, so I ran into a few bumps, mostly around moving pixels from one image to another (kscope does a lot of pixel moving, because it needs to reverse images to produce its kaleidoscope-like effect). In Processing (and processing.js), it was easy to use get() and set() methods with x and y (and sometimes height and width) parameters, and the get() and set() methods ran quickly in the browser. p5.js offers similar get() and set() methods; however, they're very slow, so I had to add code to do the pixel picking pixel by pixel ("If Stephen Pentecost picked a slew of pixels pixel by pixel . . . ").

Despite this little bump, I'm really happy with p5.js. It's nice to do Processing-like stuff without the Java baggage.


The original versions of kscope used mouse movements to shift the kaleidoscope image. I tried that with the p5.js version, and it didn't work as smoothly, mostly because I had trouble coordinating the timing of mouse movements, p5.js's draw() loop, and the render time for refreshes to the canvas. More work would certainly lead to a solution; however, the current implementation, which cycles endlessly from one (almost random) state to another, seems to yield a reasonably interesting display.

Walter Crane, again

kscope uses images by Walter Crane (these particular images come from Wikimedia, although there are tons of them on the internet). I used black-and-white images by Walter Crane for The Mutable Stanzas. Unfortunately, black-and-white images don't make for a compelling kaleidoscope; however, Crane's color images often have a palette which works well with the visual "mood" established by The Mutable Stanzas. So I guess I can start thinking about an overarching presentation style for this site.