NAME - Random-dot stereograms


David M. Chess,


  use strict;
  use RaDoSt;
  srand();      # The module doesn't do any seeding itself

  # create a simple stereogram and save as a GIF
  open OUTH, ">rds1.gif";
  my $rds = new RaDoSt::Stereogram(\&callback);
  binmode OUTH;
  print OUTH $rds->gif();
  close OUTH;

  # create a larger black-and-white version
  open OUTH, ">rds2.gif";
  $rds->{width} = 600;     # These can also be set
  $rds->{height} = 500;    #   at new() time
  $rds->{colorcount} = 2;
  $rds->{colormap} = [ [0,0,0] , [255,255,255] ];
  $rds->{arows} = 0;       # No alignment strip
  binmode OUTH;
  print OUTH $rds->gif();
  close OUTH;

  # Sample callback routine
  sub callback {
    my ($x,$y) = @_;
    # progress report
    print "Row $x \n" if not $y;
    # a floating diamond
    return 7 if abs($x-200)+abs($y-200) < 100;
    # over an undulating plain
    return 3*(sin($x/20)+sin($y/30));


  1999/09/29 - First release version, 1.00

Creating a new object


returns a new stereogram object, of the default height and width, taking z-height information from the given callback routine. Default settings can be overridden by modifying the instance variables, as described below.

Defaults are:

  Width: 400
  Height: 400
  Colors: 16
  Colormap: undef
  Crossing width: 75
  Alignment rows: 5


returns a new stereogram object, as above, with the given callback routine, width, and height.

Instance variables


holds a reference to the sub that will be called for each point on the map, to obtain the height off the page of the 3D image at that point. The callback is passed two integers representing the acrossness and downness of the desired point, and it should return an integer whose absolute value is no more