1------------------------------------------------------------------------------ 2-- GtkAda - Ada95 binding for Gtk+/Gnome -- 3-- -- 4-- Copyright (C) 2010-2015, AdaCore -- 5-- -- 6-- This library is free software; you can redistribute it and/or modify it -- 7-- under terms of the GNU General Public License as published by the Free -- 8-- Software Foundation; either version 3, or (at your option) any later -- 9-- version. This library is distributed in the hope that it will be useful, -- 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- 11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 12-- -- 13-- As a special exception under Section 7 of GPL version 3, you are granted -- 14-- additional permissions described in the GCC Runtime Library Exception, -- 15-- version 3.1, as published by the Free Software Foundation. -- 16-- -- 17-- You should have received a copy of the GNU General Public License and -- 18-- a copy of the GCC Runtime Library Exception along with this program; -- 19-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 20-- <http://www.gnu.org/licenses/>. -- 21-- -- 22------------------------------------------------------------------------------ 23 24-- <description> 25-- Generic matrix operations. 26-- </description> 27-- 28-- <c_version>1.8.8</c_version> 29-- <group>Cairo</group> 30 31package Cairo.Matrix is 32 33 procedure Init 34 (Matrix : access Cairo_Matrix; 35 Xx : Gdouble; 36 Yx : Gdouble; 37 Xy : Gdouble; 38 Yy : Gdouble; 39 X0 : Gdouble; 40 Y0 : Gdouble); 41 -- Matrix: a Cairo_Matrix 42 -- Xx: Xx component of the affine transformation 43 -- Yx: Yx component of the affine transformation 44 -- Xy: Xy component of the affine transformation 45 -- Yy: Yy component of the affine transformation 46 -- X0: X translation component of the affine transformation 47 -- Y0: Y translation component of the affine transformation 48 -- 49 -- Sets matrix to be the affine transformation given by 50 -- Xx, Yx, Xy, Yy, X0, Y0. The transformation is given 51 -- by: 52 -- 53 -- X_new = Xx * X + Xy * Y + X0; 54 -- Y_new = Yx * X + Yy * Y + Y0; 55 56 procedure Init_Identity (Matrix : access Cairo_Matrix); 57 -- Matrix: a Cairo_Matrix 58 -- 59 -- Modifies matrix to be an identity transformation. 60 61 procedure Init_Translate 62 (Matrix : access Cairo_Matrix; 63 Tx : Gdouble; 64 Ty : Gdouble); 65 -- Matrix: a Cairo_Matrix 66 -- Tx: amount to translate in the X direction 67 -- Ty: amount to translate in the Y direction 68 -- 69 -- Initializes matrix to a transformation that translates by Tx and 70 -- Ty in the X and Y dimensions, respectively. 71 72 procedure Init_Scale 73 (Matrix : access Cairo_Matrix; 74 Sx : Gdouble; 75 Sy : Gdouble); 76 -- Matrix: a Cairo_Matrix 77 -- Sx: scale factor in the X direction 78 -- Sy: scale factor in the Y direction 79 -- 80 -- Initializes matrix to a transformation that scales by Sx and Sy 81 -- in the X and Y dimensions, respectively. 82 83 procedure Init_Rotate (Matrix : access Cairo_Matrix; Radians : Gdouble); 84 -- Matrix: a Cairo_Matrix 85 -- Radians: angle of rotation, in Radians. The direction of rotation 86 -- is defined such that positive angles rotate in the direction from 87 -- the positive X axis toward the positive Y axis. With the default 88 -- axis orientation of cairo, positive angles rotate in a clockwise 89 -- direction. 90 -- 91 -- Initialized matrix to a transformation that rotates by radians. 92 93 procedure Translate 94 (Matrix : access Cairo_Matrix; 95 Tx : Gdouble; 96 Ty : Gdouble); 97 -- Matrix: a Cairo_Matrix 98 -- Tx: amount to translate in the X direction 99 -- Ty: amount to translate in the Y direction 100 -- 101 -- Applies a translation by Tx, Ty to the transformation in 102 -- matrix. The effect of the new transformation is to first translate 103 -- the coordinates by Tx and Ty, then apply the original transformation 104 -- to the coordinates. 105 106 procedure Scale 107 (Matrix : access Cairo_Matrix; 108 Sx : Gdouble; 109 Sy : Gdouble); 110 -- Matrix: a Cairo_Matrix 111 -- Sx: scale factor in the X direction 112 -- Sy: scale factor in the Y direction 113 -- 114 -- Applies scaling by Sx, Sy to the transformation in matrix. The 115 -- effect of the new transformation is to first scale the coordinates 116 -- by Sx and Sy, then apply the original transformation to the coordinates. 117 118 procedure Rotate (Matrix : access Cairo_Matrix; Radians : Gdouble); 119 -- Matrix: a Cairo_Matrix 120 -- Radians: angle of rotation, in Radians. The direction of rotation 121 -- is defined such that positive angles rotate in the direction from 122 -- the positive X axis toward the positive Y axis. With the default 123 -- axis orientation of cairo, positive angles rotate in a clockwise 124 -- direction. 125 -- 126 -- Applies rotation by radians to the transformation in matrix. The effect 127 -- of the new transformation is to first rotate the coordinates by radians, 128 -- then apply the original transformation to the coordinates. 129 130 function Invert (Matrix : access Cairo_Matrix) return Cairo_Status; 131 -- Matrix: a Cairo_Matrix 132 -- 133 -- Changes matrix to be the inverse of its original value. Not 134 -- all transformation matrices have inverses; if the matrix 135 -- collapses points together (it is "degenerate"), 136 -- then it has no inverse and this function will fail. 137 -- 138 -- Returns: If matrix has an inverse, modifies matrix to 139 -- be the inverse matrix and returns Cairo_Status_Success. Otherwise, 140 -- returns Cairo_Status_Invalid_Matrix. 141 142 procedure Multiply 143 (Result : access Cairo_Matrix; 144 A : access Cairo_Matrix; 145 B : access Cairo_Matrix); 146 -- Result: a Cairo_Matrix in which to store the Result 147 -- A: a Cairo_Matrix 148 -- B: a Cairo_Matrix 149 -- 150 -- Multiplies the affine transformations in a and b together 151 -- and stores the result in result. The effect of the resulting 152 -- transformation is to first apply the transformation in a to the 153 -- coordinates and then apply the transformation in b to the 154 -- coordinates. 155 -- 156 -- It is allowable for result to be identical to either a or b. 157 158 procedure Transform_Distance 159 (Matrix : access Cairo_Matrix; 160 Dx : access Gdouble; 161 Dy : access Gdouble); 162 -- Matrix: a Cairo_Matrix 163 -- Dx: X component of a distance vector. An in/out parameter 164 -- Dy: Y component of a distance vector. An in/out parameter 165 -- 166 -- Transforms the distance vector (Dx,Dy) by matrix. This is 167 -- similar to Cairo.Matrix.Transform_Point except that the translation 168 -- components of the transformation are ignored. The calculation of 169 -- the returned vector is as follows: 170 -- 171 -- Dx2 = Dx1 * A + Dy1 * C; 172 -- Dy2 = Dx1 * B + Dy1 * D; 173 -- 174 -- Affine transformations are position invariant, so the same vector 175 -- always transforms to the same vector. If (X1,Y1) transforms 176 -- to (X2,Y2) then (X1+Dx1,Y1+Dy1) will transform to 177 -- (X1+Dx2,Y1+Dy2) for all values of X1 and X2. 178 179 procedure Transform_Point 180 (Matrix : access Cairo_Matrix; 181 X : access Gdouble; 182 Y : access Gdouble); 183 -- Matrix: a Cairo_Matrix 184 -- X: X position. An in/out parameter 185 -- Y: Y position. An in/out parameter 186 -- 187 -- Transforms the point (X, Y) by matrix. 188 189private 190 191 pragma Import (C, Init, "cairo_matrix_init"); 192 pragma Import (C, Init_Identity, "cairo_matrix_init_identity"); 193 pragma Import (C, Init_Translate, "cairo_matrix_init_translate"); 194 pragma Import (C, Init_Scale, "cairo_matrix_init_scale"); 195 pragma Import (C, Init_Rotate, "cairo_matrix_init_rotate"); 196 pragma Import (C, Translate, "cairo_matrix_translate"); 197 pragma Import (C, Scale, "cairo_matrix_scale"); 198 pragma Import (C, Rotate, "cairo_matrix_rotate"); 199 pragma Import (C, Invert, "cairo_matrix_invert"); 200 pragma Import (C, Multiply, "cairo_matrix_multiply"); 201 pragma Import (C, Transform_Distance, "cairo_matrix_transform_distance"); 202 pragma Import (C, Transform_Point, "cairo_matrix_transform_point"); 203 204end Cairo.Matrix; 205