From 8fe2e39e952457bd5d18148eee25d15e1e4322aa Mon Sep 17 00:00:00 2001 From: damien Date: Thu, 23 Aug 2001 11:58:47 +0000 Subject: corrected decimal number inperl with locale --- clock.pm | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/clock.pm b/clock.pm index 8237f6bd..4461c9d3 100755 --- a/clock.pm +++ b/clock.pm @@ -214,7 +214,7 @@ sub determine_radian { my $r; my $i=0; foreach (\$dRadians_hour, \$dRadians_min, \$dRadians_sec) { - my $d=sqrt ( ($x - ($midx + 0.70 * $radius * sin ($$_)))**2 + ($y - ($midy - 0.70 * $radius * cos ($$_)))**2 ); + 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++; } @@ -252,9 +252,9 @@ sub rad_to_time { sub time_to_rad { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = @_; - $dRadians_hour = $hour % 12 * $PI / 6.0; - $dRadians_min = $min * $PI / 30.0; - $dRadians_sec = $sec * $PI / 30.0; + $dRadians_hour = $hour % 12 * $PI / 6; + $dRadians_min = $min * $PI / 30; + $dRadians_sec = $sec * $PI / 30; $adj_h->set_value($hour); $adj_m->set_value($min); $adj_s->set_value($sec); @@ -264,7 +264,7 @@ sub Repaint { my ($drawing_area) = @_; my $dRadians_hour_real = POSIX::floor($dRadians_hour / $PI*6 ) * $PI/6.0 + $dRadians_min / 12; - my $dRadians_min_real = POSIX::floor($dRadians_min / $PI * 30 ) * $PI / 30.0; + 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, $drawing_area->allocation->[2], @@ -293,34 +293,34 @@ sub DrawSec { my ($pixmap, $gc, $midx, $midy, $dRadians, $dec) = @_; $pixmap->draw_line ($gc, $midx+$dec, $midy+$dec, - $midx+$dec + (0.80 * $radius * sin ($dRadians)), - $midy+$dec - (0.80 * $radius * cos ($dRadians))) + $midx+$dec + (8/10 * $radius * sin ($dRadians)), + $midy+$dec - (8/10 * $radius * cos ($dRadians))) } sub DrawMin { my ($pixmap, $gc, $midx, $midy, $dRadians, $dec) = @_; $pixmap->draw_polygon ($gc, 1, - $midx+$dec - 0.03 * $radius * sin ($dRadians), - $midy+$dec + 0.03 * $radius * cos ($dRadians), - $midx+$dec - 0.03 * $radius * sin ($dRadians+$PI/2), - $midy+$dec + 0.03 * $radius * cos ($dRadians+$PI/2), - $midx+$dec + 0.80 * $radius * sin ($dRadians), - $midy+$dec - 0.80 * $radius * cos ($dRadians), - $midx+$dec + 0.03 * $radius * sin ($dRadians+$PI/2), - $midy+$dec - 0.03 * $radius * cos ($dRadians+$PI/2)); + $midx+$dec - 3/100 * $radius * sin ($dRadians), + $midy+$dec + 3/100 * $radius * cos ($dRadians), + $midx+$dec - 3/100 * $radius * sin ($dRadians+$PI/2), + $midy+$dec + 3/100 * $radius * cos ($dRadians+$PI/2), + $midx+$dec + 8/10 * $radius * sin ($dRadians), + $midy+$dec - 8/10 * $radius * cos ($dRadians), + $midx+$dec + 3/100 * $radius * sin ($dRadians+$PI/2), + $midy+$dec - 3/100 * $radius * cos ($dRadians+$PI/2)); } sub DrawHour { my ($pixmap, $gc, $midx, $midy, $dRadians, $dec) = @_; $pixmap->draw_polygon ($gc, 1, - $midx+$dec - 0.05 * $radius * sin ($dRadians), - $midy+$dec + 0.05 * $radius * cos ($dRadians), - $midx+$dec - 0.05 * $radius * sin ($dRadians+$PI/2), - $midy+$dec + 0.05 * $radius * cos ($dRadians+$PI/2), - $midx+$dec + 0.70 * $radius * sin ($dRadians), - $midy+$dec - 0.70 * $radius * cos ($dRadians), - $midx+$dec + 0.05 * $radius * sin ($dRadians+$PI/2), - $midy+$dec - 0.05 * $radius * cos ($dRadians+$PI/2)); + $midx+$dec - 5/100 * $radius * sin ($dRadians), + $midy+$dec + 5/100 * $radius * cos ($dRadians), + $midx+$dec - 5/100 * $radius * sin ($dRadians+$PI/2), + $midy+$dec + 5/100 * $radius * cos ($dRadians+$PI/2), + $midx+$dec + 7/10 * $radius * sin ($dRadians), + $midy+$dec - 7/10 * $radius * cos ($dRadians), + $midx+$dec + 5/100 * $radius * sin ($dRadians+$PI/2), + $midy+$dec - 5/100 * $radius * cos ($dRadians+$PI/2)); } sub DrawTickAt { @@ -328,18 +328,18 @@ sub DrawTickAt { my $dRadians = $nHour * $PI / 6.0; $pixmap->draw_line ($_->[0], - $cx+$_->[1] + 0.90 * $radius * sin ($dRadians), - $cy+$_->[1] - 0.90 * $radius * cos ($dRadians), - $cx+$_->[1] + 1.0 * $radius * sin ($dRadians), - $cy+$_->[1] - 1.0 * $radius * cos ($dRadians)) + $cx+$_->[1] + 9/10 * $radius * sin ($dRadians), + $cy+$_->[1] - 9/10 * $radius * cos ($dRadians), + $cx+$_->[1] + 1 * $radius * sin ($dRadians), + $cy+$_->[1] - 1 * $radius * cos ($dRadians)) foreach ([$gray_gc, 5], [$black_gc, 0]); } sub DrawPointAt { my ($pixmap, $black_gc, $gray_gc, $nHour, $cx, $cy) = @_; - my $dRadians = $nHour * $PI / 30.0; + my $dRadians = $nHour * $PI / 30; $pixmap->draw_point ($black_gc, - $cx + 0.95 * $radius * sin ($dRadians), - $cy - 0.95 * $radius * cos ($dRadians)) + $cx + 95/100 * $radius * sin ($dRadians), + $cy - 95/100 * $radius * cos ($dRadians)) } -- cgit v1.2.1