diff options
-rwxr-xr-x | clock.pl | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -16,7 +16,6 @@ my $pixmap; my $radius; my ($dRadians_hour, $dRadians_min, $dRadians_sec); my $Radian; -my $type; my $timer; my ($midx, $midy); my $first = 1; @@ -176,7 +175,7 @@ sub motion_event { $pressed or return; if ($first) { Gtk2->timeout_remove($timer); - ($Radian, $type) = determine_radian($event->x, $event->y); + $Radian = determine_radian($event->x, $event->y); $button_reset->set_sensitive(1); } @@ -192,13 +191,12 @@ sub determine_radian { my $res; my $r; - my $i = 0; foreach (\$dRadians_hour, \$dRadians_min, \$dRadians_sec) { my $d = sqrt( ($x - ($midx + 7/10 * $radius * sin($$_)))**2 + ($y - ($midy - 7/10 * $radius * cos($$_)))**2); $res or $res = $d, $r = $_; - $d < $res and $res = $d, $r = $_, $i++; + $d < $res and $res = $d, $r = $_; } - ($r, $i); + $r; } sub expose_event { @@ -228,7 +226,7 @@ sub Repaint { my ($drawing_area, $update_time) = @_; time_to_rad(localtime(time())) if $update_time; my ($width, $height) = ($drawing_area->allocation->width, $drawing_area->allocation->height); - my $dRadians_hour_real = POSIX::floor($dRadians_hour / $PI*6) * $PI/6.0 + $dRadians_min / 12; + my $dRadians_hour_real = $dRadians_hour + $dRadians_min / 12; my $dRadians_min_real = POSIX::floor($dRadians_min / $PI * 30) * $PI / 30; my $dRadians_sec_real = $dRadians_sec; $pixmap->draw_rectangle($drawing_area->style->white_gc, 1, 0, 0, $width, $height); |