in reply to CGI Text on a path -- Possible?

That depends. Your question is too generic. What are you trying to do? Curve fitting? And also you haven't told us what is the expected output yet. If you only want to draw the text inside an image, that would be easy. You could do that with GD and similar packages. If you want to present output as plain text, then you need to add <pre> and </pre> tags around your output to preserve the returns. But the solution depends on your actual problem.

So one step at a time. Please give more detail on the problem.

Replies are listed 'Best First'.
Re: Re: CGI Text on a path -- Possible?
by gregfriend (Novice) on Feb 26, 2004 at 23:04 UTC
    The output file will be an image - jpg, bmp etc. Whatever I can manage. What I am wanting to do is to take a user's family tree information and format it in the actual shape of a tree where the names form the trunk and the branches. I was able to automate it pretty well with the VB sendkeys function and CorelDRAW providing the graphics engine (with built in text on a path support) but it still required quite a bit of manual tweaking to make it look good. The bezier curve requirement is because the branches look better and fit together better when there is a dual curve to them. I want to make it CGI because I would like to shift the burden of the manual tweaking to the user rather than me. :) So I guess in addition to the text on a path question I also need to know how to get that information into a jpg or bmp. Someone suggested the GD module but I haven't had a chance to look at it yet.

    Greg Friend
      I wrote a bezier text demo below, that will give you something to start with. It will be easy to convert this demo to work from the browser, just print appropriate content header, binmode the STDOUT, and dump the image to the STDOUT.
      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;

      You can also use the Windows version of ImageMagick which has built-in support for bezier text (I think), and it is an excellent graphics package.