Imagerで破線を表現する
昨日描いたグラフで破線が使いたくなったので、
目盛の一部を破線に変更してみた。
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 | sub draw_graduation { my ( $img , $color ) = @_ ; $img ->box( filled => 1, color => 'black' ); for ( 0..6 ) { my $x = $x0 + ((( $graph_width - 1) / 5) * $_ ); $img ->line( x1 => $x , y1 => $y0 , x2 => $x , y2 => $y0 - (( $graph_height - 1) * 1.2), color => $color ); } for ( 0..12 ) { my $y = $y0 - ((SCALE_Y / 10) * $_ ); my $x_end = $x0 + $graph_width - 1; if ( $_ % 5 ) { my $stroke = 3; my $space = 3; my ( $x1 , $x2 ) = ( $x0 , $x0 + $stroke ); while ( $x2 <= $x_end ) { $img ->line( x1 => $x1 , y1 => $y , x2 => $x2 - 1, y2 => $y , color => $color ); $x1 = $x2 + $space ; $x2 = $x1 + $stroke ; } if ( $x1 < $x_end ) { $img ->line( x1 => $x1 , y1 => $y , x2 => $x_end , y2 => $y , color => $color ); } } else { $img ->line( x1 => $x0 , y1 => $y , x2 => $x_end , y2 => $y , color => $color ); } } } |
一番下の関数を修正して、y軸の0.0と0.5と1.0を強調してみた。
どうせだったら、色も明るくした方が良かったかなって思う。
おしまい。
Leave a Comment