The Kaleidoscope class transforms static images into living visual symmetry. It supports GPU and software fallback rendering, double-buffered transitions, and modular state control. This engine is crafted to be ethical, inclusive, performant, and enlightening β serving as both a powerful tool and a teaching aid.
class Kaleidoscope {
constructor({ canvas, resolution, debug, defaultImage })
}
canvas β HTMLCanvasElement to draw toresolution β { width, height } objectdebug β enables detailed trace outputdefaultImage β optional fallback imageimageA imageB β user-supplied original imagessourceSquareA sourceSquareB β square-resampled inputstargetBufferA targetBufferB β rendered symmetrical buffersfinalOutputA finalOutputB β final display images cropped to screen resolutionactiveBuffer nextBuffer β for double-buffered animation ping-pongangleA angleB β rotation in degrees for intuitive UIalphaA alphaB β crossfade blend weights (0.0β1.0)rev β seconds per revolutionspherize β radial lens distortion amount (applied to both outputs)refractionIndex β controls bend factor of spherizeradius β radius for spherize transformationanimate β true for continuous updatesloadImage(target, file) β assign an image to A or Bdraw() β render current frame (GPU or software)capture(filename) β export high-res screenshotfadeTo(nextImage, duration) β crossfade between imagesupdate(deltaTime) β update rotation + alpha blendstoggleDebug(state) β enable/disable tracingimageA / imageBsourceSquareAtargetBufferAfinalOutputAAll public-facing angles are in degrees. Internally, radians are used. You can manipulate:
kaleido.angleA = 45;
kaleido.angleB = 270;
kaleido.rev = 12; // one full turn every 12 seconds
This keeps the API intuitive for artists and educators.
Debug mode traces each function's entry, key state variables, and failures. Debug log can be downloaded or cleared. UI visibility is automatically toggled by debug.
Designed for universal creative access. High-end output, low-end compatibility:
This is not a proprietary trick β itβs a tool for light-based exploration. Everyoneβs welcome here.
This engine teaches students how geometry, rotation, and pixels converge to make something beautiful. All logic is shared in plain text β as it should be.