Templat...t::Align(3)

πŸ’… Templat...t::Align(3) β€” bestie edition

ok so real talk, this page is from the User Contributed Perl Documentation (that's the manual name, it's giving ✨community-maintained✨) and it's about drawing text in GD images. picture that. text. in images. aligned. iconic.


πŸ¦‹ NAME

Template::Plugin::GD::Text::Align β€” draws aligned strings in GD images. that's the whole vibe, no cap.


🌸 SYNOPSIS

[% USE align = GD.Text.Align(gd_image); %]

literally one line, she's effortless πŸ’…


πŸŽ€ EXAMPLES

ok here's the full demo, drink it in:

[% 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;
-%]

so she makes a 100,100 image, grabs her colors from GD.Constants, draws a blue oval with im.arc(50,50,95,75,0,360,blue), then sets up GD.Text.Align(im), picks gdc.gdLargeFont, says "Hello", sets colour => red, halign => "center", calls a.draw(50,70,0) and pipes out a PNG to stdout(1). the whole glow-up in one template πŸ”₯


✨ DESCRIPTION

the GD.Text.Align plugin is basically the middleman β€” it gives you an interface to the GD::Text::Align module, so you can draw text in GD images with all sorts of alignments and orientations. main character text placement tbh πŸ‘‘

for the deeper lore, go read GD::Text::Align. and if you want wrapped text in GD images instead, head over to Template::Plugin::GD::Text::Wrap β€” that's the plugin that does the wrapping iykyk 🫢


πŸ‘‘ 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 <craig@arraycomm.com> wrote the original GD plugins for the Template Toolkit (2001).
  • Andy Wardley <abw@cpan.org> extracted them from the TT core into a separate distribution for TT version 2.15.
πŸ₯Ί and listen β€” these modules are looking for a new maintainer. please contact Andy Wardley if you're willing to help out. adopt these icons, bestie, they deserve it πŸ’–

Copyright (C) 2001 Craig Barratt <craig@arraycomm.com>, 2006 Andy Wardley <abw@cpan.org>.

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. slay, free software rights 🫢


πŸ”₯ SEE ALSO

  • Template::Plugin::GD
  • Template::Plugin::GD::Text
  • Template::Plugin::GD::Text::Wrap
  • GD

the whole friend group fr fr πŸ’œ


⭐ cute little sign-off: this was perl v5.42.0, dated 2017-10-08 β€” and that's the whole page, bestie, you ate that πŸŽ€βœ¨

πŸ“¦ where this page comes from