8 Queens Problem
Abhivadaye
Anagram Finder
Bouncing Spheres
Break Out
Classic Snake
Cycloids
Deflection Demo
Double Pendulum
EV Savings
Flocking
Fog fly through
Forces on Objects
Fractals
Game of Life
Horizontal Stars
Image Scanning
JSON Beautify
Julia Sets
Kaleidoscope
Kock Fractals
Lorenz Attractor
Mandlebrot Set
Meta Balls
Natural Flocking
Number Convert
Number Game
Pandemic Simulator
Particles & Nodes
Perlin Noise
Poisson Disk
QuadTree Search
Ripples
Set Demonstration
Sierpiński Triangles
Simple Pendulum
Sine Waves
Starfield
Super Shapes 2D
Target Finder
Tic Tac Toe
Voronoi Diagram
Who Moved My...
Kaleidoscope
This is a kaleidoscope implemented in canvas.
01 Jan 2007
Patterns can be created in HTML5 canvas using context object’s function “createPattern”. Patterns can be created with images. Fortunately for us, HTML5 treats Canvas objects itself as images. With this in mind I thought it would be easy to implement an animated kaleidoscope.
//Pattern using an image
var pattern = aContext.createPattern(anImage, 'repeat');
//Pattern using another canvas.
var pattern = aContext.createPattern(orAnotherCanvas, 'repeat');

A pattern is created out of this and this pattern is applied to a pie shape.

This shape is then rotated around its axis and this will form a kaleidoscope.
While this worked wonderfully and was very easy to implement, I found out that the createPattern function eats up a lot of memory and the longer the kaleidoscope runs, the slower the animation gets. And I am talking about slowness on an 8GB, Intel i7 processor. That is bad.
This was obviously abandoned.
The below implementation is a much simpler one. One that does not use createPattern and thus is not processor or memory intensive. In this solution I have taken an animating canvas and rotate it 45 degrees each time. Here is what one slice looks like.

With two slices it becomes clear where we are going with this.

We can do this until the penultimate slice, because the last slice is going to overlap the first one and thus will ruin the illusion.
For the last slice alone, I create another canvas that is clipped to the exact dimensions that is required to fill the gap.
The final effect is very nice. But I’ll let you be the judge.
Select from one of the below animating patterns.