summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-03-28 20:15:00 +0100
committerTomaž Vajngerl <quikee@gmail.com>2020-04-01 16:19:24 +0200
commit3ce519f41724fa4bd61e761b0442b21e6c65232a (patch)
treef525c3549f86f65025845b7ef6e218e28ba4fb6f
parent28419b6655c3ab4a11de8cbad4001a26dd3b8dc7 (diff)
basegfx: add convenience access. and creator to B2DHomMatrix
In SVG, CSS, HTML Canvas it is usual to define a matrix with a,b,c,d,e,f attributes, where the values correcpond to the following: [a,c,e] [b,d,f] [0,0,1] This change adds accessors and creator to B2DHomMatrix, so it is easier to deal with other matrices that are defined like that. Change-Id: I6927513b1a70ad5eb70d7fe14a00de4a767f176a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91310 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit cc7dc7552adb84dbd6954d01d2f347029d9302bc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91450 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--include/basegfx/matrix/b2dhommatrix.hxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/basegfx/matrix/b2dhommatrix.hxx b/include/basegfx/matrix/b2dhommatrix.hxx
index 9f2c8a338412..0015b2a78fce 100644
--- a/include/basegfx/matrix/b2dhommatrix.hxx
+++ b/include/basegfx/matrix/b2dhommatrix.hxx
@@ -47,6 +47,33 @@ namespace basegfx
B2DHomMatrix(B2DHomMatrix&& rMat);
~B2DHomMatrix();
+ /** Convenience creator for declaration of the matrix that is commonly
+ used by web standards (SVG, CSS, HTML).
+
+ Values a,b,c,d,e,f represent the following values in the matrix:
+ [a,c,e] [a,c,e]
+ [b,d,f] or [b,d,f]
+ [0,0,1]
+
+ */
+ static B2DHomMatrix abcdef(double da, double db, double dc, double dd, double de, double df)
+ {
+ return B2DHomMatrix(da, dc, de, db, dd, df);
+ }
+
+ // Convenience accessor for value at 0,0 position in the matrix
+ double a() { return get(0,0); }
+ // Convenience accessor for value at 1,0 position in the matrix
+ double b() { return get(1,0); }
+ // Convenience accessor for value at 0,1 position in the matrix
+ double c() { return get(0,1); }
+ // Convenience accessor for value at 1,1 position in the matrix
+ double d() { return get(1,1); }
+ // Convenience accessor for value at 0,2 position in the matrix
+ double e() { return get(0,2); }
+ // Convenience accessor for value at 1,2 position in the matrix
+ double f() { return get(1,2); }
+
/** constructor to allow setting all needed values for a 3x2 matrix at once. The
parameter f_0x1 e.g. is the same as using set(0, 1, f)
*/