This example demonstrates how SCANs can be created by supplying
a list of value pairs. This is by far the fastest method because the
data is not transfered one by one. Instead the buffer is
passed to Spectra by a single call. Spectra is then cutting
it into records, which are delimited by \n. Each record
contains 2 numbers that are separated by blanks. The first of the
numbers is decoded as an x-value the second as the corresponding y-value.
The number of points of the newly created SCAN is just the number of records.
#!/usr/bin/perl -w
use Spectra;
use GQE;
use POSIX;
#
# delete everything
#
Spectra::delete();
#
# create the buffer
#
my $buffer = ' ' x 100000;
$buffer = "";
#
# fill the buffer with a list of value pairs, each record is
# terminated by '\n'
#
foreach my $i ( 1 .. 8192)
{
my $sin = POSIX::sin( $i/800);
$buffer .= "$i $sin\n";
}
$sin = SCAN->create( name => "Sinus",
title => "Sinus",
data_ptr => \$buffer) or die " Failed to create Sinus ";
#
$sin->set( "at" => "(1,2,2)");
#
# find window limits and display
#
Spectra::autoscale();
Spectra::display();
Spectra::keyw();