#!/usr/bin/perl -w
#3.14159265358979
use Tk;
my $MainWindow = MainWindow->new();
my $Canvas = $MainWindow->Canvas();
#$MainWindow->bind('<Configure>', \&Hallo);
$MainWindow->bind('<ButtonPress-1>', \&Hallo);
#$Canvas->createText(100,100,-tags => 'Text', -text => $text);
$Canvas->pack(-expand => 'yes', -fill => 'both');
MainLoop;
sub Hallo
{
$text = $Canvas->geometry();
$Canvas->delete(Text);
$Canvas->createText(100,100,-tags => 'Text', -text => $text);
$xm = 250;
$ym = 250;
$r = 30;
$Canvas->createOval($xm - $r,$ym - $r,$xm + $r,$ym + $r, -tags =>'A');
my $calc = sub {
my $i = shift;
$x1=(30+20)*cos($i)-20*cos((30+20)*$i/20);
$x2=(30+20)*cos($i+0.01)-20*cos((30+20)*($i+0.01)/20);
$y1=(30+20)*sin($i)-20*sin((30+20)*$i/20);
$y2=(30+20)*sin($i+0.01)-20*sin((30+20)*($i+0.01)/20);
$xP=50*cos($i);
$yP=50*sin($i);
$xm = 250 + $xP;
$ym = 250 + $yP;
$r = 20;
};
$calc->(0);
$Canvas->delete("B");
$Canvas->delete("radius");
my $oval = $Canvas->createOval($xm - $r,$ym - $r,$xm + $r,$ym + $r, -tags =>'B');
my $line1 = $Canvas->createLine($xm, $ym, $x2+250, $y2+250, -tags => 'radius');
my $line2 = $Canvas->createLine($x1+250, $y1+250, $x2+250, $y2+250, -tags => 'zykloid');
for($i=0; $i<=3.14159265358979*6; $i=$i+0.01)
{
$calc->($i);
$Canvas->coords($oval, $xm - $r,$ym - $r,$xm + $r,$ym + $r);
$Canvas->coords($line1, $xm, $ym, $x2+250, $y2+250);
$Canvas->coords($line2, $x1+250, $y1+250, $x2+250, $y2+250);
$MainWindow->update;
}
}