Graph-Easy
view release on metacpan or search on metacpan
lib/Graph/Easy/As_ascii.pm view on Meta::CPAN
'cross' => '+',
'diamond' => '<>',
'x' => 'X',
},
},
{
filled =>
{
'star' => 'â
',
'square' => 'â ',
'dot' => '·',
'circle' => 'â',
'cross' => '+',
'diamond' => 'â',
'x' => 'â³',
},
closed =>
{
'star' => 'â',
'square' => 'â¡',
'dot' => '·',
'circle' => 'â',
'cross' => '+',
'diamond' => 'â',
'x' => 'â³',
},
}
];
sub _point_style
{
my ($self, $shape, $style) = @_;
return '' if $shape eq 'invisible';
if ($style =~ /^(star|square|dot|circle|cross|diamond)\z/)
{
# support the old "pointstyle: diamond" notion:
$shape = $style; $style = 'filled';
}
$style = 'filled' unless defined $style;
my $g = $self->{graph}->{_ascii_style} || 0;
$point_shapes->[$g]->{$style}->{$shape};
}
sub _border_style
{
my ($self, $style, $type) = @_;
# make a copy so that we can modify it
my $g = $self->{graph}->{_ascii_style} || 0;
my $s = [ @{ $border_styles->[ $g ]->{$style} } ];
die ("Unknown $type border style '$style'") if @$s == 0;
my $shape = 'rect';
$shape = $self->attribute('shape') unless $self->isa_cell();
return $s unless $shape eq 'rounded';
# if shape: rounded, overlay the rounded edge pieces
splice (@$s, 0, 4, @$rounded_edges)
if $style =~ /^(solid|dotted|dashed|dot-dash|dot-dot-dash)\z/;
# '####' => ' ### '
splice (@$s, 0, 4, (' ', ' ', ' ', ' '))
if $g == 0 || $style =~ /^(bold|wide|broad|double|double-dash|bold-dash)\z/;
$s;
}
#############################################################################
# different arrow styles and shapes in ASCII and boxart
my $arrow_form =
{
normal => 0,
sleek => 1, # slightly squashed
};
my $arrow_shapes =
{
triangle => 0,
diamond => 1,
box => 2,
dot => 3,
inv => 4, # an inverted triangle
line => 5,
cross => 6,
x => 7,
};
# todo: ⪠â«
my $arrow_styles =
[
[
# triangle
{
open => [ '>', '<', '^', 'v' ],
closed => [ '>', '<', '^', 'v' ],
filled => [ '>', '<', '^', 'v' ],
},
{
open => [ '>', '<', 'â§', 'â¨' ],
closed => [ 'â·', 'â', 'â³', 'â½' ],
filled => [ 'â¶', 'â', 'â²', 'â¼' ],
}
], [
# diamond
{
open => [ '>', '<', '^', 'v' ],
closed => [ '>', '<', '^', 'v' ],
filled => [ '>', '<', '^', 'v' ],
},
{
open => [ '>', '<', 'â§', 'â¨' ],
closed => [ 'â', 'â', 'â', 'â' ],
filled => [ 'â', 'â', 'â', 'â' ],
}
], [
( run in 3.058 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )