1Imager::Matrix2d(3)   User Contributed Perl Documentation  Imager::Matrix2d(3)
2
3
4

NAME

6         Imager::Matrix2d - simple wrapper for matrix construction
7

SYNOPSIS

9         use Imager::Matrix2d;
10         $m1 = Imager::Matrix2d->identity;
11         $m2 = Imager::Matrix2d->rotate(radians=>$angle, x=>$cx, y=>$cy);
12         $m3 = Imager::Matrix2d->translate(x=>$dx, y=>$dy);
13         $m4 = Imager::Matrix2d->shear(x=>$sx, y=>$sy);
14         $m5 = Imager::Matrix2d->reflect(axis=>$axis);
15         $m6 = Imager::Matrix2d->scale(x=>$xratio, y=>$yratio);
16         $m8 = Imager::Matric2d->matrix($v11, $v12, $v13,
17                                        $v21, $v22, $v23,
18                                        $v31, $v32, $v33);
19         $m6 = $m1 * $m2;
20         $m7 = $m1 + $m2;
21         use Imager::Matrix2d qw(:handy);
22         # various m2d_* functions imported
23         # where m2d_(.*) calls Imager::Matrix2d->$1()
24

DESCRIPTION

26       This class provides a simple wrapper around a reference to an array of
27       9 coefficients, treated as a matrix:
28
29        [ 0, 1, 2,
30          3, 4, 5,
31          6, 7, 8 ]
32
33       Most of the methods in this class are constructors.  The others are
34       overloaded operators.
35
36       Note that since Imager represents images with y increasing from top to
37       bottom, rotation angles are clockwise, rather than counter-clockwise.
38
39       identity()
40           Returns the identity matrix.
41
42       rotate(radians=>$angle)
43       rotate(degrees=>$angle)
44           Creates a matrix that rotates around the origin, or around the
45           point (x,y) if the 'x' and 'y' parameters are provided.
46
47       translate(x=>$dx, y=>$dy)
48       translate(x=>$dx)
49       translate(y=>$dy)
50           Translates by the specify amounts.
51
52       shear(x=>$sx, y=>$sy)
53       shear(x=>$sx)
54       shear(y=>$sy)
55           Shear by the given amounts.
56
57       reflect(axis=>$axis)
58           Reflect around the given axis, either 'x' or 'y'.
59
60       reflect(radians=>$angle)
61       reflect(degrees=>$angle)
62           Reflect around a line drawn at the given angle from the origin.
63
64       scale(x=>$xratio, y=>$yratio)
65           Scales at the given ratios.
66
67           You can also specify a center for the scaling with the "cx" and
68           "cy" parameters.
69
70       matrix($v11, $v12, $v13, $v21, $v22, $v23, $v31, $v32, $v33)
71           Create a matrix with custom coefficients.
72
73       transform($x, $y)
74           Transform a point the same way matrix_transform does.
75
76       compose(matrix...)
77           Compose several matrices together for use in transformation.
78
79           For example, for three matrices:
80
81             my $out = Imager::Matrix2d->compose($m1, $m2, $m3);
82
83           is equivalent to:
84
85             my $out = $m3 * $m2 * $m1;
86
87           Returns the identity matrix if no parameters are supplied.
88
89           May return the supplied matrix if only one matrix is supplied.
90
91       _mult()
92           Implements the overloaded '*' operator.  Internal use.
93
94           Currently both the left and right-hand sides of the operator must
95           be an Imager::Matrix2d.
96
97           When composing a matrix for transformation you should multiply the
98           matrices in the reverse order of the transformations:
99
100             my $shear = Imager::Matrix2d->shear(x => 0.1);
101             my $rotate = Imager::Matrix2d->rotate(degrees => 45);
102             my $shear_then_rotate = $rotate * $shear;
103
104           or use the compose method:
105
106             my $shear_then_rotate = Imager::Matrix2d->compose($shear, $rotate);
107
108       _add()
109           Implements the overloaded binary '+' operator.
110
111           Currently both the left and right sides of the operator must be
112           Imager::Matrix2d objects.
113
114       _string()
115           Implements the overloaded stringification operator.
116
117           This returns a string containing 3 lines of text with no
118           terminating newline.
119
120           I tried to make it fairly nicely formatted.  You might disagree :)
121
122       _eq Implement the overloaded equality operator.
123
124           Provided for older perls that don't handle magic auto generation of
125           eq from "".
126
127       The following functions are shortcuts to the various constructors.
128
129       These are not methods.
130
131       You can import these methods with:
132
133         use Imager::Matrix2d ':handy';
134
135       m2d_identity
136       m2d_rotate()
137       m2d_translate()
138       m2d_shear()
139       m2d_reflect()
140       m2d_scale()
141

AUTHOR

143       Tony Cook <tony@develop-help.com>
144

BUGS

146       Needs a way to invert a matrix.
147

SEE ALSO

149       Imager(3), Imager::Font(3)
150
151       http://imager.perl.org/
152
153
154
155perl v5.32.1                      2021-01-27               Imager::Matrix2d(3)
Impressum