Revision 1.1 by Raisonance :
Project source(s) were modified to ensure compatability with Primer2. The archive is updated with a Ride project adapted to Primer2.
(Replace specific low level functions by standard API for LCD access).
Features:
This program creates symmetrical random images usually seen in the optical kaleidoscope. In the original kaleidoscope the arrangement of the mirrors creates a multiply reflected image, which has a special symmetry determined by the number and configuration of the mirrors. The most common kaleidoscope has 2 or 3 mirrors, arranged in 60 degrees relation to each other. This creates a double hexagonal symmetry, something like you see on the display of this electronic kaleidoscope.
The image is constructed of rotated and mirrored versions of a single triangle. The triangles are rasterized, and at the same time clipped to create a hexagonal symmetry. The resulting images are multiplied and shifted to simulate the infinite reflections of the mirrors.
The picture can be changed by slowly rotating/shaking the Primer. At each step a number of triangles are drawn on the screen. Their color, position and rotation are chosen randomly. The resulting image shows an infinite variety of symmetrical configurations.
The program contains several general purpose and reusable components. There is a 2D transformation engine for rotating and translating the triangles (includes an efficient fixpoint sin/cos implementation); a simple random number generator; an efficient span-based software triangle rasterizer which can be used either in a 2D or a 3D rendering engine; and a moving average filter for smoothing the MEMS data.
Enjoy!