GD::Text::Align.3pm
上传用户:qdrechuli
上传日期:2022-08-01
资源大小:917k
文件大小:9k
- ." Automatically generated by Pod::Man version 1.15
- ." Tue Oct 8 11:46:54 2002
- ."
- ." Standard preamble:
- ." ======================================================================
- .de Sh " Subsection heading
- .br
- .if t .Sp
- .ne 5
- .PP
- fB\$1fR
- .PP
- ..
- .de Sp " Vertical space (when we can't use .PP)
- .if t .sp .5v
- .if n .sp
- ..
- .de Ip " List item
- .br
- .ie \n(.$>=3 .ne \$3
- .el .ne 3
- .IP "\$1" \$2
- ..
- .de Vb " Begin verbatim text
- .ft CW
- .nf
- .ne \$1
- ..
- .de Ve " End verbatim text
- .ft R
- .fi
- ..
- ." Set up some character translations and predefined strings. *(-- will
- ." give an unbreakable dash, *(PI will give pi, *(L" will give a left
- ." double quote, and *(R" will give a right double quote. | will give a
- ." real vertical bar. *(C+ will give a nicer C++. Capital omega is used
- ." to do unbreakable dashes and therefore won't be available. *(C` and
- ." *(C' expand to `' in nroff, nothing in troff, for use with C<>
- .tr (*W-|(bv*(Tr
- .ds C+ Cv'-.1v'h'-1p's-2+h'-1p'+s0v'.1v'h'-1p'
- .ie n {
- . ds -- (*W-
- . ds PI pi
- . if (n(.H=4u)&(1m=24u) .ds -- (*Wh'-12u'(*Wh'-12u'-" diablo 10 pitch
- . if (n(.H=4u)&(1m=20u) .ds -- (*Wh'-12u'(*Wh'-8u'-" diablo 12 pitch
- . ds L" ""
- . ds R" ""
- . ds C` ""
- . ds C' ""
- 'br}
- .el{
- . ds -- |(em|
- . ds PI (*p
- . ds L" ``
- . ds R" ''
- 'br}
- ."
- ." If the F register is turned on, we'll generate index entries on stderr
- ." for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
- ." index entries marked with X<> in POD. Of course, you'll have to process
- ." the output yourself in some meaningful fashion.
- .if nF {
- . de IX
- . tm Index:\$1t\n%t"\$2"
- ..
- . nr % 0
- . rr F
- .}
- ."
- ." For nroff, turn off justification. Always turn off hyphenation; it
- ." makes way too many mistakes in technical documents.
- .hy 0
- .if n .na
- ."
- ." Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
- ." Fear. Run. Save yourself. No user-serviceable parts.
- .bd B 3
- . " fudge factors for nroff and troff
- .if n {
- . ds #H 0
- . ds #V .8m
- . ds #F .3m
- . ds #[ f1
- . ds #] fP
- .}
- .if t {
- . ds #H ((1u-(\\n(.fu%2u))*.13m)
- . ds #V .6m
- . ds #F 0
- . ds #[ &
- . ds #] &
- .}
- . " simple accents for nroff and troff
- .if n {
- . ds ' &
- . ds ` &
- . ds ^ &
- . ds , &
- . ds ~ ~
- . ds /
- .}
- .if t {
- . ds ' \k:h'-(\n(.wu*8/10-*(#H)''h"|\n:u"
- . ds ` \k:h'-(\n(.wu*8/10-*(#H)'`h'|\n:u'
- . ds ^ \k:h'-(\n(.wu*10/11-*(#H)'^h'|\n:u'
- . ds , \k:h'-(\n(.wu*8/10)',h'|\n:u'
- . ds ~ \k:h'-(\n(.wu-*(#H-.1m)'~h'|\n:u'
- . ds / \k:h'-(\n(.wu*8/10-*(#H)'z(slh'|\n:u'
- .}
- . " troff and (daisy-wheel) nroff accents
- .ds : \k:h'-(\n(.wu*8/10-*(#H+.1m+*(#F)'v'-*(#V'z.h'.2m+*(#F'.h'|\n:u'v'*(#V'
- .ds 8 h'*(#H'(*bh'-*(#H'
- .ds o \k:h'-(\n(.wu+w'(de'u-*(#H)/2u'v'-.3n'*(#[z(dev'.3n'h'|\n:u'*(#]
- .ds d- h'*(#H'(pdh'-w'~'u'v'-.25m'f2(hyfPv'.25m'h'-*(#H'
- .ds D- D\k:h'-w'D'u'v'-.11m'z(hyv'.11m'h'|\n:u'
- .ds th *(#[v'.3m's+1Is-1v'-.3m'h'-(w'I'u*2/3)'s-1os+1*(#]
- .ds Th *(#[s+2Is-2h'-w'I'u*3/5'v'-.3m'ov'.3m'*(#]
- .ds ae ah'-(w'a'u*4/10)'e
- .ds Ae Ah'-(w'A'u*4/10)'E
- . " corrections for vroff
- .if v .ds ~ \k:h'-(\n(.wu*9/10-*(#H)'s-2u~ds+2h'|\n:u'
- .if v .ds ^ \k:h'-(\n(.wu*10/11-*(#H)'v'-.4m'^v'.4m'h'|\n:u'
- . " for low resolution devices (crt and lpr)
- .if n(.H>23 .if n(.V>19
- {
- . ds : e
- . ds 8 ss
- . ds o a
- . ds d- dh'-1'(ga
- . ds D- Dh'-1'(hy
- . ds th o'bp'
- . ds Th o'LP'
- . ds ae ae
- . ds Ae AE
- .}
- .rm #[ #] #H #V #F C
- ." ======================================================================
- ."
- .IX Title "Text::Align 3"
- .TH Text::Align 3 "perl v5.6.1" "2000-03-18" "User Contributed Perl Documentation"
- .UC
- .SH "NAME"
- &s-1GD:s0:Text::Align - Draw aligned strings
- .SH "SYNOPSIS"
- .IX Header "SYNOPSIS"
- .Vb 2
- & use GD;
- & use GD::Text::Align;
- .Ve
- .Vb 2
- & my $gd = GD::Image->new(800,600);
- & # allocate colours, do other things.
- .Ve
- .Vb 9
- & my $align = GD::Text::Align->new($gd
- & valign => 'top',
- & halign => 'right',
- & );
- & $align->set_font('cetus.ttf', 12);
- & $align->set_text('some string');
- & @bb = $align->bounding_box(200, 400, PI/3);
- & # you can do things based on the bounding box here
- & $align->draw(200, 400, PI/3);
- .Ve
- .SH "DESCRIPTION"
- .IX Header "DESCRIPTION"
- &s-1GD:s0:Text::Align provides an object that draws a string aligned
- to a coordinate at an angle.
- .PP
- For builtin fonts only two angles are valid: 0 and *(PI/2s0. All other
- angles will be converted to one of these two.
- .SH "METHODS"
- .IX Header "METHODS"
- This class inherits everything from s-1GD:s0:Text. I will only discuss the
- methods and attributes here that are not discussed there, or that have a
- different interface or behaviour. Methods directly inherited include
- &f(CW*(C`set_text*(C'fR and f(CW*(C`set_font*(C'fR.
- .Sh "s-1GD:s0:Text::Align->new($gd_object, attrib => value, ...)"
- .IX Subsection "GD::Text::Align->new($gd_object, attrib => value, ...)"
- Create a new object. The first argument to new has to be a valid
- &s-1GD:s0:Image object. The other arguments will be passed on to the set
- method.
- .Sh "$align->set(attrib => value, ...)"
- .IX Subsection "$align->set(attrib => value, ...)"
- Set an attribute. Valid attributes are the ones discussed in
- the GD::Text manpage and:
- .Ip "valign, halign" 4
- .IX Item "valign, halign"
- Vertical and horizontal alignment of the string. See also set_valign and
- set_halign.
- .Ip "colour, color" 4
- .IX Item "colour, color"
- Synonyms. The colour to use to draw the string. This should be the index
- of the colour in the s-1GD:s0:Image object's palette. The default value is
- the last colour in the s-1GDs0 object's palette at the time of the creation
- of f(CW*(C`$align*(C'fR.
- .Sh "$align->get(attribute)"
- .IX Subsection "$align->get(attribute)"
- Get the value of an attribute.
- Valid attributes are all the attributes mentioned in the GD::Text manpage, the
- attributes mentioned under the f(CW*(C`set*(C'fR method and
- .Ip "x, y and angle" 4
- .IX Item "x, y and angle"
- The x and y coordinate and the angle to be used. You can only do this
- after a call to the draw or bounding_box methods. Note that these
- coordinates are not necessarily the same ones that were passed in.
- Instead, they are the coordinates from where the s-1GDs0 methods will start
- drawing. I doubt that this is very useful to anyone.
- .PP
- Note that while you can set the colour with both 'color' and 'colour',
- you can only get it as 'colour'. Sorry, but such is life in Australia.
- .Sh "$align->set_valign(value)"
- .IX Subsection "$align->set_valign(value)"
- Set the vertical alignment of the string to one of 'top', 'center',
- &'base' or 'bottom'. For builtin fonts the last two are the same. The
- value 'base' denotes the baseline of a TrueType font.
- Returns true on success, false on failure.
- .Sh "$align->set_halign(value)"
- .IX Subsection "$align->set_halign(value)"
- Set the horizontal alignment of the string to one of 'left', 'center',
- or 'right'.
- Returns true on success, false on failure.
- .Sh "$align->set_align(valign, halign)"
- .IX Subsection "$align->set_align(valign, halign)"
- Set the vertical and horizontal alignment. Just here for convenience.
- See also f(CW*(C`set_valign*(C'fR and f(CW*(C`set_halign*(C'fR.
- Returns true on success, false on failure.
- .Sh "$align->draw(x, y, angle)"
- .IX Subsection "$align->draw(x, y, angle)"
- Draw the string at coordinates fIxfR, fIyfR at an angle fIanglefR in
- radians. The x and y coordinate become the pivot around which the
- string rotates.
- .PP
- Note that for the builtin s-1GDs0 fonts the only two valid angles are 0 and
- &*(PI/2s0.
- .PP
- Returns the bounding box of the drawn string (see f(CW*(C`bounding_box()*(C'fR).
- .Sh "$align->bounding_box(x, y, angle)"
- .IX Subsection "$align->bounding_box(x, y, angle)"
- Return the bounding box of the string to draw. This returns an
- eight-element list (exactly like the s-1GD:s0:Image->stringTTF method):
- .PP
- .Vb 4
- & (x1,y1) lower left corner
- & (x2,y2) lower right corner
- & (x3,y3) upper right corner
- & (x4,y4) upper left corner
- .Ve
- Note that upper, lower, left and right are relative to the string, not
- to the canvas.
- .PP
- The bounding box can be used to make decisions about whether to move the
- string or change the font size prior to actually drawing the string.
- .SH "NOTES"
- .IX Header "NOTES"
- As with all Modules for Perl: Please stick to using the interface. If
- you try to fiddle too much with knowledge of the internals of this
- module, you may get burned. I may change them at any time.
- .PP
- You can only use TrueType fonts with version of s-1GDs0 > 1.20, and then
- only if compiled with support for this. If you attempt to do it
- anyway, you will get errors.
- .PP
- In the following, terms like 'top', 'upper', 'left' and the like are all
- relative to the string to be drawn, not to the canvas.
- .SH "BUGS"
- .IX Header "BUGS"
- Any bugs inherited from s-1GD:s0:Text.
- .SH "COPYRIGHT"
- .IX Header "COPYRIGHT"
- copyright 1999
- Martien Verbruggen (mgjv@comdyn.com.au)
- .SH "SEE ALSO"
- .IX Header "SEE ALSO"
- the GD manpage, the GD::Text manpage, the GD::Text::Wrap manpage