diff options
author | thb <thb@openoffice.org> | 2009-10-16 00:43:16 +0200 |
---|---|---|
committer | thb <thb@openoffice.org> | 2009-10-16 00:43:16 +0200 |
commit | 39d191d6dcac49b137dbcd3b4e029714016641ea (patch) | |
tree | f34330c117e9abdb71e5521f399bc84d67a70045 /drawinglayer/source/texture | |
parent | 49d596bd5d1b5e0a1e02d74a51aab207410abae4 (diff) |
#i105937# Much improved gradient support for canvas/basegfx/drawinglayer.
See http://blog.thebehrens.net/2009/07/28/hackweek-iv-canvas-convwatch/ for more background information
Diffstat (limited to 'drawinglayer/source/texture')
-rw-r--r-- | drawinglayer/source/texture/texture.cxx | 126 | ||||
-rw-r--r-- | drawinglayer/source/texture/texture3d.cxx | 2 |
2 files changed, 26 insertions, 102 deletions
diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index 4f784c71897f..934003ce5a00 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -165,15 +165,10 @@ namespace drawinglayer { if(maGradientInfo.mnSteps) { - const double fTop(mfBorder); - const double fStripeWidth((1.0 - fTop) / maGradientInfo.mnSteps); - + const double fStripeWidth(1.0 / maGradientInfo.mnSteps); for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) { - const double fOffsetUpper(fStripeWidth * (double)a); - - // create matrix - const basegfx::B2DRange aRect(0.0, fTop + fOffsetUpper, 1.0, 1.0); + const basegfx::B2DRange aRect(0.0, fStripeWidth * a, 1.0, 1.0); impAppendMatrix(rMatrices, aRect); } } @@ -225,17 +220,10 @@ namespace drawinglayer { if(maGradientInfo.mnSteps) { - const double fHalfBorder(mfBorder * 0.5); - double fTop(fHalfBorder); - double fBottom(1.0 - fHalfBorder); - const double fStripeWidth((fBottom - fTop) / ((maGradientInfo.mnSteps * 2L) - 1L)); - - for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) + const double fStripeWidth=1.0 / (maGradientInfo.mnSteps - 1L); + for(sal_uInt32 a(maGradientInfo.mnSteps-1L); a != 0; a--) { - const double fOffset(fStripeWidth * (double)a); - - // create matrix - const basegfx::B2DRange aRect(0.0, fTop + fOffset, 1.0, fBottom - fOffset); + const basegfx::B2DRange aRect(0, 0, 1.0, fStripeWidth * a); impAppendMatrix(rMatrices, aRect); } } @@ -287,34 +275,10 @@ namespace drawinglayer { if(maGradientInfo.mnSteps) { - const double fHalfBorder((1.0 - mfBorder) * 0.5); - double fLeft(0.5 - fHalfBorder); - double fTop(0.5 - fHalfBorder); - double fRight(0.5 + fHalfBorder); - double fBottom(0.5 + fHalfBorder); - double fIncrementX, fIncrementY; - - if(maGradientInfo.mfAspectRatio > 1.0) - { - fIncrementY = (fBottom - fTop) / (double)(maGradientInfo.mnSteps * 2L); - fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio; - } - else - { - fIncrementX = (fRight - fLeft) / (double)(maGradientInfo.mnSteps * 2L); - fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio; - } - + const double fStepSize=1.0 / maGradientInfo.mnSteps; for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) { - // next step - fLeft += fIncrementX; - fRight -= fIncrementX; - fTop += fIncrementY; - fBottom -= fIncrementY; - - // create matrix - const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom); + const basegfx::B2DRange aRect(0, 0, fStepSize*a, fStepSize*a); impAppendMatrix(rMatrices, aRect); } } @@ -359,34 +323,29 @@ namespace drawinglayer { if(maGradientInfo.mnSteps) { - const double fHalfBorder((1.0 - mfBorder) * 0.5); - double fLeft(0.5 - fHalfBorder); - double fTop(0.5 - fHalfBorder); - double fRight(0.5 + fHalfBorder); - double fBottom(0.5 + fHalfBorder); + double fWidth(1); + double fHeight(1); double fIncrementX, fIncrementY; if(maGradientInfo.mfAspectRatio > 1.0) { - fIncrementY = (fBottom - fTop) / (double)(maGradientInfo.mnSteps * 2L); + fIncrementY = fHeight / maGradientInfo.mnSteps; fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio; } else { - fIncrementX = (fRight - fLeft) / (double)(maGradientInfo.mnSteps * 2L); + fIncrementX = fWidth / maGradientInfo.mnSteps; fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio; } for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) { // next step - fLeft += fIncrementX; - fRight -= fIncrementX; - fTop += fIncrementY; - fBottom -= fIncrementY; + fWidth -= fIncrementX; + fHeight -= fIncrementY; // create matrix - const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom); + const basegfx::B2DRange aRect(0, 0, fWidth, fHeight); impAppendMatrix(rMatrices, aRect); } } @@ -431,42 +390,10 @@ namespace drawinglayer { if(maGradientInfo.mnSteps) { - const double fHalfBorder((1.0 - mfBorder) * 0.5); - double fLeft(0.5 - fHalfBorder); - double fTop(0.5 - fHalfBorder); - double fRight(0.5 + fHalfBorder); - double fBottom(0.5 + fHalfBorder); - double fIncrementX, fIncrementY; - - if(maGradientInfo.mfAspectRatio > 1.0) - { - const double fWidth(fRight - fLeft); - const double fHalfAspectExpansion(((maGradientInfo.mfAspectRatio - 1.0) * 0.5) * fWidth); - fTop -= fHalfAspectExpansion; - fBottom += fHalfAspectExpansion; - fIncrementX = fWidth / (double)(maGradientInfo.mnSteps * 2L); - fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio; - } - else - { - const double fHeight(fBottom - fTop); - const double fHalfAspectExpansion((((1.0 / maGradientInfo.mfAspectRatio) - 1.0) * 0.5) * fHeight); - fLeft -= fHalfAspectExpansion; - fRight += fHalfAspectExpansion; - fIncrementY = fHeight / (double)(maGradientInfo.mnSteps * 2L); - fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio; - } - + const double fStepSize=1.0 / maGradientInfo.mnSteps; for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) { - // next step - fLeft += fIncrementX; - fRight -= fIncrementX; - fTop += fIncrementY; - fBottom -= fIncrementY; - - // create matrix - const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom); + const basegfx::B2DRange aRect(0, 0, fStepSize*a, fStepSize*a); impAppendMatrix(rMatrices, aRect); } } @@ -511,34 +438,29 @@ namespace drawinglayer { if(maGradientInfo.mnSteps) { - const double fHalfBorder((1.0 - mfBorder) * 0.5); - double fLeft(0.5 - fHalfBorder); - double fTop(0.5 - fHalfBorder); - double fRight(0.5 + fHalfBorder); - double fBottom(0.5 + fHalfBorder); + double fWidth(1); + double fHeight(1); double fIncrementX, fIncrementY; if(maGradientInfo.mfAspectRatio > 1.0) { - fIncrementY = (fBottom - fTop) / (double)(maGradientInfo.mnSteps * 2L); + fIncrementY = fHeight / maGradientInfo.mnSteps; fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio; } else { - fIncrementX = (fRight - fLeft) / (double)(maGradientInfo.mnSteps * 2L); + fIncrementX = fWidth / maGradientInfo.mnSteps; fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio; } for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) { // next step - fLeft += fIncrementX; - fRight -= fIncrementX; - fTop += fIncrementY; - fBottom -= fIncrementY; + fWidth -= fIncrementX; + fHeight -= fIncrementY; // create matrix - const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom); + const basegfx::B2DRange aRect(0, 0, fWidth, fHeight); impAppendMatrix(rMatrices, aRect); } } @@ -574,6 +496,8 @@ namespace drawinglayer double fTargetOffsetX(rTargetRange.getMinX()); double fTargetOffsetY(rTargetRange.getMinY()); + fAngle = -fAngle; + // add object expansion if(0.0 != fAngle) { diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx index 0e103ad385c9..4257faeee571 100644 --- a/drawinglayer/source/texture/texture3d.cxx +++ b/drawinglayer/source/texture/texture3d.cxx @@ -198,7 +198,7 @@ namespace drawinglayer { const attribute::FillHatchAttribute& rHatch(rPrimitive.getHatch()); const basegfx::B2DRange aOutlineRange(0.0, 0.0, rPrimitive.getTextureSize().getX(), rPrimitive.getTextureSize().getY()); - const double fAngleA(-rHatch.getAngle()); + const double fAngleA(rHatch.getAngle()); maColor = rHatch.getColor(); mbFillBackground = rHatch.isFillBackground(); mp0 = new GeoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA); |