1Text::Align(3)        User Contributed Perl Documentation       Text::Align(3)
2
3
4

NAME

6       GD::Text::Align - Draw aligned strings
7

SYNOPSIS

9         use GD;
10         use GD::Text::Align;
11
12         my $gd = GD::Image->new(800,600);
13         # allocate colours, do other things.
14
15         my $align = GD::Text::Align->new($gd
16           valign => 'top',
17           halign => 'right',
18         );
19         $align->set_font('arial', 12);
20         $align->set_text('some string');
21         @bb = $align->bounding_box(200, 400, PI/3);
22         # you can do things based on the bounding box here
23         $align->draw(200, 400, PI/3);
24

DESCRIPTION

26       GD::Text::Align provides an object that draws a string aligned to a
27       coordinate at an angle.
28
29       For builtin fonts only two angles are valid: 0 and PI/2. All other
30       angles will be converted to one of these two.
31

METHODS

33       This class inherits everything from GD::Text. I will only discuss the
34       methods and attributes here that are not discussed there, or that have
35       a different interface or behaviour. Methods directly inherited include
36       "set_text" and "set_font".
37
38   GD::Text::Align->new($gd_object, attrib => value, ...)
39       Create a new object. The first argument to new has to be a valid
40       GD::Image object. The other arguments will be passed on to the set
41       method.
42
43   $align->set(attrib => value, ...)
44       Set an attribute. Valid attributes are the ones discussed in GD::Text
45       and:
46
47       valign, halign
48           Vertical and horizontal alignment of the string. See also
49           set_valign and set_halign.
50
51       colour, color
52           Synonyms. The colour to use to draw the string. This should be the
53           index of the colour in the GD::Image object's palette. The default
54           value is the last colour in the GD object's palette at the time of
55           the creation of $align.
56
57   $align->get(attribute)
58       Get the value of an attribute.  Valid attributes are all the attributes
59       mentioned in GD::Text, the attributes mentioned under the "set" method
60       and
61
62       x, y and angle
63           The x and y coordinate and the angle to be used. You can only do
64           this after a call to the draw or bounding_box methods. Note that
65           these coordinates are not necessarily the same ones that were
66           passed in.  Instead, they are the coordinates from where the GD
67           methods will start drawing. I doubt that this is very useful to
68           anyone.
69
70       Note that while you can set the colour with both 'color' and 'colour',
71       you can only get it as 'colour'. Sorry, but such is life in Australia.
72
73   $align->set_valign(value)
74       Set the vertical alignment of the string to one of 'top', 'center',
75       'base' or 'bottom'. For builtin fonts the last two are the same. The
76       value 'base' denotes the baseline of a TrueType font.  Returns true on
77       success, false on failure.
78
79   $align->set_halign(value)
80       Set the horizontal alignment of the string to one of 'left', 'center',
81       or 'right'.  Returns true on success, false on failure.
82
83   $align->set_align(valign, halign)
84       Set the vertical and horizontal alignment. Just here for convenience.
85       See also "set_valign" and "set_halign".  Returns true on success, false
86       on failure.
87
88   $align->draw(x, y, angle)
89       Draw the string at coordinates x, y at an angle angle in radians. The x
90       and y coordinate become the pivot around which the string rotates.
91
92       Note that for the builtin GD fonts the only two valid angles are 0 and
93       PI/2.
94
95       Returns the bounding box of the drawn string (see "bounding_box()").
96
97   $align->bounding_box(x, y, angle)
98       Return the bounding box of the string to draw. This returns an eight-
99       element list (exactly like the GD::Image->stringTTF method):
100
101         (x1,y1) lower left corner
102         (x2,y2) lower right corner
103         (x3,y3) upper right corner
104         (x4,y4) upper left corner
105
106       Note that upper, lower, left and right are relative to the string, not
107       to the canvas.
108
109       The bounding box can be used to make decisions about whether to move
110       the string or change the font size prior to actually drawing the
111       string.
112

NOTES

114       As with all Modules for Perl: Please stick to using the interface. If
115       you try to fiddle too much with knowledge of the internals of this
116       module, you may get burned. I may change them at any time.
117
118       You can only use TrueType fonts with version of GD > 1.20, and then
119       only if compiled with support for this. If you attempt to do it anyway,
120       you will get errors.
121
122       In the following, terms like 'top', 'upper', 'left' and the like are
123       all relative to the string to be drawn, not to the canvas.
124

BUGS

126       Any bugs inherited from GD::Text.
127
129       copyright 1999 Martien Verbruggen (mgjv@comdyn.com.au)
130

SEE ALSO

132       GD, GD::Text, GD::Text::Wrap
133
134
135
136perl v5.28.1                      2003-02-24                    Text::Align(3)
Impressum