in reply to Re: Re: CGI Text on a path -- Possible?
in thread CGI Text on a path -- Possible?
use strict; use warnings; use Math::Bezier; use GD; use IO::File; my @control = ( 0, 0, 100, 200, 300, -200, 400, 0 ); my $bezier = Math::Bezier->new(@control); my $text = "Hello World, this is Perl"; my $len = length($text); my @curve = $bezier->curve($len); my @pos = map { my $idx = $_ * 2; [ $curve[$idx], $curve[$idx + 1] ] } 0 .. $len - 1; my $im = new GD::Image(1024, 768); my $white = $im->colorAllocate(0,0,0); my $black = $im->colorAllocate(255,255,255); my @chars = split //, $text; $im->string(gdGiantFont, $pos[$_][0] + 200, $pos[$_][1] + 500, $chars[$_], $black) for 0..$#chars; my $f = new IO::File "test.jpg", "w" or die; binmode $f; print $f $im->jpeg;
|
|---|