10 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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');
for($i=0; $i<=3.14159265358979*6; $i=$i+0.01)
{
$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;
$Canvas->delete(B);
$Canvas->delete(radius);
$Canvas->createOval($xm - $r,$ym - $r,$xm + $r,$ym + $r, -tags =>'B');
$Canvas->createLine($xm, $ym, $x2+250, $y2+250, -tags => 'radius');
$Canvas->createLine($x1+250, $y1+250, $x2+250, $y2+250, -tags => 'zykloid');
$MainWindow->update;
}
}
use constant Pi => 3.14159265358979;
*PI = \3.14159265358979;
*PI = sub () { 3.14159265358979 };
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/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;
}
}
perl -MTk -e '$c=tkinit->Canvas;$c->createLine( 0,0,1,1 ); $c->delete("all"); warn $c->createLine(0,0,1,1)'
1
2
3
4
5
$Canvas->delete('all');
zeichne_objektart1($_) for (0..$n1);
zeichne_objektart2($_) for (0..$n2);
zeichne_objektart3($_) for (0..$n3);
...
10 Einträge, 1 Seite |