use warnings;
use strict;
use Tk;

# Zeichnet eine Folge von Kreisen entlang einer archimedischen 
# Spirale (Kreismittelpunkte sizen auf der Spirale)

my $PI =  atan2(1,1) * 4;         # Kreiszahl Pi
my $origin_x = 110;               # Mittelpunkt der Spirale (x)
my $origin_y = 70;                # Mittelpunkt der Spirale (y)
my $radius = 5;                   # Radius-Startwert
my $path_radius = 0;               # Startwert des Spiral-Radius
my ($path_x, $path_y, $angle);

# Das mw erzeugen
my $mw = MainWindow->new();
$mw->Label(-text => '     Test für Canvas     ')->pack();

my $canvas = $mw->Canvas(-background => 'blue',
                         -width      => 300, 
                         -height     => 240)->pack();

for ($angle = 0; $angle <= 180;
     $path_radius += 7, $radius += 3, $angle += 10)
  {
  # Koordinaten der Spirale: r.cos([theta]) and r.sin([theta])
  # sin() und cos() benötigen Angaben im Bogenmass: Grad * PI/90
  # Berechnung des Mittelpunktes des aktuellen Kreises:
  $path_x = $origin_x + $path_radius * cos ($angle * $PI / 90);
  $path_y = $origin_y - $path_radius * sin ($angle * $PI / 90);
  $canvas->create ('oval',
             $path_x - $radius,
             $path_y - $radius,
             $path_x + $radius,
             $path_y + $radius,
             -fill => 'red');
  }

MainLoop();