summaryrefslogtreecommitdiff
path: root/drawinglayer/source
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-08-23 10:37:58 +0000
committerArmin Le Grand <alg@apache.org>2012-08-23 10:37:58 +0000
commitbcf4fd2f0f1825ee63e543f251722e45f6b851d7 (patch)
treea503d1c714ea4017fe62769a5113a1f0d24ea85a /drawinglayer/source
parent78a2ef14fff4777df4300aa1f1eff593b1b7a84d (diff)
#120616# Corrected SVG gradient primitive and it's decomposition
Notes
Notes: merged as: 99501a839f6d777c24bc9210787fd14dc3aad67d
Diffstat (limited to 'drawinglayer/source')
-rw-r--r--drawinglayer/source/primitive2d/svggradientprimitive2d.cxx81
1 files changed, 59 insertions, 22 deletions
diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
index acb696a678a9..510500beee0b 100644
--- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
@@ -288,6 +288,7 @@ namespace drawinglayer
const basegfx::B2DPolyPolygon& rPolyPolygon,
const SvgGradientEntryVector& rGradientEntries,
const basegfx::B2DPoint& rStart,
+ bool bUseUnitCoordinates,
SpreadMethod aSpreadMethod)
: maPolyPolygon(rPolyPolygon),
maGradientEntries(rGradientEntries),
@@ -296,7 +297,8 @@ namespace drawinglayer
mbPreconditionsChecked(false),
mbCreatesContent(false),
mbSingleEntry(false),
- mbFullyOpaque(true)
+ mbFullyOpaque(true),
+ mbUseUnitCoordinates(bUseUnitCoordinates)
{
}
@@ -307,6 +309,7 @@ namespace drawinglayer
return (getPolyPolygon() == rCompare.getPolyPolygon()
&& getGradientEntries() == rCompare.getGradientEntries()
&& getStart() == rCompare.getStart()
+ && getUseUnitCoordinates() == rCompare.getUseUnitCoordinates()
&& getSpreadMethod() == rCompare.getSpreadMethod());
}
@@ -398,20 +401,37 @@ namespace drawinglayer
basegfx::tools::createScaleTranslateB2DHomMatrix(
fPolyWidth, fPolyHeight,
aPolyRange.getMinX(), aPolyRange.getMinY()));
-
- // get start, end in object coordinates
- const basegfx::B2DPoint aStart(aObjectTransform * getStart());
- const basegfx::B2DPoint aEnd(aObjectTransform * getEnd());
-
- // create transform from unit vector [0.0 .. 1.0] along the X-Axis to given
- // gradient vector in object coordinates defined by Start, End
- const basegfx::B2DVector aVector(aEnd - aStart);
- const double fVectorLength(aVector.getLength());
basegfx::B2DHomMatrix aUnitGradientToObject;
+ static bool bInterpretAbsolute(true);
- aUnitGradientToObject.scale(fVectorLength, 1.0);
- aUnitGradientToObject.rotate(atan2(aVector.getY(), aVector.getX()));
- aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
+ if(getUseUnitCoordinates())
+ {
+ // interpret in unit coordinate system -> object aspect ratio will scale result
+ // create unit transform from unit vector [0.0 .. 1.0] along the X-Axis to given
+ // gradient vector defined by Start,End
+ const basegfx::B2DVector aVector(getEnd() - getStart());
+ const double fVectorLength(aVector.getLength());
+ basegfx::B2DHomMatrix aUnitGradientToGradient;
+
+ aUnitGradientToGradient.scale(fVectorLength, 1.0);
+ aUnitGradientToGradient.rotate(atan2(aVector.getY(), aVector.getX()));
+ aUnitGradientToGradient.translate(getStart().getX(), getStart().getY());
+
+ // create full transform from unit gradient coordinates to object coordinates
+ // including the SvgGradient transformation
+ aUnitGradientToObject = aObjectTransform * aUnitGradientToGradient;
+ }
+ else
+ {
+ // interpret in object coordinate system -> object aspect ratio will not scale result
+ const basegfx::B2DPoint aStart(aObjectTransform * getStart());
+ const basegfx::B2DPoint aEnd(aObjectTransform * getEnd());
+ const basegfx::B2DVector aVector(aEnd - aStart);
+
+ aUnitGradientToObject.scale(aVector.getLength(), 1.0);
+ aUnitGradientToObject.rotate(atan2(aVector.getY(), aVector.getX()));
+ aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
+ }
// create inverse from it
basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
@@ -535,9 +555,10 @@ namespace drawinglayer
const SvgGradientEntryVector& rGradientEntries,
const basegfx::B2DPoint& rStart,
const basegfx::B2DPoint& rEnd,
+ bool bUseUnitCoordinates,
SpreadMethod aSpreadMethod)
: BufferedDecompositionPrimitive2D(),
- SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, aSpreadMethod),
+ SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates, aSpreadMethod),
maEnd(rEnd)
{
}
@@ -715,16 +736,31 @@ namespace drawinglayer
basegfx::tools::createScaleTranslateB2DHomMatrix(
fPolyWidth, fPolyHeight,
aPolyRange.getMinX(), aPolyRange.getMinY()));
+ basegfx::B2DHomMatrix aUnitGradientToObject;
+ static bool bInterpretAbsolute(true);
- // create unit transform from unit vector to given linear gradient vector
- basegfx::B2DHomMatrix aUnitGradientToGradient;
+ if(getUseUnitCoordinates())
+ {
+ // interpret in unit coordinate system -> object aspect ratio will scale result
+ // create unit transform from unit vector to given linear gradient vector
+ basegfx::B2DHomMatrix aUnitGradientToGradient;
- aUnitGradientToGradient.scale(getRadius(), getRadius());
- aUnitGradientToGradient.translate(getStart().getX(), getStart().getY());
+ aUnitGradientToGradient.scale(getRadius(), getRadius());
+ aUnitGradientToGradient.translate(getStart().getX(), getStart().getY());
- // create full transform from unit gradient coordinates to object coordinates
- // including the SvgGradient transformation
- basegfx::B2DHomMatrix aUnitGradientToObject(aObjectTransform * aUnitGradientToGradient);
+ // create full transform from unit gradient coordinates to object coordinates
+ // including the SvgGradient transformation
+ aUnitGradientToObject = aObjectTransform * aUnitGradientToGradient;
+ }
+ else
+ {
+ // interpret in object coordinate system -> object aspect ratio will not scale result
+ const double fRadius((aObjectTransform * basegfx::B2DVector(getRadius(), 0.0)).getLength());
+ const basegfx::B2DPoint aStart(aObjectTransform * getStart());
+
+ aUnitGradientToObject.scale(fRadius, fRadius);
+ aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
+ }
// create inverse from it
basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
@@ -797,10 +833,11 @@ namespace drawinglayer
const SvgGradientEntryVector& rGradientEntries,
const basegfx::B2DPoint& rStart,
double fRadius,
+ bool bUseUnitCoordinates,
SpreadMethod aSpreadMethod,
const basegfx::B2DPoint* pFocal)
: BufferedDecompositionPrimitive2D(),
- SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, aSpreadMethod),
+ SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates, aSpreadMethod),
mfRadius(fRadius),
maFocal(rStart),
maFocalVector(0.0, 0.0),