Tk-LCD
view release on metacpan or search on metacpan
$Tk::LCD::VERSION = '1.3';
package Tk::LCD;
use base qw/Tk::Derived Tk::Canvas/;
use vars qw/$ELW %SHAPE %shape %LLCD %ULCD/;
use subs qw/ldifference/;
use strict;
Construct Tk::Widget 'LCD';
# LCD class data.
$ELW = 22; # element pixel width
# %SHAPE stolen with appreciation from Donal K. Fellows' Tcl game
# of Maze. An LCD element can display a digit, space or minus sign.
# It's made up of 7 segments labelled 'a' through 'g'. Each segment
# is defined by a series of Canvas widget polygon coordinates.
#
# b
# -
# a| |c
# - <--- g
# f| |d
# -
# e
%SHAPE = (
'a' => [qw/ 3.0 5 5.2 3 7.0 5 6.0 15 3.8 17 2.0 15/],
'b' => [qw/ 6.3 2 8.5 0 18.5 0 20.3 2 18.1 4 8.1 4/],
'c' => [qw/19.0 5 21.2 3 23.0 5 22.0 15 19.8 17 18.0 15/],
'd' => [qw/17.4 21 19.6 19 21.4 21 20.4 31 18.2 33 16.4 31/],
'e' => [qw/ 3.1 34 5.3 32 15.3 32 17.1 34 14.9 36 4.9 36/],
'f' => [qw/ 1.4 21 3.6 19 5.4 21 4.4 31 2.2 33 0.4 31/],
'g' => [qw/ 4.7 18 6.9 16 16.9 16 18.7 18 16.5 20 6.5 20/],
);
# %shape is 1/2 the size of %SHAPE.
foreach my $c (keys %SHAPE) {
$shape{$c} = [ map {$_ / 2.0} @{$SHAPE{$c}} ];
}
# To display an LCD element we must turn on and off certain segments.
# %LLCD defines a list of segments to turn on for any particular
# symbol.
%LLCD = (
'0' => [qw/a b c d e f/],
'1' => [qw/c d/],
'2' => [qw/b c e f g/],
'3' => [qw/b c d e g/],
'4' => [qw/a c d g/],
'5' => [qw/a b d e g/],
'6' => [qw/a b d e f g/],
'7' => [qw/b c d/],
'8' => [qw/a b c d e f g/],
'9' => [qw/a b c d e g/],
'-' => [qw/g/],
' ' => [''],
);
# Similarly, %ULCD defines a list of LCD element segments to turn off
# for any particular symbol. In Maze, %ULCD was manually generated,
( run in 0.837 second using v1.01-cache-2.11-cpan-a1f116cd669 )