in reply to draw objects in circle
#!/usr/bin/perl use warnings; use strict; use Tk; use constant PI => 4 * atan2(1, 1); my ($center_x, $center_y) = (25, 25); my $radius = 20; my $object_count = 19; my $mw = 'MainWindow'->new(-title => 'Objects in circle'); $mw->Label(-text => 'Center')->grid(-row => $center_x, -column => $center_y, ); my @objects = map "Object $_", 1 .. $object_count; my $step = 2 * PI / (1 + $#objects); for my $i (0 .. $#objects) { my $angle = $i * $step; my $x = $center_x + $radius * cos $angle; my $y = $center_y + $radius * sin $angle; $mw->Label(-text => $objects[$i])->grid(-row => $y, -column => $x, ); } MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: draw objects in circle
by Hossein (Acolyte) on Aug 27, 2013 at 11:12 UTC |