From cc7dc7552adb84dbd6954d01d2f347029d9302bc Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 28 Mar 2020 20:15:00 +0100 Subject: basegfx: add convenience access. and creator to B2DHomMatrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- include/basegfx/matrix/b2dhommatrix.hxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'include/basegfx') 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) */ -- cgit