Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

Kaleidoscope-Creator

An example of drawing kaleidoscope images with different variations.

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

Kaleidoscope-Creator

Compiler 10 Seattle 10 1 Berlin 10 2 Tokyo 10 3 Rio 10 4 Sydney 11 Alexandria 12 Athens
Components None

A kaleidoscope is an optical instrument with two or more reflecting surfaces (or mirrors) tilted to each other at an angle, so that one or more (parts of) objects on one end of these mirrors are shown as a symmetrical pattern when viewed from the other end, due to repeated reflection. These reflectors are often enclosed in a tube, usually containing on one end a cell with loose, colored pieces of glass or other transparent (and/or opaque) materials to be reflected into the viewed pattern. Rotation of the cell causes motion of the materials, resulting in an ever-changing view being presented.

Use:

Move the mirror with the mouse or adjust it in X/Y using pixels.

The term "kaleidoscope" was coined by its Scottish inventor David Brewster. It is derived from the Ancient Greek word καλός (kalos), "beautiful, beauty", εἶδος (eidos), "form, appearance" and σκοπέω (skopeō), "to look, to examine", hence "observation of beautiful forms". It was first published in the patent that was granted on July 10, 1817.

Calculation from an image:

pascal
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
  bitmap:tbitmap;
  zrect,qrect:trect;
  ii,jj,v,v1,v2,modu,anz:integer;
  pu:array[0..4] of tpoint;
type
  TRGBArray = ARRAY[0..32767] OF TRGBTriple;
  pRGBArray = ^TRGBArray;
  TMyhelp = array[0..0] of TRGBQuad;

procedure Drehen90Grad(xBitmap:TBitmap);
var
  P       : PRGBQuad;
  x,y,b,h : Integer;
  RowOut  : ^TMyHelp;
  help    : TBitmap;
BEGIN
    xBitmap.PixelFormat := pf32bit;
    help := TBitmap.Create;
    help.PixelFormat := pf32bit;
    b := xbitmap.Height;
    h := xbitmap.Width;
    help.Width := b;
    help.height := h;
    for y := 0 to (h-1) do
    begin
      rowOut := help.ScanLine[y];
      P  := xBitmap.scanline[xbitmap.height-1];
      inc(p,y);
      for x := 0 to (b-1) do
      begin
        rowout[x] := p^;
        inc(p,h);
      end;
    end;
    xbitmap.Assign(help);
    help.free;
end;

Mirror:

pascal
procedure SpiegelnHorizontal(Bitmap:TBitmap);
var
  i,j,w :  INTEGER;
  RowIn :  pRGBArray;
  RowOut:  pRGBArray;
begin
    w := bitmap.width*sizeof(TRGBTriple);
    Getmem(rowin,w);
    for j := 0 to Bitmap.Height-1 do
    begin
      move(Bitmap.Scanline[j]^,rowin^,w);
      rowout := Bitmap.Scanline[j];
      for i := 0 to Bitmap.Width-1 do rowout[i] := rowin[Bitmap.Width-1-i];
    end;
    bitmap.Assign(bitmap);
    Freemem(rowin);
end;

Triangle turning:

pascal
procedure dreieckdrehen;
type
  SiCoDiType= record si, co, di:real; end;
var
  Center, NewCenter: record x,y:real end;
  theta: real;
  i: Integer;
  Bitmap, NewBitMap: Tbitmap;
function SiCoDiPoint ( const p1: tpoint; p2x,p2y:real ): SiCoDiType;
var
  dx, dy: real;
begin
    dx := ( p2x - p1.x );
    dy := ( p2y - p1.y );
    with RESULT do
    begin
      di := HYPOT( dx, dy );
      if abs( di )<1 then
      begin
        si := 0.0;
        co := 1.0
      end
      else
      begin
        si := dy/di;
        co := dx/di
      end;
    end;
end;

Light polarization:

In 1814, Sir David Brewster conducted experiments on light polarization by successive reflections between plates of glass and first noted "the circular arrangement of the images of a candle round a center, and the multiplication of the sectors formed by the extremities of the plates of glass". He forgot about it, but noticed a more impressive version of the effect during further experiments in February 1815. A while later, he was impressed by the multiplied reflection of a bit of cement that was pressed through at the end of a triangular glass trough, which appeared more regular and almost perfectly symmetrical in comparison to the reflected objects that had been situated further away from the reflecting plates in earlier experiments. This triggered more experiments to find the conditions for the most beautiful and symmetrically perfect conditions. An early version had pieces of colored glass and other irregular objects fixed permanently and was admired by some Members of the Royal Society of Edinburgh, including Sir George Mackenzie who predicted its popularity. A version followed in which some of the objects and pieces of glass could move when the tube was rotated. The last step, regarded as most important by Brewster, was to place the reflecting panes in a draw tube with a concave lens to distinctly introduce surrounding objects into the reflected pattern.

Example:

General variations:

  • variations in size (Brewster deemed a length of five to ten inches convenient, for one to four inches he suggested the use of a lens with a focus length equal to the length of the reflectors).
  • variations in the angle of inclination of the reflecting surfaces. In his patent Brewster deemed 18°, 20° or 22 1/2° most pleasing. In the treatise 45°, 36° and 30° are the primary examples.
  • variations in material of the reflecting surfaces (plates of plain glass, quicksilvered glass (mirror) or metal, or the reflecting inner surfaces of a solid prism of glass or rock crystal) The choice of material can have some influence of the tint and the quality of the image.
  • a wide variety of objects, small figures, fragments, liquids and materials of different colors and shapes can be used in object cells (apart from the more usual transparent fragments, for instance twisted pieces of iron or brass wire, or some lace, can produce very fine effects).