From ed43421545c86f85b5fc4b9a33be077748fb8487 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 14 Aug 2012 08:19:40 +0000 Subject: Resolves: fdo#49508# #i120539# Fixed visualisation of gradient 'square' which was broken in OOo3.3 (cherry picked from commit 008bc1d4b8cd47ca9940be00a8cfdcdb1ef85856) Change-Id: I912b74deb37f9dc09e2ae83977aab180c46bd501 --- basegfx/source/tools/gradienttools.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'basegfx/source') diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index f2e65774ba02..c45c335e9368 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -190,6 +190,16 @@ namespace basegfx double fTargetOffsetX(rTargetRange.getMinX()); double fTargetOffsetY(rTargetRange.getMinY()); + // add object expansion + if(bSquare) + { + const double fOriginalDiag(sqrt((fTargetSizeX * fTargetSizeX) + (fTargetSizeY * fTargetSizeY))); + fTargetOffsetX -= (fOriginalDiag - fTargetSizeX) / 2.0; + fTargetOffsetY -= (fOriginalDiag - fTargetSizeY) / 2.0; + fTargetSizeX = fOriginalDiag; + fTargetSizeY = fOriginalDiag; + } + // add object expansion if(0.0 != fAngle) { @@ -230,10 +240,7 @@ namespace basegfx o_rGradientInfo.maTextureTransform.translate(fTargetOffsetX, fTargetOffsetY); // prepare aspect for texture - if( bSquare ) - o_rGradientInfo.mfAspectRatio = 1.0; // since we want a square - else - o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0; + o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0; // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform; -- cgit