diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-03-28 20:15:00 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-03-29 13:19:47 +0200 |
commit | cc7dc7552adb84dbd6954d01d2f347029d9302bc (patch) | |
tree | bae29fc5c3057e71ea9f2ec1dfd5b68f57eeee35 /include/basegfx/matrix | |
parent | b53a9c552a30a3aaa2b26ef8b1a3e8cf0f011a5c (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>
Diffstat (limited to 'include/basegfx/matrix')
-rw-r--r-- | include/basegfx/matrix/b2dhommatrix.hxx | 27 |
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) */ |