Template-GD-2.66/0000755000175000017500000000000010370657177013073 5ustar abwabw00000000000000Template-GD-2.66/t/0000755000175000017500000000000010370657177013336 5ustar abwabw00000000000000Template-GD-2.66/t/gd.t0000644000175000017500000001062210370655773014116 0ustar abwabw00000000000000#============================================================= -*-perl-*- # # t/gd.t # # Test the GD plugin. Tests are based on the GD module tests. # # Written by Craig Barratt # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id: gd.t 6 2006-02-03 13:40:35Z abw $ # #======================================================================== use strict; use lib qw( ../lib ); use Template; use Template::Test; $^W = 1; eval "use GD;"; if ( $@ || $GD::VERSION < 1.20 ) { skip_all('GD module(s) not installed'); } test_expect(\*DATA, { FILTERS => { hex => \&hex_filter, } }); # # write text out in hex format. # sub hex_filter { my $text = shift; $text =~ s/(.)/sprintf("%02x", ord($1))/esg; $text =~ s/(.{70})/$1\n/g; return $text; } __END__ -- test -- [% FILTER replace('.'); # # This is test2 from GD-1.xx/t/GD.t # USE gd_c = GD.Constants; USE im = GD.Image(300,300); white = im.colorAllocate(255, 255, 255); black = im.colorAllocate(0, 0, 0); red = im.colorAllocate(255, 0, 0); blue = im.colorAllocate(0,0,255); yellow = im.colorAllocate(255,250,205); USE brush = GD.Image(10,10); brush.colorAllocate(255,255,255); # white brush.colorAllocate(0,0,0); # black brush.transparent(white); # white is transparent brush.filledRectangle(0,0,5,2,black); # a black rectangle im.setBrush(brush); im.arc(100,100,100,150,0,360,gd_c.gdBrushed); USE poly = GD::Polygon; poly.addPt(30,30); poly.addPt(100,10); poly.addPt(190,290); poly.addPt(30,290); im.polygon(poly,gd_c.gdBrushed); im.fill(132,62,blue); im.fill(100,70,red); im.fill(40,40,yellow); im.interlaced(1); im.copy(im,150,150,20,20,50,50); im.copyResized(im,10,200,20,20,100,100,50,50); END; out = im.png | hex; out.length > 6000 ? 'ok' : 'not ok' -%] -- expect -- ok -- test -- [% FILTER replace('.'); # # This is test3 from GD-1.xx/t/GD.t # USE im = GD.Image(100,50); black = im.colorAllocate(0, 0, 0); white = im.colorAllocate(255, 255, 255); red = im.colorAllocate(255, 0, 0); blue = im.colorAllocate(0,0,255); im.arc(50, 25, 98, 48, 0, 360, white); im.fill(50, 21, red); END; out = im.png | hex; out.length > 500 ? 'ok' : 'not ok' -%] -- expect -- ok -- test -- [% FILTER replace('.'); # # This is test4 from GD-1.xx/t/GD.t # USE im = GD.Image(225,180); black = im.colorAllocate(0, 0, 0); white = im.colorAllocate(255, 255, 255); red = im.colorAllocate(255, 0, 0); blue = im.colorAllocate(0,0,255); yellow = im.colorAllocate(255,250,205); USE poly = GD.Polygon; poly.addPt(0,50); poly.addPt(25,25); poly.addPt(50,50); im.filledPolygon(poly,blue); poly.offset(100,100); im.filledPolygon(poly,red); poly.map(50,50,100,100,10,10,110,60); im.filledPolygon(poly,yellow); b = poly.bounds; b0 = b.0; b1 = b.1; b2 = b.2; b3 = b.3; poly.map(b0,b1,b2,b3,50,20,80,160); im.filledPolygon(poly,white); END; out = im.png | hex; out.length > 1250 ? "ok" : "not ok" -%] -- expect -- ok -- test -- [% FILTER replace('.'); # # This is test5 from GD-1.xx/t/GD.t # USE gd_c = GD.Constants; USE im = GD.Image(300,300); white = im.colorAllocate(255, 255, 255); black = im.colorAllocate(0, 0, 0); red = im.colorAllocate(255, 0, 0); blue = im.colorAllocate(0,0,255); yellow = im.colorAllocate(255,250,205); im.transparent(white); im.interlaced(1); USE brush = GD.Image(10,10); brush.colorAllocate(255,255,255); brush.colorAllocate(0,0,0); brush.transparent(white); brush.filledRectangle(0,0,5,2,black); im.string(gd_c.gdLargeFont,150,10,"Hello world!",red); im.string(gd_c.gdSmallFont,150,28,"Goodbye cruel world!",blue); im.stringUp(gd_c.gdTinyFont,280,250,"I'm climbing the wall!",black); im.charUp(gd_c.gdMediumBoldFont,280,280,"Q",black); im.setBrush(brush); im.arc(100,100,100,150,0,360,gd_c.gdBrushed); USE poly = GD.Polygon; poly.addPt(30,30); poly.addPt(100,10); poly.addPt(190,290); poly.addPt(30,290); im.polygon(poly,gd_c.gdBrushed); im.fill(132,62,blue); im.fill(100,70,red); im.fill(40,40,yellow); END; out = im.png | hex; out.length > 6500 ? 'ok' : 'not ok' -%] -- expect -- ok Template-GD-2.66/t/gdgraph.t0000644000175000017500000001746210370655773015151 0ustar abwabw00000000000000#============================================================= -*-perl-*- # # t/gdgraph.t # # Test the GD::Graph::* plugins. The GD::Graph::* modules don't # come with any tests, so we simply verify that each graph type # produces a PNG output file, but we don't verify the contents. # # Written by Craig Barratt # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id: gdgraph.t 6 2006-02-03 13:40:35Z abw $ # #======================================================================== use strict; use lib qw( ../lib ); use Template; use Template::Test; $^W = 1; eval "use GD; use GD::Graph;"; if ( $@ || $GD::VERSION < 1.20 ) { skip_all('GD module(s) not installed'); } test_expect(\*DATA, { FILTERS => { head2hex => [\&head2hex_filter_factory, 1], } }); # # Grab just the first $len bytes of the input, and optionally convert # to a hex string if $hex is set # sub head2hex_filter_factory { my($context, $len, $hex) = @_; return sub { my $text = shift; return $text if length $text < $len; $text = substr($text, 0, $len); $text =~ s/(.)/sprintf("%02x", ord($1))/eg if ( $hex ); return $text; } } __END__ -- test -- [% USE g = GD.Graph.lines(300,200); x = [1, 2, 3, 4]; y = [5, 4, 2, 3]; r = g.set(x_label => 'X Label', y_label => 'Y label', title => 'Title'); g.plot([x, y]).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4], ]; USE my_graph = GD.Graph.bars(); r = my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Simple Bar Chart', y_max_value => 8, y_tick_number => 8, y_label_skip => 2, # shadows bar_spacing => 8, shadow_depth => 4, shadowclr => 'dred', transparent => 0, ); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4], ]; USE my_graph = GD.Graph.bars(); r = my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'Two data sets', # shadows bar_spacing => 8, shadow_depth => 4, shadowclr => 'dred', long_ticks => 1, y_max_value => 40, y_tick_number => 8, y_label_skip => 2, bar_spacing => 3, accent_treshold => 200, transparent => 0, ); r = my_graph.set_legend( 'Data set 1', 'Data set 2' ); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [50, 52, 53, 54, 55, 56, 57, 58, 59], [60, 61, 61, 63, 68, 66, 65, 61, 58], [70, 72, 71, 74, 78, 73, 75, 71, 68], ]; USE my_graph = GD.Graph.linespoints; r = my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Lines and Points Graph', y_max_value => 80, y_tick_number => 6, y_label_skip => 2, y_long_ticks => 1, x_tick_length => 2, markers => [ 1, 5 ], skip_undef => 1, transparent => 0, ); r = my_graph.set_legend('data set 1', 'data set 2', 'data set 3'); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 1, 2, 5, 6, 3, 1.5, -1, -3, -4], [ -4, -3, 1, 1, -3, -1.5, -2, -1, 0], [ 9, 8, 9, 8.4, 7.1, 7.5, 8, 3, -3], [ 0.1, 0.2, 0.5, 0.4, 0.3, 0.5, 0.1, 0, 0.4], [ -0.1, 2, 5, 4, -3, 2.5, 3.2, 4, -4], ]; USE my_graph = GD.Graph.mixed(); r = my_graph.set( types => ['lines', 'lines', 'points', 'area', 'linespoints'], default_type => 'points', ); r = my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Mixed Type Graph', y_max_value => 10, y_min_value => -5, y_tick_number => 3, y_label_skip => 0, x_plot_values => 0, y_plot_values => 0, long_ticks => 1, x_ticks => 0, legend_marker_width => 24, line_width => 3, marker_size => 5, bar_spacing => 8, transparent => 0, ); r = my_graph.set_legend('one', 'two', 'three', 'four', 'five', 'six'); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th"], [ 4, 2, 3, 4, 3, 3.5] ]; USE my_graph = GD.Graph.pie( 250, 200 ); r = my_graph.set( title => 'A Pie Chart', label => 'Label', axislabelclr => 'black', pie_height => 36, transparent => 0, ); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], [ -1, -2, -5, -6, -3, 1.5, 1, 1.3, 2] ]; USE my_graph = GD.Graph.area(); r = my_graph.set( two_axes => 1, zero_axis => 1, transparent => 0, ); r = my_graph.set_legend('left axis', 'right axis' ); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], [ 1, 2, 5, 6, 3, 1.5, 2, 3, 4], ]; USE my_graph = GD.Graph.points(); r = my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Points Graph', y_max_value => 40, y_tick_number => 8, y_label_skip => 2, legend_placement => 'RC', long_ticks => 1, marker_size => 6, markers => [ 1, 7, 5 ], transparent => 0, ); r = my_graph.set_legend('one', 'two'); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ], [-5, -4, -3, -3, -1, 0, 2, 1, 3, 4, 6, 7], [4, 3, 5, 6, 3,1.5, -1, -3, -4, -6, -7, -8], [1, 2, 2, 3, 4, 3, 1, -1, 0, 2, 3, 2], ]; USE my_graph = GD.Graph.lines(); r = my_graph.set( x_label => 'Month', y_label => 'Measure of success', title => 'A Simple Line Graph', y_max_value => 8, y_min_value => -8, y_tick_number => 16, y_label_skip => 2, box_axis => 0, line_width => 3, zero_axis_only => 1, x_label_position => 1, y_label_position => 1, x_label_skip => 3, x_tick_offset => 2, transparent => 0, ); r = my_graph.set_legend("Us", "Them", "Others"); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 Template-GD-2.66/t/gdgraph3d.t0000644000175000017500000000665110370655773015376 0ustar abwabw00000000000000#============================================================= -*-perl-*- # # t/gdgraph3d.t # # Test the GD::Graph::*3d plugins. The GD::Graph3d module doesn't # come with any tests, so we simply verify that each graph type # produces a PNG output file, but we don't verify the contents. # # Written by Craig Barratt # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id: gdgraph3d.t 6 2006-02-03 13:40:35Z abw $ # #======================================================================== use strict; use lib qw( ../lib ); use Template; use Template::Test; $^W = 1; eval "use GD; use GD::Graph; use GD::Graph::bars3d;"; if ( $@ || $GD::VERSION < 1.20 ) { skip_all('GD module(s) not installed'); } test_expect(\*DATA, { FILTERS => { head2hex => [\&head2hex_filter_factory, 1], } }); # # Grab just the first $len bytes of the input, and optionally convert # to a hex string if $hex is set # sub head2hex_filter_factory { my($context, $len, $hex) = @_; return sub { my $text = shift; return $text if length $text < $len; $text = substr($text, 0, $len); $text =~ s/(.)/sprintf("%02x", ord($1))/eg if ( $hex ); return $text; } } __END__ -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4], ]; USE my_graph = GD::Graph::bars3d(); r = my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A 3d Bar Chart', y_max_value => 8, y_tick_number => 8, y_label_skip => 2, # shadows bar_spacing => 8, shadow_depth => 4, shadowclr => 'dred', transparent => 0, ); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ], [-5, -4, -3, -3, -1, 0, 2, 1, 3, 4, 6, 7], [4, 3, 5, 6, 3,1.5, -1, -3, -4, -6, -7, -8], [1, 2, 2, 3, 4, 3, 1, -1, 0, 2, 3, 2], ]; USE my_graph = GD::Graph::lines3d(); r = my_graph.set( x_label => 'Month', y_label => 'Measure of success', title => 'A 3d Line Graph', y_max_value => 8, y_min_value => -8, y_tick_number => 16, y_label_skip => 2, box_axis => 0, line_width => 3, zero_axis_only => 1, x_label_position => 1, y_label_position => 1, x_label_skip => 3, x_tick_offset => 2, transparent => 0, ); r = my_graph.set_legend("Us", "Them", "Others"); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 -- test -- [% data = [ ["1st","2nd","3rd","4th","5th","6th"], [ 4, 2, 3, 4, 3, 3.5] ]; USE my_graph = GD::Graph::pie( 250, 200 ); r = my_graph.set( title => 'A Pie Chart', label => 'Label', axislabelclr => 'black', pie_height => 36, transparent => 0, ); my_graph.plot(data).png | head2hex(4, 1); %] -- expect -- 89504e47 Template-GD-2.66/t/gdtext.t0000644000175000017500000000254510370655773015030 0ustar abwabw00000000000000#============================================================= -*-perl-*- # # t/gdtext.t # # Test the GD::Text plugin. Tests are based on the GD::Text module tests. # # Written by Craig Barratt # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id: gdtext.t 6 2006-02-03 13:40:35Z abw $ # #======================================================================== use strict; use lib qw( ../lib ); use Template; use Template::Test; $^W = 1; eval "use GD; use GD::Text;"; if ( $@ || $GD::VERSION < 1.20 ) { skip_all('GD module(s) not installed'); } test_expect(\*DATA); __END__ -- test -- [% USE gd_c = GD.Constants; USE t = GD.Text; x = t.set_text('Some text'); r = t.get('width', 'height', 'char_up', 'char_down'); r.join(":"); "\n"; x = t.set_text('Some other text'); r.0 = t.get('width'); r.join(":"); "\n"; x = t.set_font(gd_c.gdGiantFont); t.is_builtin; "\n"; t.width('Foobar Banana'); "\n"; t.get('text'); "\n"; r = t.get('width', 'height', 'char_up', 'char_down'); r.join(":"); "\n"; -%] -- expect -- 54:13:13:0 90:13:13:0 1 117 Some other text 135:15:15:0 -- test -- [% USE gd_c = GD.Constants; USE t = GD.Text(text => 'FooBar Banana', font => gd_c.gdGiantFont); t.get('width'); "\n"; -%] -- expect -- 117 Template-GD-2.66/t/gdtextwrap.t0000644000175000017500000000327510370655773015723 0ustar abwabw00000000000000#============================================================= -*-perl-*- # # t/gdtextwrap.t # # Test the GD::Text::Wrap plugin. Tests are based on the GD::Text # module tests. # # Written by Craig Barratt # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id: gdtextwrap.t 6 2006-02-03 13:40:35Z abw $ # #======================================================================== use strict; use lib qw( ../lib ); use Template; use Template::Test; $^W = 1; eval "use GD; use GD::Text::Wrap;"; if ( $@ || $GD::VERSION < 1.20 ) { skip_all('GD module(s) not installed'); } test_expect(\*DATA); __END__ -- test -- [% text = BLOCK -%] Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. [% END %][% USE gd_c = GD.Constants; USE gd = GD.Image(170,150); x = gd.colorAllocate(255,255,255); x = gd.colorAllocate( 0, 0, 0); USE wp = GD.Text.Wrap(gd, text => text); x = wp.set(align => 'left', width => 130); wp.get_bounds(20,10).join(":"); "\n"; x = wp.set(align => 'justified'); wp.get_bounds(20,10).join(":"); "\n"; # Draw, and check that the result is the same wp.draw(20,10).join(":"); "\n"; x = wp.set(align => 'left'); wp.draw(20,10).join(":"); "\n"; x = wp.set(align => 'justified'); wp.draw(20,10).join(":"); "\n"; x = wp.set(align => 'right'); wp.draw(20,10).join(":"); "\n"; x = wp.set(preserve_nl => 1); wp.draw(20,10).join(":"); "\n"; -%] -- expect -- 20:10:150:128 20:10:150:128 20:10:150:128 20:10:150:128 20:10:150:128 20:10:150:128 20:10:150:143 Template-GD-2.66/t/gdtextalign.t0000644000175000017500000000372510370655773016044 0ustar abwabw00000000000000#============================================================= -*-perl-*- # # t/gdtextalign.t # # Test the GD::Text::Align plugin. Tests are based on the GD::Text # module tests. # # Written by Craig Barratt # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id: gdtextalign.t 6 2006-02-03 13:40:35Z abw $ # #======================================================================== use strict; use lib qw( ../lib ); use Template; use Template::Test; $^W = 1; eval "use GD; use GD::Text::Align;"; if ( $@ || $GD::VERSION < 1.20 ) { skip_all('GD module(s) not installed'); } test_expect(\*DATA); __END__ -- test -- [% USE gd_c = GD.Constants; USE gd = GD.Image(200,200); x = gd.colorAllocate(255,255,255); x = gd.colorAllocate(0,0,0); USE t = GD.Text.Align(gd); x = t.set_text('A string'); t.get('width', 'height', 'char_up', 'char_down').join(":"); "\n"; x = t.set_align('top', 'left'); x = t.draw(100,10); t.get('x', 'y').join(":"); "\n"; x = t.set_align('center', 'right'); x = t.draw(100,10); t.get('x', 'y').join(":"); "\n"; x = t.set_align('bottom','center'); x = t.draw(100,20); t.get('x', 'y').join(":"); "\n"; x = t.set_font(gd_c.gdGiantFont); x = t.set_align('bottom', 'right'); x = t.draw(100,40); t.get('x', 'y').join(":"); "\n"; x = t.set_align('bottom', 'left'); t.bounding_box(100,100).join(":"); "\n"; -%] -- expect -- 48:13:13:0 100:10 52:3.5 76:7 28:25 100:100:172:100:172:85:100:85 -- test -- [% USE gd_c = GD.Constants; USE gd = GD.Image(200,200); x = gd.colorAllocate(255,255,255); x = gd.colorAllocate(0,0,0); USE t = GD.Text.Align(gd, valign => 'top', halign => 'left', text => 'Banana Boat', colour => 1, font => gd_c.gdGiantFont, ); t.draw(10,10).join(":"); "\n"; %] -- expect -- 10:25:109:25:109:10:10:10 Template-GD-2.66/lib/0000755000175000017500000000000010370657177013641 5ustar abwabw00000000000000Template-GD-2.66/lib/Template/0000755000175000017500000000000010370657177015414 5ustar abwabw00000000000000Template-GD-2.66/lib/Template/Plugin/0000755000175000017500000000000010370657177016652 5ustar abwabw00000000000000Template-GD-2.66/lib/Template/Plugin/GD/0000755000175000017500000000000010370657177017144 5ustar abwabw00000000000000Template-GD-2.66/lib/Template/Plugin/GD/Text/0000755000175000017500000000000010370657177020070 5ustar abwabw00000000000000Template-GD-2.66/lib/Template/Plugin/GD/Text/Wrap.pm0000644000175000017500000000742610370657115021340 0ustar abwabw00000000000000package Template::Plugin::GD::Text::Wrap; use strict; use warnings; use base qw( GD::Text::Wrap Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; my $gd = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); return $class->SUPER::new($gd, @_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } 1; __END__ =head1 NAME Template::Plugin::GD::Text::Wrap - Break and wrap strings in GD images =head1 SYNOPSIS [% USE align = GD.Text.Wrap(gd_image); %] =head1 EXAMPLES [% FILTER null; USE gd = GD.Image(200,400); USE gdc = GD.Constants; black = gd.colorAllocate(0, 0, 0); green = gd.colorAllocate(0, 255, 0); txt = "This is some long text. " | repeat(10); USE wrapbox = GD.Text.Wrap(gd, line_space => 4, color => green, text => txt, ); wrapbox.set_font(gdc.gdMediumBoldFont); wrapbox.set(align => 'center', width => 160); wrapbox.draw(20, 20); gd.png | stdout(1); END; -%] [% txt = BLOCK -%] Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. [% END -%] [% FILTER null; # # This example follows the example in GD::Text::Wrap, except # we create a second image that is a copy just enough of the # first image to hold the final text, plus a border. # USE gd = GD.Image(400,400); USE gdc = GD.Constants; green = gd.colorAllocate(0, 255, 0); blue = gd.colorAllocate(0, 0, 255); USE wrapbox = GD.Text.Wrap(gd, line_space => 4, color => green, text => txt, ); wrapbox.set_font(gdc.gdMediumBoldFont); wrapbox.set(align => 'center', width => 140); rect = wrapbox.get_bounds(5, 5); x0 = rect.0; y0 = rect.1; x1 = rect.2 + 9; y1 = rect.3 + 9; gd.filledRectangle(0, 0, x1, y1, blue); gd.rectangle(0, 0, x1, y1, green); wrapbox.draw(x0, y0); nx = x1 + 1; ny = y1 + 1; USE gd2 = GD.Image(nx, ny); gd2.copy(gd, 0, 0, 0, 0, x1, y1); gd2.png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Text.Wrap plugin provides an interface to the GD::Text::Wrap module. It allows multiples line of text to be drawn in GD images with various wrapping and alignment. See L for more details. See L for a plugin that allow you to draw text with various alignment and orientation. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it and Martien Verbruggen wrote the GD::Text module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. These modules are looking for a new maintainer. Please contact Andy Wardley if you are willing to help out. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Text is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Text/Align.pm0000644000175000017500000000513710370657110021451 0ustar abwabw00000000000000package Template::Plugin::GD::Text::Align; use strict; use warnings; use base qw( GD::Text::Align Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; my $gd = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); return $class->SUPER::new($gd, @_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } 1; __END__ =head1 NAME Template::Plugin::GD::Text::Align - Draw aligned strings in GD images =head1 SYNOPSIS [% USE align = GD.Text.Align(gd_image); %] =head1 EXAMPLES [% FILTER null; USE im = GD.Image(100,100); USE gdc = GD.Constants; # allocate some colors black = im.colorAllocate(0, 0, 0); red = im.colorAllocate(255,0, 0); blue = im.colorAllocate(0, 0, 255); # Draw a blue oval im.arc(50,50,95,75,0,360,blue); USE a = GD.Text.Align(im); a.set_font(gdc.gdLargeFont); a.set_text("Hello"); a.set(colour => red, halign => "center"); a.draw(50,70,0); # Output image in PNG format im.png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Text.Align plugin provides an interface to the GD::Text::Align module. It allows text to be drawn in GD images with various alignments and orientations. See L for more details. See L for a plugin that allow you to render wrapped text in GD images. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it and Martien Verbruggen wrote the GD::Text module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. These modules are looking for a new maintainer. Please contact Andy Wardley if you are willing to help out. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Text is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/0000755000175000017500000000000010370657177020205 5ustar abwabw00000000000000Template-GD-2.66/lib/Template/Plugin/GD/Graph/points.pm0000644000175000017500000000600010370657066022050 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::points; use strict; use warnings; use base qw( GD::Graph::points Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::points - Create point graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.points(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], [ 1, 2, 5, 6, 3, 1.5, 2, 3, 4], ]; USE my_graph = GD.Graph.points(); my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Points Graph', y_max_value => 40, y_tick_number => 8, y_label_skip => 2, legend_placement => 'RC', long_ticks => 1, marker_size => 6, markers => [ 1, 7, 5 ], transparent => 0, ); my_graph.set_legend('one', 'two'); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.points plugin provides an interface to the GD::Graph::points class defined by the GD::Graph module. It allows one or more (x,y) data sets to be plotted as points, in addition to axes and legends. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/lines3d.pm0000644000175000017500000000657410370657026022111 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::lines3d; use strict; use warnings; use base qw( GD::Graph::lines3d Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::lines3d - Create 3D line graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.lines3d(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ], [-5, -4, -3, -3, -1, 0, 2, 1, 3, 4, 6, 7], [4, 3, 5, 6, 3,1.5, -1, -3, -4, -6, -7, -8], [1, 2, 2, 3, 4, 3, 1, -1, 0, 2, 3, 2], ]; USE my_graph = GD.Graph.lines3d(); my_graph.set( x_label => 'Month', y_label => 'Measure of success', title => 'A 3d Line Graph', y_max_value => 8, y_min_value => -8, y_tick_number => 16, y_label_skip => 2, box_axis => 0, line_width => 3, zero_axis_only => 1, x_label_position => 1, y_label_position => 1, x_label_skip => 3, x_tick_offset => 2, transparent => 0, ); my_graph.set_legend("Us", "Them", "Others"); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.lines3d plugin provides an interface to the GD::Graph::lines3d class defined by the GD::Graph3d module. It allows one or more (x,y) data sets to be plotted as y versus x lines with a 3-dimensional appearance, together with axes and legends. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph3d is copyright (C) 1999,2000 Wadsack-Allen. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/pie3d.pm0000644000175000017500000000544510370657053021550 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::pie3d; use strict; use warnings; use base qw( GD::Graph::pie3d Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::pie3d - Create 3D pie charts with legends =head1 SYNOPSIS [% USE g = GD.Graph.pie3d(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th"], [ 4, 2, 3, 4, 3, 3.5] ]; USE my_graph = GD.Graph.pie3d( 250, 200 ); my_graph.set( title => 'A Pie Chart', label => 'Label', axislabelclr => 'black', pie_height => 36, transparent => 0, ); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.pie3d plugin provides an interface to the GD::Graph::pie3d class defined by the GD::Graph module. It allows an (x,y) data set to be plotted as a 3d pie chart. The x values are typically strings. Note that GD::Graph::pie already produces a 3d effect, so GD::Graph::pie3d is just a wrapper around GD::Graph::pie. Similarly, the plugin GD.Graph.pie3d is effectively the same as the plugin GD.Graph.pie. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph3d is copyright (c) 1999,2000 Wadsack-Allen. All Rights Reserved. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/linespoints.pm0000644000175000017500000000615210370657040023103 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::linespoints; use strict; use warnings; use base qw( GD::Graph::linespoints Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::linespoints - Create line/point graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.linespoints(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [50, 52, 53, 54, 55, 56, 57, 58, 59], [60, 61, 61, 63, 68, 66, 65, 61, 58], [70, 72, 71, 74, 78, 73, 75, 71, 68], ]; USE my_graph = GD.Graph.linespoints; my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Lines and Points Graph', y_max_value => 80, y_tick_number => 6, y_label_skip => 2, y_long_ticks => 1, x_tick_length => 2, markers => [ 1, 5 ], skip_undef => 1, transparent => 0, ); my_graph.set_legend('data set 1', 'data set 2', 'data set 3'); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.linespoints plugin provides an interface to the GD::Graph::linespoints class defined by the GD::Graph module. It allows one or more (x,y) data sets to be plotted as y versus x lines, plus symbols placed at each point, in addition to axes and legends. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/pie.pm0000644000175000017500000000477410370657057021331 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::pie; use strict; use warnings; use base qw( GD::Graph::pie Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::pie - Create pie charts with legends =head1 SYNOPSIS [% USE g = GD.Graph.pie(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th"], [ 4, 2, 3, 4, 3, 3.5] ]; USE my_graph = GD.Graph.pie( 250, 200 ); my_graph.set( title => 'A Pie Chart', label => 'Label', axislabelclr => 'black', pie_height => 36, transparent => 0, ); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.pie plugin provides an interface to the GD::Graph::pie class defined by the GD::Graph module. It allows an (x,y) data set to be plotted as a pie chart. The x values are typically strings. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/mixed.pm0000644000175000017500000000721010370657044021642 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::mixed; use strict; use warnings; use base qw( GD::Graph::mixed Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::mixed - Create mixed graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.mixed(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 1, 2, 5, 6, 3, 1.5, -1, -3, -4], [ -4, -3, 1, 1, -3, -1.5, -2, -1, 0], [ 9, 8, 9, 8.4, 7.1, 7.5, 8, 3, -3], [ 0.1, 0.2, 0.5, 0.4, 0.3, 0.5, 0.1, 0, 0.4], [ -0.1, 2, 5, 4, -3, 2.5, 3.2, 4, -4], ]; USE my_graph = GD.Graph.mixed(); my_graph.set( types => ['lines', 'lines', 'points', 'area', 'linespoints'], default_type => 'points', ); my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Mixed Type Graph', y_max_value => 10, y_min_value => -5, y_tick_number => 3, y_label_skip => 0, x_plot_values => 0, y_plot_values => 0, long_ticks => 1, x_ticks => 0, legend_marker_width => 24, line_width => 3, marker_size => 5, bar_spacing => 8, transparent => 0, ); my_graph.set_legend('one', 'two', 'three', 'four', 'five', 'six'); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.mixed plugin provides an interface to the GD::Graph::mixed class defined by the GD::Graph module. It allows one or more (x,y) data sets to be plotted with various styles (lines, points, bars, areas etc). See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/bars.pm0000644000175000017500000000757610370657015021500 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::bars; use strict; use warnings; use base qw( GD::Graph::bars Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::bars - Create bar graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.bars(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4], ]; USE my_graph = GD.Graph.bars(); my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'A Simple Bar Chart', y_max_value => 8, y_tick_number => 8, y_label_skip => 2, # shadows bar_spacing => 8, shadow_depth => 4, shadowclr => 'dred', transparent => 0, ); my_graph.plot(data).png | stdout(1); END; -%] [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4], ]; USE my_graph = GD.Graph.bars(); my_graph.set( x_label => 'X Label', y_label => 'Y label', title => 'Two data sets', # shadows bar_spacing => 8, shadow_depth => 4, shadowclr => 'dred', long_ticks => 1, y_max_value => 40, y_tick_number => 8, y_label_skip => 2, bar_spacing => 3, accent_treshold => 200, transparent => 0, ); my_graph.set_legend( 'Data set 1', 'Data set 2' ); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.bars plugin provides an interface to the GD::Graph::bars class defined by the GD::Graph module. It allows one or more (x,y) data sets to be plotted with each point represented by a bar, in addition to axes and legends. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/area.pm0000644000175000017500000000537210370657000021443 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::area; use strict; use warnings; use base qw( GD::Graph::area Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::area - Create area graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.area(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], [ -1, -2, -5, -6, -3, 1.5, 1, 1.3, 2] ]; USE my_graph = GD.Graph.area(); my_graph.set( two_axes => 1, zero_axis => 1, transparent => 0, ); my_graph.set_legend('left axis', 'right axis' ); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.area plugin provides an interface to the GD::Graph::area class defined by the GD::Graph module. It allows one or more (x,y) data sets to be plotted as lines with the area between the line and x-axis shaded, in addition to axes and legends. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/lines.pm0000644000175000017500000000707310370657033021653 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::lines; use strict; use warnings; use base qw( GD::Graph::lines Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::lines - Create line graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.lines(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; USE g = GD.Graph.lines(300,200); x = [1, 2, 3, 4]; y = [5, 4, 2, 3]; g.set( x_label => 'X Label', y_label => 'Y label', title => 'Title' ); g.plot([x, y]).png | stdout(1); END; -%] [% FILTER null; data = [ ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ], [-5, -4, -3, -3, -1, 0, 2, 1, 3, 4, 6, 7], [4, 3, 5, 6, 3,1.5, -1, -3, -4, -6, -7, -8], [1, 2, 2, 3, 4, 3, 1, -1, 0, 2, 3, 2], ]; USE my_graph = GD.Graph.lines(); my_graph.set( x_label => 'Month', y_label => 'Measure of success', title => 'A Simple Line Graph', y_max_value => 8, y_min_value => -8, y_tick_number => 16, y_label_skip => 2, box_axis => 0, line_width => 3, zero_axis_only => 1, x_label_position => 1, y_label_position => 1, x_label_skip => 3, x_tick_offset => 2, transparent => 0, ); my_graph.set_legend("Us", "Them", "Others"); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.lines plugin provides an interface to the GD::Graph::lines class defined by the GD::Graph module. It allows one or more (x,y) data sets to be plotted as y versus x lines with axes and legends. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Graph/bars3d.pm0000644000175000017500000000656310370657006021722 0ustar abwabw00000000000000package Template::Plugin::GD::Graph::bars3d; use strict; use warnings; use base qw( GD::Graph::bars3d Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } sub set_legend { my $self = shift; $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); } 1; __END__ =head1 NAME Template::Plugin::GD::Graph::bars3d - Create 3D bar graphs with axes and legends =head1 SYNOPSIS [% USE g = GD.Graph.bars3d(x_size, y_size); %] =head1 EXAMPLES [% FILTER null; data = [ ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ], [-5, -4, -3, -3, -1, 0, 2, 1, 3, 4, 6, 7], [4, 3, 5, 6, 3,1.5, -1, -3, -4, -6, -7, -8], [1, 2, 2, 3, 4, 3, 1, -1, 0, 2, 3, 2], ]; USE my_graph = GD.Graph.bars3d(); my_graph.set( x_label => 'Month', y_label => 'Measure of success', title => 'A 3d Bar Chart', y_max_value => 8, y_min_value => -8, y_tick_number => 16, y_label_skip => 2, box_axis => 0, line_width => 3, zero_axis_only => 1, x_label_position => 1, y_label_position => 1, x_label_skip => 3, x_tick_offset => 2, transparent => 0, ); my_graph.set_legend("Us", "Them", "Others"); my_graph.plot(data).png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Graph.bars3d plugin provides an interface to the GD::Graph::bars3d class defined by the GD::Graph3d module. It allows one or more (x,y) data sets to be plotted as y versus x bars with a 3-dimensional appearance, together with axes and legends. See L for more details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Martien Verbruggen wrote the GD::Graph module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Graph3d is copyright (C) 1999,2000 Wadsack-Allen. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Polygon.pm0000644000175000017500000000525310370656733021133 0ustar abwabw00000000000000package Template::Plugin::GD::Polygon; use strict; use warnings; use base 'Template::Plugin'; use GD; our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return GD::Polygon->new(@_); } 1; __END__ =head1 NAME Template::Plugin::GD::Polygon - Interface to GD module Polygon class =head1 SYNOPSIS [% USE poly = GD.Polygon; poly.addPt(50,0); poly.addPt(99,99); %] =head1 EXAMPLES [% FILTER null; USE im = GD.Image(100,100); USE c = GD.Constants; # allocate some colors white = im.colorAllocate(255,255,255); black = im.colorAllocate(0, 0, 0); red = im.colorAllocate(255,0, 0); blue = im.colorAllocate(0, 0,255); green = im.colorAllocate(0, 255,0); # make the background transparent and interlaced im.transparent(white); im.interlaced('true'); # Put a black frame around the picture im.rectangle(0,0,99,99,black); # Draw a blue oval im.arc(50,50,95,75,0,360,blue); # And fill it with red im.fill(50,50,red); # Draw a blue triangle by defining a polygon USE poly = GD.Polygon; poly.addPt(50,0); poly.addPt(99,99); poly.addPt(0,99); im.filledPolygon(poly, blue); # Output binary image in PNG format im.png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Polygon plugin provides an interface to GD.pm's GD::Polygon class. See L for a complete description of the GD library and all the methods that can be called via the GD.Polygon plugin. See L for the main interface to the GD functions. See L for a plugin that allows you access to GD.pm's constants. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. The GD.pm interface is copyright 1995-2000, Lincoln D. Stein. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Image.pm0000644000175000017500000000732010370656717020525 0ustar abwabw00000000000000package Template::Plugin::GD::Image; use strict; use warnings; use base 'Template::Plugin'; use GD; our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; return GD::Image->new(@_); } 1; __END__ =head1 NAME Template::Plugin::GD::Image - Interface to GD Graphics Library =head1 SYNOPSIS [% USE im = GD.Image(width, height) %] =head1 EXAMPLES [% FILTER null; USE gdc = GD.Constants; USE im = GD.Image(200,100); black = im.colorAllocate(0 ,0, 0); red = im.colorAllocate(255,0, 0); r = im.string(gdc.gdLargeFont, 10, 10, "Large Red Text", red); im.png | stdout(1); END; -%] [% FILTER null; USE im = GD.Image(100,100); # allocate some colors black = im.colorAllocate(0, 0, 0); red = im.colorAllocate(255,0, 0); blue = im.colorAllocate(0, 0, 255); # Draw a blue oval im.arc(50,50,95,75,0,360,blue); # And fill it with red im.fill(50,50,red); # Output binary image in PNG format im.png | stdout(1); END; -%] [% FILTER null; USE im = GD.Image(100,100); USE c = GD.Constants; USE poly = GD.Polygon; # allocate some colors white = im.colorAllocate(255,255,255); black = im.colorAllocate(0, 0, 0); red = im.colorAllocate(255,0, 0); blue = im.colorAllocate(0, 0,255); green = im.colorAllocate(0, 255,0); # make the background transparent and interlaced im.transparent(white); im.interlaced('true'); # Put a black frame around the picture im.rectangle(0,0,99,99,black); # Draw a blue oval im.arc(50,50,95,75,0,360,blue); # And fill it with red im.fill(50,50,red); # Draw a blue triangle poly.addPt(50,0); poly.addPt(99,99); poly.addPt(0,99); im.filledPolygon(poly, blue); # Output binary image in PNG format im.png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Image plugin provides an interface to GD.pm's GD::Image class. The GD::Image class is the main interface to GD.pm. It is very important that no extraneous template output appear before or after the image. Since some methods return values that would otherwise appear in the output, it is recommended that GD.Image code be wrapped in a null filter. The methods that produce the final output (eg, png, jpeg, gd etc) can then explicitly make their output appear by using the stdout filter, with a non-zero argument to force binary mode (required for non-modern operating systems). See L for a complete description of the GD library and all the methods that can be called via the GD.Image plugin. See L for a plugin that allows you access to GD.pm's constants. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. The GD.pm interface is copyright 1995-2000, Lincoln D. Stein. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Text.pm0000644000175000017500000000442310370656763020431 0ustar abwabw00000000000000package Template::Plugin::GD::Text; use strict; use warnings; use base qw( GD::Text Template::Plugin ); our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); return $class->SUPER::new(@_); } sub set { my $self = shift; push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); $self->SUPER::set(@_); } 1; __END__ =head1 NAME Template::Plugin::GD::Text - Text utilities for use with GD =head1 SYNOPSIS [% USE gd_text = GD.Text %] =head1 EXAMPLES [% USE gd_c = GD.Constants; USE t = GD.Text; x = t.set_text('Some text'); r = t.get('width', 'height', 'char_up', 'char_down'); r.join(":"); "\n"; # returns 54:13:13:0. -%] [% USE gd_c = GD.Constants; USE t = GD.Text(text => 'FooBar Banana', font => gd_c.gdGiantFont); t.get('width'); "\n"; # returns 117. -%] =head1 DESCRIPTION The GD.Text plugin provides an interface to the GD::Text module. It allows attributes of strings such as width and height in pixels to be computed. See L for more details. See L and L for plugins that allow you to render aligned or wrapped text in GD images. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it and Martien Verbruggen wrote the GD::Text module. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. GD::Text is copyright 1999 Martien Verbruggen. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD/Constants.pm0000644000175000017500000000450510370656746021463 0ustar abwabw00000000000000package Template::Plugin::GD::Constants; use strict; use warnings; use GD qw(/^gd/ /^GD/); use base 'Template::Plugin'; our $VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); sub new { my $class = shift; my $context = shift; my $self = { }; bless $self, $class; # # GD has exported various gd* and GD_* contstants. Find them. # foreach my $v ( keys(%Template::Plugin::GD::Constants::) ) { $self->{$v} = eval($v) if ( $v =~ /^gd/ || $v =~ /^GD_/ ); } return $self; } 1; __END__ =head1 NAME Template::Plugin::GD::Constants - Interface to GD module constants =head1 SYNOPSIS [% USE gdc = GD.Constants %] # --> the constants gdc.gdBrushed, gdc.gdSmallFont, gdc.GD_CMP_IMAGE # are now available =head1 EXAMPLES [% FILTER null; USE gdc = GD.Constants; USE im = GD.Image(200,100); black = im.colorAllocate(0 ,0, 0); red = im.colorAllocate(255,0, 0); r = im.string(gdc.gdLargeFont, 10, 10, "Large Red Text", red); im.png | stdout(1); END; -%] =head1 DESCRIPTION The GD.Constants plugin provides access to the various GD module's constants (such as gdBrushed, gdSmallFont, gdTransparent, GD_CMP_IMAGE etc). When GD.pm is used in perl it exports various contstants into the caller's namespace. This plugin makes those exported constants available as template variables. See L and L for further examples and details. =head1 AUTHOR Thomas Boutell wrote the GD graphics library. Lincoln D. Stein wrote the Perl GD modules that interface to it. Craig Barratt Ecraig@arraycomm.comE wrote the original GD plugins for the Template Toolkit (2001). Andy Wardley Eabw@cpan.orgE extracted them from the TT core into a separate distribution for TT version 2.15. =head1 COPYRIGHT Copyright (C) 2001 Craig Barratt Ecraig@arraycomm.comE, 2006 Andy Wardley Eabw@cpan.orgE. The GD.pm interface is copyright 1995-2000, Lincoln D. Stein. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: Template-GD-2.66/lib/Template/Plugin/GD.pm0000644000175000017500000001304010370656676017503 0ustar abwabw00000000000000package Template::Plugin::GD; use strict; use warnings; use base 'Template::Plugin'; use GD; our $VERSION = 2.66; sub new { my $class = shift; my $context = shift; bless { context => $context, }, $class; } sub image { my $self = shift; return GD::Image->new(@_); } sub polygon { my $self = shift; return GD::Polygon->new(@_); } sub text { my $self = shift; $self->{ context }->plugin( 'GD.Text' => @_ ); } 1; __END__ =head1 NAME Template::Plugin::GD - GD plugin(s) for the Template Toolkit =head1 SYNOPSIS [% USE GD; # create an image img = GD.image(width, height) # allocate some colors black = img.colorAllocate(0, 0, 0); red = img.colorAllocate(255, 0, 0); blue = img.colorAllocate(0, 0, 255); # draw a blue oval img.arc(50, 50, 95, 75, 0, 360, blue); # fill it with red img.fill(50, 50, red); # output binary image in PNG format img.png | redirect('example.png'); %] =head1 DESCRIPTION The Template-GD distribution provides a number of Template Toolkit plugin modules to interface with Lincoln Stein's GD modules. These in turn provide an interface to Thomas Boutell's GD graphics library. These plugins were distributed as part of the Template Toolkit until version 2.15 released in February 2006. At this time they were extracted into this separate distribution. For general information on the Template Toolkit see the documentation for the L