App-Music-PlayTab
view release on metacpan or search on metacpan
lib/App/Music/PlayTab/Output/PDF.pm view on Meta::CPAN
}
elsif ( ref($chord) eq 'ARRAY' ) {
my $fun = "render__" . shift(@$chord);
$self->$fun( @$chord );
}
else {
my $fun = "render__$chord";
$self->$fun;
}
while ( $dup-- > 1 ) {
$self->render__space;
}
}
sub newline {
my ( $self, $xtra ) = @_;
$x = $ps->{marginleft};
$y += $yd;
$y += ($xtra-1)*$yd if defined $xtra;
}
sub text {
my ( $self, $text, $xxmd, $font ) = @_;
$font ||= $ps->{fonts}->{subtitle};
$xxmd ||= 0;
$self->checkvspace;
$pr->text( $x + $xxmd, $y, $text, $font );
}
sub postfix {
my ( $self, $text ) = @_;
$x += 4;
$self->text( $text, $md );
}
use constant GRIDSTEP => 8;
use constant GRIDSPACE => 10;
sub grids {
my ( $self, $grids ) = @_;
my $n = int( ( 570 - $md - 45 ) / ( GRIDSPACE * GRIDSTEP ) );
my $i = 0;
foreach my $ch ( @$grids ) {
$self->render_grid($ch);
if ( ++$i >= $n ) {
$self->newline(4);
$i = 0;
}
else {
$x += GRIDSPACE * GRIDSTEP;
}
}
$self->newline(3);
}
################ Other Render Functions ################
use constant MS_REST => "\x{002b}";
use constant MS_REPT => "\x{0024}";
sub render__again {
my ( $self ) = @_;
$self->chord( $self->{_prev_chord} );
}
sub render__space {
my ( $self ) = @_;
$x += $xd;
}
sub render__rest {
my $self = shift;
$pr->msym( $x + $md, $y, MS_REST, 20 );
$x += $xd;
}
sub render__same {
# Whole bar(s) repeat.
my ( $self, $wh, $xs ) = @_;
# Currently, $wh will always be 1 (single bar repeat).
$pr->ctext( $x + $md + ($xs * $xd) / 2, $y + 3, MS_REPT, $f_msyms, 25 );
$x += $xs * $xd;
}
sub render__hmore {
$x += 4;
}
sub render__hless {
$x -= 4;
}
sub render_grid {
my ( $self, $grid ) = @_;
my @c = @$grid;
my $chord = shift(@c);
my $save_x = $x;
my $save_y = $y;
$y += 0;
$x += 28;
if ( $chord =~ /::/ ) {
$x -= $chord->width($self) / 2;
$chord->render;
}
else {
$pr->ctext( $x, $y, $chord, $f_chord );
}
$x = $save_x;
$y = $save_y;
# Fretboard.
my $c = shift(@c);
$pr->fretboard( $x + $md + 8, $y - 5,
5 * GRIDSTEP, 4 * GRIDSTEP,
$c, \@c );
}
################ Page managemant ################
( run in 0.622 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )