An ARRAY Example

The following example demonstrates how an array is created. It can be displayed as an 8-bit grey-scale. The command change/ct id can be used to change the colour representation.

  #!/usr/bin/perl

  use Spectra; 
  use GQE; 

  cls();
  delete();

  $nx = 220;
  $ny = 200;  

  $a1 = ARRAY->create( name => "a1", 
  columns => $nx, 
  title => "hallo",
  rows => $ny) or die " failed to create a1 ";
  #
  # Fill the ARRAY GQE.
  #
  for( $x = 0; $x < $nx; $x++)
  {
  for( $y = 0; $y < $ny; $y++)
  {
  $a1->{data}[$x + $nx*$y] = $x*10;
  }
  if( ! ($x % 10))
  {
  print "\033[2;5f $x/$nx \n";
  }
  }
  #
  # the min and max have to be calculated
  #
  Gra_command <<EOF;
  calc a1 = a1 + 0
  EOF
  ;
  $a1->set( "ncolour" => "$nx", 
            "offset_colour" => "10",
            "scale" => "2");
  #
  # array reference in scalar context, return length (total())
  #
  #$length = @{$a1->{data}};

  display();