1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsTransform2D_h___
8 #define nsTransform2D_h___
15 * This represents the following matrix (note that the order of row/column
16 * indices is opposite to usual notation)
22 * Transformation of a coordinate (x, y) is obtained by setting
23 * v = (x, y, 1)^T and evaluating M . v
26 float m00
, m11
, m20
, m21
;
34 ~nsTransform2D(void) = default;
37 * set this transform to a translation
39 * @param tx, x translation
40 * @param ty, y translation
43 void SetToTranslate(float tx
, float ty
) {
50 * get the translation portion of this transform
52 * @param pt, Point to return translation values in
55 void GetTranslationCoord(nscoord
* ptX
, nscoord
* ptY
) const {
56 *ptX
= NSToCoordRound(m20
);
57 *ptY
= NSToCoordRound(m21
);
61 * apply matrix to vector
63 * @param pt Point to transform
66 void TransformCoord(nscoord
* ptX
, nscoord
* ptY
) const;
69 * apply matrix to rect
71 * @param rect Rect to transform
74 void TransformCoord(nscoord
* aX
, nscoord
* aY
, nscoord
* aWidth
,
75 nscoord
* aHeight
) const;
78 * add a scale to a Transform via x, y pair
80 * @param ptX x value to add as x scale
81 * @param ptY y value to add as y scale
84 void AddScale(float ptX
, float ptY
) {
90 * Set the scale (overriding any previous calls to AddScale, but leaving
91 * any existing translation).
93 * @param ptX x value to add as x scale
94 * @param ptY y value to add as y scale
97 void SetScale(float ptX
, float ptY
) {