Music::Image::Chord - Perl extension for generating guitar tab chords
use Music::Image::Chord; $image = new Music::Image::Chord(); $old_font = $image->font('/path/to/my/TrueType/font.ttf'); $old_file = $image->file('/path/to/file/to/save.png'); $image->draw(name => 'D'); # Write the actual file.
Image::Chord is a simple package for creating images of guitar chords in any format that the Imager module can produce.
The object's API is as follows:
- new Image::Chord()
Creates and returns a new Image::Chord object.
Returns and optionally sets the thickness of the fret bar. Only used if on the first fret (which is the default).
Returns and optionally sets the image boundaries. It accepts several formats:
$image->bounds($width, $height); $image->bounds(width=>$wid, height=>$hgt); $image->bounds(xmin=>$xmin, xmax=>$xmax, yMIN=>$ymin, YMax=>$ymax);
Returns and optionally sets the width/height of the crop marks on the image. If this value is not set or is <= 0, then crop marks will not be drawn.
$image->crop_width(5); # Crop marks will be 5 pixels wide. print $image->crop_width(); # Display the current crop mark width.
Returns and optionally sets the Imager debugging flag.
$image->debug(1); # Set debugging print $image->debug(); # Get the current debugging value
Returns and optionally sets the font used to render the chord's title.
$image->font('/home/jgoff/Bach.ttf'); # Display in the Bach TrueType font $foo = $image->font(); # Assign $foo to the image's font
Returns and optionally sets the file name to save the rendered image to. It also reads the extension of the file to determine how to save the image.
Returns and optionally sets the beginning fret in the image. Defaults to 1.
$image->fret(5); print $image->fret(); # prints the current fret setting.
- draw([optional named parameters])
Renders the chord described into the appropriate file. Optional named parameters are:
name - The name of the chord fret - Beginning fret barres - Chord barres, not implemented yet. chord - If the chord isn't represented in the list, describe it like 'xx0232'.
$image->draw( name => 'D' ); # Draw a D chord
Returns and optionally sets the grid coordinates. X and Y are the UL corner of the grid, and w and h control (for the moment, this will change) the inter-string and inter-fret spacing.
$image->grid($x,$y,$w,$h); # Set explicitly $image->grid(x=>$x,y=>$y,w=>$w,h=>$h); # Set through named parameters.
Jeffrey Goff, <firstname.lastname@example.org<gt> Inspiration by #perl
Copyright (C) 2003 by Jeffrey Goff
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.