Kaydet (Commit) 888e6450 authored tarafından Armin Le Grand's avatar Armin Le Grand

#120604# corrected 3d gradients, adapted basegfx to be smarter in some areas

üst 377fc9b9
...@@ -138,22 +138,20 @@ namespace basegfx ...@@ -138,22 +138,20 @@ namespace basegfx
inline BPixel minimum(const BPixel& rTupA, const BPixel& rTupB) inline BPixel minimum(const BPixel& rTupA, const BPixel& rTupB)
{ {
BPixel aMin( return BPixel(
(rTupB.getRed() < rTupA.getRed()) ? rTupB.getRed() : rTupA.getRed(), std::min(rTupB.getRed(), rTupA.getRed()),
(rTupB.getGreen() < rTupA.getGreen()) ? rTupB.getGreen() : rTupA.getGreen(), std::min(rTupB.getGreen(), rTupA.getGreen()),
(rTupB.getBlue() < rTupA.getBlue()) ? rTupB.getBlue() : rTupA.getBlue(), std::min(rTupB.getBlue(), rTupA.getBlue()),
(rTupB.getOpacity() < rTupA.getOpacity()) ? rTupB.getOpacity() : rTupA.getOpacity()); std::min(rTupB.getOpacity(), rTupA.getOpacity()));
return aMin;
} }
inline BPixel maximum(const BPixel& rTupA, const BPixel& rTupB) inline BPixel maximum(const BPixel& rTupA, const BPixel& rTupB)
{ {
BPixel aMax( return BPixel(
(rTupB.getRed() > rTupA.getRed()) ? rTupB.getRed() : rTupA.getRed(), std::max(rTupB.getRed(), rTupA.getRed()),
(rTupB.getGreen() > rTupA.getGreen()) ? rTupB.getGreen() : rTupA.getGreen(), std::max(rTupB.getGreen(), rTupA.getGreen()),
(rTupB.getBlue() > rTupA.getBlue()) ? rTupB.getBlue() : rTupA.getBlue(), std::max(rTupB.getBlue(), rTupA.getBlue()),
(rTupB.getOpacity() > rTupA.getOpacity()) ? rTupB.getOpacity() : rTupA.getOpacity()); std::max(rTupB.getOpacity(), rTupA.getOpacity()));
return aMax;
} }
inline BPixel interpolate(const BPixel& rOld1, const BPixel& rOld2, double t) inline BPixel interpolate(const BPixel& rOld1, const BPixel& rOld2, double t)
...@@ -174,6 +172,7 @@ namespace basegfx ...@@ -174,6 +172,7 @@ namespace basegfx
{ {
const sal_uInt32 nFactor(fround(256.0 * t)); const sal_uInt32 nFactor(fround(256.0 * t));
const sal_uInt32 nNegFac(256L - nFactor); const sal_uInt32 nNegFac(256L - nFactor);
return BPixel( return BPixel(
(sal_uInt8)(((sal_uInt32)rOld1.getRed() * nNegFac + (sal_uInt32)rOld2.getRed() * nFactor) >> 8L), (sal_uInt8)(((sal_uInt32)rOld1.getRed() * nNegFac + (sal_uInt32)rOld2.getRed() * nFactor) >> 8L),
(sal_uInt8)(((sal_uInt32)rOld1.getGreen() * nNegFac + (sal_uInt32)rOld2.getGreen() * nFactor) >> 8L), (sal_uInt8)(((sal_uInt32)rOld1.getGreen() * nNegFac + (sal_uInt32)rOld2.getGreen() * nFactor) >> 8L),
...@@ -184,34 +183,20 @@ namespace basegfx ...@@ -184,34 +183,20 @@ namespace basegfx
inline BPixel average(const BPixel& rOld1, const BPixel& rOld2) inline BPixel average(const BPixel& rOld1, const BPixel& rOld2)
{ {
if(rOld1 == rOld2) return BPixel(
{ rOld1.getRed() == rOld2.getRed() ? rOld1.getRed() : (sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed()) >> 1L),
return rOld1; rOld1.getGreen() == rOld2.getGreen() ? rOld1.getGreen() : (sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen()) >> 1L),
} rOld1.getBlue() == rOld2.getBlue() ? rOld1.getBlue() : (sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue()) >> 1L),
else rOld1.getOpacity() == rOld2.getOpacity() ? rOld1.getOpacity() : (sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity()) >> 1L));
{
return BPixel(
(sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed()) >> 1L),
(sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen()) >> 1L),
(sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue()) >> 1L),
(sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity()) >> 1L));
}
} }
inline BPixel average(const BPixel& rOld1, const BPixel& rOld2, const BPixel& rOld3) inline BPixel average(const BPixel& rOld1, const BPixel& rOld2, const BPixel& rOld3)
{ {
if(rOld1 == rOld2 && rOld2 == rOld3) return BPixel(
{ (rOld1.getRed() == rOld2.getRed() && rOld2.getRed() == rOld3.getRed()) ? rOld1.getRed() : (sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed() + (sal_uInt32)rOld3.getRed()) / 3L),
return rOld1; (rOld1.getGreen() == rOld2.getGreen() && rOld2.getGreen() == rOld3.getGreen()) ? rOld1.getGreen() : (sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen() + (sal_uInt32)rOld3.getGreen()) / 3L),
} (rOld1.getBlue() == rOld2.getBlue() && rOld2.getBlue() == rOld3.getBlue()) ? rOld1.getBlue() : (sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue() + (sal_uInt32)rOld3.getBlue()) / 3L),
else (rOld1.getOpacity() == rOld2.getOpacity() && rOld2.getOpacity() == rOld3.getOpacity()) ? rOld1.getOpacity() : (sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity() + (sal_uInt32)rOld3.getOpacity()) / 3L));
{
return BPixel(
(sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed() + (sal_uInt32)rOld3.getRed()) / 3L),
(sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen() + (sal_uInt32)rOld3.getGreen()) / 3L),
(sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue() + (sal_uInt32)rOld3.getBlue()) / 3L),
(sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity() + (sal_uInt32)rOld3.getOpacity()) / 3L));
}
} }
} // end of namespace basegfx } // end of namespace basegfx
......
...@@ -48,13 +48,17 @@ namespace basegfx ...@@ -48,13 +48,17 @@ namespace basegfx
::basegfx::B2DTuple maTuple; ::basegfx::B2DTuple maTuple;
/// This Member holds the homogenous part of the point /// This Member holds the homogenous part of the point
double mfW; double mfW;
/** Test if this homogen point does have a homogenous part /** Test if this homogen point does have a homogenous part
@return Returns true if this point has no homogenous part @return Returns true if this point has no homogenous part
*/ */
bool implIsHomogenized() const; inline bool implIsHomogenized() const
{
const double fOne(1.0);
return ::basegfx::fTools::equal(fOne, mfW);
}
/** Remove homogenous part of this Point /** Remove homogenous part of this Point
...@@ -74,7 +78,11 @@ namespace basegfx ...@@ -74,7 +78,11 @@ namespace basegfx
the homogenous part of a homogenous point does from a mathematical the homogenous part of a homogenous point does from a mathematical
point of view not change the point at all. point of view not change the point at all.
*/ */
void implTestAndHomogenize() const; inline void implTestAndHomogenize() const
{
if(!implIsHomogenized())
((B2DHomPoint*)this)->implHomogenize();
}
public: public:
/** Create a homogen point /** Create a homogen point
...@@ -134,7 +142,11 @@ namespace basegfx ...@@ -134,7 +142,11 @@ namespace basegfx
@attention Even when this method is const it may change all @attention Even when this method is const it may change all
members of this instance. members of this instance.
*/ */
B2DPoint getB2DPoint() const; inline B2DPoint getB2DPoint() const
{
implTestAndHomogenize();
return B2DPoint(maTuple.getX(), maTuple.getY());
}
/** Get X-coordinate /** Get X-coordinate
...@@ -144,7 +156,11 @@ namespace basegfx ...@@ -144,7 +156,11 @@ namespace basegfx
@attention Even when this method is const it may change all @attention Even when this method is const it may change all
members of this instance. members of this instance.
*/ */
double getX() const; inline double getX() const
{
implTestAndHomogenize();
return maTuple.getX();
}
/** Get Y-coordinate /** Get Y-coordinate
...@@ -154,7 +170,11 @@ namespace basegfx ...@@ -154,7 +170,11 @@ namespace basegfx
@attention Even when this method is const it may change all @attention Even when this method is const it may change all
members of this instance. members of this instance.
*/ */
double getY() const; inline double getY() const
{
implTestAndHomogenize();
return maTuple.getY();
}
/** Set X-coordinate of the homogen point. /** Set X-coordinate of the homogen point.
...@@ -164,7 +184,10 @@ namespace basegfx ...@@ -164,7 +184,10 @@ namespace basegfx
@param fX @param fX
The to-be-set X-coordinate without homogenous part. The to-be-set X-coordinate without homogenous part.
*/ */
void setX(double fX); inline void setX(double fX)
{
maTuple.setX(implIsHomogenized() ? fX : fX * mfW );
}
/** Set Y-coordinate of the homogen point. /** Set Y-coordinate of the homogen point.
...@@ -174,58 +197,183 @@ namespace basegfx ...@@ -174,58 +197,183 @@ namespace basegfx
@param fY @param fY
The to-be-set Y-coordinate without homogenous part. The to-be-set Y-coordinate without homogenous part.
*/ */
void setY(double fY); inline void setY(double fY)
{
maTuple.setY(implIsHomogenized() ? fY : fY * mfW );
}
// operators // operators
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
B2DHomPoint& operator+=( const B2DHomPoint& rPnt ); inline B2DHomPoint& operator+=( const B2DHomPoint& rPnt )
{
maTuple.setX(getX() * rPnt.mfW + rPnt.getX() * mfW);
maTuple.setY(getY() * rPnt.mfW + rPnt.getY() * mfW);
mfW = mfW * rPnt.mfW;
B2DHomPoint& operator-=( const B2DHomPoint& rPnt ); return *this;
}
B2DHomPoint& operator*=(double t); inline B2DHomPoint& operator-=( const B2DHomPoint& rPnt )
{
maTuple.setX(getX() * rPnt.mfW - rPnt.getX() * mfW);
maTuple.setY(getY() * rPnt.mfW - rPnt.getY() * mfW);
mfW = mfW * rPnt.mfW;
B2DHomPoint& operator*=( const B2DHomMatrix& rMat ); return *this;
}
B2DHomPoint& operator/=(double t);
B2DHomPoint& operator-(void); inline B2DHomPoint& operator*=(double t)
{
if(!::basegfx::fTools::equalZero(t))
{
mfW /= t;
}
bool operator==( const B2DHomPoint& rPnt ) const; return *this;
}
bool operator!=( const B2DHomPoint& rPnt ) const; B2DHomPoint& operator*=( const B2DHomMatrix& rMat );
B2DHomPoint& operator=( const B2DHomPoint& rPnt ); inline B2DHomPoint& operator/=(double t)
{
mfW *= t;
return *this;
}
inline B2DHomPoint& operator-(void)
{
mfW = -mfW;
return *this;
}
inline bool operator==( const B2DHomPoint& rPnt ) const
{
implTestAndHomogenize();
return (maTuple == rPnt.maTuple);
}
inline bool operator!=( const B2DHomPoint& rPnt ) const
{
implTestAndHomogenize();
return (maTuple != rPnt.maTuple);
}
inline B2DHomPoint& operator=( const B2DHomPoint& rPnt )
{
maTuple = rPnt.maTuple;
mfW = rPnt.mfW;
return *this;
}
}; };
// external operators // external operators
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
B2DHomPoint minimum(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); inline B2DHomPoint minimum(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
B2DHomPoint maximum(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); return B2DHomPoint( // getX()/getY() homogenizes already
std::min(rVecB.getX(), rVecA.getX()),
std::min(rVecB.getY(), rVecA.getY()));
}
B2DHomPoint absolute(const B2DHomPoint& rVec); inline B2DHomPoint maximum(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
return B2DHomPoint( // getX()/getY() homogenizes already
std::max(rVecB.getX(), rVecA.getX()),
std::max(rVecB.getY(), rVecA.getY()));
}
B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t); inline B2DHomPoint absolute(const B2DHomPoint& rVec)
{
return B2DHomPoint( // getX()/getY() homogenizes already
fabs(rVec.getX()),
fabs(rVec.getY()));
}
B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2); inline B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t)
{
if(0.0 >= t)
{
return rOld1;
}
else if(1.0 <= t)
{
return rOld2;
}
else if(rOld1 == rOld2) // this call homogenizes already
{
return rOld1;
}
else
{
return B2DHomPoint(
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
}
}
inline B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2)
{
return B2DHomPoint( // getX()/ getY() homogenizes already
rOld1.getX() == rOld2.getX() ? rOld1.getX() : (rOld1.getX() + rOld2.getX()) * 0.5,
rOld1.getY() == rOld2.getY() ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5);
}
B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2, B2DHomPoint& rOld3); inline B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2, B2DHomPoint& rOld3)
{
return B2DHomPoint( // getX()/ getY() homogenizes already
(rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
(rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
}
B2DHomPoint operator+(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); inline B2DHomPoint operator+(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
B2DHomPoint aSum(rVecA);
aSum += rVecB;
return aSum;
}
B2DHomPoint operator-(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB); inline B2DHomPoint operator-(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
B2DHomPoint aSub(rVecA);
aSub -= rVecB;
return aSub;
}
B2DHomPoint operator*(const B2DHomPoint& rVec, double t); inline B2DHomPoint operator*(const B2DHomPoint& rVec, double t)
{
B2DHomPoint aNew(rVec);
aNew *= t;
return aNew;
}
B2DHomPoint operator*(double t, const B2DHomPoint& rVec); inline B2DHomPoint operator*(double t, const B2DHomPoint& rVec)
{
B2DHomPoint aNew(rVec);
aNew *= t;
return aNew;
}
B2DHomPoint operator*( const B2DHomMatrix& rMat, const B2DHomPoint& rPoint ); inline B2DHomPoint operator*( const B2DHomMatrix& rMat, const B2DHomPoint& rPoint )
{
B2DHomPoint aNew(rPoint);
return aNew*=rMat;
}
B2DHomPoint operator/(const B2DHomPoint& rVec, double t); inline B2DHomPoint operator/(const B2DHomPoint& rVec, double t)
{
B2DHomPoint aNew(rVec);
aNew /= t;
return aNew;
}
B2DHomPoint operator/(double t, const B2DHomPoint& rVec); inline B2DHomPoint operator/(double t, const B2DHomPoint& rVec)
{
B2DHomPoint aNew(rVec);
aNew /= t;
return aNew;
}
} // end of namespace basegfx } // end of namespace basegfx
#endif /* _BGFX_POINT_B2DHOMPOINT_HXX */ #endif /* _BGFX_POINT_B2DHOMPOINT_HXX */
...@@ -303,56 +303,65 @@ namespace basegfx ...@@ -303,56 +303,65 @@ namespace basegfx
inline B3DHomPoint minimum(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) inline B3DHomPoint minimum(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB)
{ {
B3DHomPoint aMin( return B3DHomPoint( // getX()/getY()/getZ() homogenizes already
(rVecB.getX() < rVecA.getX()) ? rVecB.getX() : rVecA.getX(), std::min(rVecB.getX(), rVecA.getX()),
(rVecB.getY() < rVecA.getY()) ? rVecB.getY() : rVecA.getY(), std::min(rVecB.getY(), rVecA.getY()),
(rVecB.getZ() < rVecA.getZ()) ? rVecB.getZ() : rVecA.getZ()); std::min(rVecB.getZ(), rVecA.getZ()));
return aMin;
} }
inline B3DHomPoint maximum(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) inline B3DHomPoint maximum(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB)
{ {
B3DHomPoint aMax( return B3DHomPoint(// getX()/getY()/getZ() homogenizes already
(rVecB.getX() > rVecA.getX()) ? rVecB.getX() : rVecA.getX(), std::max(rVecB.getX(), rVecA.getX()),
(rVecB.getY() > rVecA.getY()) ? rVecB.getY() : rVecA.getY(), std::max(rVecB.getY(), rVecA.getY()),
(rVecB.getZ() > rVecA.getZ()) ? rVecB.getZ() : rVecA.getZ()); std::max(rVecB.getZ(), rVecA.getZ()));
return aMax;
} }
inline B3DHomPoint absolute(const B3DHomPoint& rVec) inline B3DHomPoint absolute(const B3DHomPoint& rVec)
{ {
B3DHomPoint aAbs( return B3DHomPoint(// getX()/getY()/getZ() homogenizes already
(0.0 > rVec.getX()) ? -rVec.getX() : rVec.getX(), fabs(rVec.getX()),
(0.0 > rVec.getY()) ? -rVec.getY() : rVec.getY(), fabs(rVec.getY()),
(0.0 > rVec.getZ()) ? -rVec.getZ() : rVec.getZ()); fabs(rVec.getZ()));
return aAbs;
} }
inline B3DHomPoint interpolate(B3DHomPoint& rOld1, B3DHomPoint& rOld2, double t) inline B3DHomPoint interpolate(B3DHomPoint& rOld1, B3DHomPoint& rOld2, double t)
{ {
B3DHomPoint aInt( if(0.0 >= t)
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), {
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), return rOld1;
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); }
return aInt; else if(1.0 <= t)
{
return rOld2;
}
else if(rOld1 == rOld2) // this call homogenizes already
{
return rOld1;
}
else
{
return B3DHomPoint(
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(),
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ());
}
} }
inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2) inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2)
{ {
B3DHomPoint aAvg( return B3DHomPoint( // getX()/getY()/getZ() homogenizes already
(rOld1.getX() + rOld2.getX()) * 0.5, rOld1.getX() == rOld2.getX() ? rOld1.getX() : (rOld1.getX() + rOld2.getX()) * 0.5,
(rOld1.getY() + rOld2.getY()) * 0.5, rOld1.getY() == rOld2.getY() ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5,
(rOld1.getZ() + rOld2.getZ()) * 0.5); rOld1.getY() == rOld2.getY() ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5);
return aAvg;
} }
inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2, B3DHomPoint& rOld3) inline B3DHomPoint average(B3DHomPoint& rOld1, B3DHomPoint& rOld2, B3DHomPoint& rOld3)
{ {
B3DHomPoint aAvg( return B3DHomPoint( // getX()/getY()/getZ() homogenizes already
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), (rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), (rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0),
(rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); (rOld1.getZ() == rOld2.getZ() && rOld2.getZ() == rOld3.getZ()) ? rOld1.getZ() : (rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0));
return aAvg;
} }
inline B3DHomPoint operator+(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB) inline B3DHomPoint operator+(const B3DHomPoint& rVecA, const B3DHomPoint& rVecB)
......
...@@ -144,42 +144,152 @@ namespace basegfx ...@@ -144,42 +144,152 @@ namespace basegfx
protected: protected:
sal_uInt32 addColorInterpolator(const BColor& rA, const BColor& rB, double fInvYDelta) sal_uInt32 addColorInterpolator(const BColor& rA, const BColor& rB, double fInvYDelta)
{ {
B3DVector aDelta(rB.getRed() - rA.getRed(), rB.getGreen() - rA.getGreen(), rB.getBlue() - rA.getBlue()); double aDeltaRed(rB.getRed() - rA.getRed());
aDelta *= fInvYDelta;
maColorInterpolators.push_back(ip_triple(rA.getRed(), aDelta.getX(), rA.getGreen(), aDelta.getY(), rA.getBlue(), aDelta.getZ())); if(fTools::equalZero(aDeltaRed))
return (maColorInterpolators.size() - 1L); {
aDeltaRed = 0.0;
}
else
{
aDeltaRed *= fInvYDelta;
}
double aDeltaGreen(rB.getGreen() - rA.getGreen());
if(fTools::equalZero(aDeltaGreen))
{
aDeltaGreen = 0.0;
}
else
{
aDeltaGreen *= fInvYDelta;
}
double aDeltaBlue(rB.getBlue() - rA.getBlue());
if(fTools::equalZero(aDeltaBlue))
{
aDeltaBlue = 0.0;
}
else
{
aDeltaBlue *= fInvYDelta;
}
maColorInterpolators.push_back(
ip_triple(
rA.getRed(), aDeltaRed,
rA.getGreen(), aDeltaGreen,
rA.getBlue(), aDeltaBlue));
return (maColorInterpolators.size() - 1);
} }
sal_uInt32 addNormalInterpolator(const B3DVector& rA, const B3DVector& rB, double fInvYDelta) sal_uInt32 addNormalInterpolator(const B3DVector& rA, const B3DVector& rB, double fInvYDelta)
{ {
B3DVector aDelta(rB.getX() - rA.getX(), rB.getY() - rA.getY(), rB.getZ() - rA.getZ()); double aDeltaX(rB.getX() - rA.getX());
aDelta *= fInvYDelta;
maNormalInterpolators.push_back(ip_triple(rA.getX(), aDelta.getX(), rA.getY(), aDelta.getY(), rA.getZ(), aDelta.getZ())); if(fTools::equalZero(aDeltaX))
return (maNormalInterpolators.size() - 1L); {
aDeltaX = 0.0;
}
else
{
aDeltaX *= fInvYDelta;
}
double aDeltaY(rB.getY() - rA.getY());
if(fTools::equalZero(aDeltaY))
{
aDeltaY = 0.0;
}
else
{
aDeltaY *= fInvYDelta;
}
double aDeltaZ(rB.getZ() - rA.getZ());
if(fTools::equalZero(aDeltaZ))
{
aDeltaZ = 0.0;
}
else
{
aDeltaZ *= fInvYDelta;
}
maNormalInterpolators.push_back(
ip_triple(
rA.getX(), aDeltaX,
rA.getY(), aDeltaY,
rA.getZ(), aDeltaZ));
return (maNormalInterpolators.size() - 1);
} }
sal_uInt32 addTextureInterpolator(const B2DPoint& rA, const B2DPoint& rB, double fInvYDelta) sal_uInt32 addTextureInterpolator(const B2DPoint& rA, const B2DPoint& rB, double fInvYDelta)
{ {
B2DVector aDelta(rB.getX() - rA.getX(), rB.getY() - rA.getY()); double aDeltaX(rB.getX() - rA.getX());
aDelta *= fInvYDelta;
maTextureInterpolators.push_back(ip_double(rA.getX(), aDelta.getX(), rA.getY(), aDelta.getY())); if(fTools::equalZero(aDeltaX))
return (maTextureInterpolators.size() - 1L); {
aDeltaX = 0.0;
}
else
{
aDeltaX *= fInvYDelta;
}
double aDeltaY(rB.getY() - rA.getY());
if(fTools::equalZero(aDeltaY))
{
aDeltaY = 0.0;
}
else
{
aDeltaY *= fInvYDelta;
}
maTextureInterpolators.push_back(
ip_double(
rA.getX(), aDeltaX,
rA.getY(), aDeltaY));
return (maTextureInterpolators.size() - 1);
} }
sal_uInt32 addInverseTextureInterpolator(const B2DPoint& rA, const B2DPoint& rB, double fZEyeA, double fZEyeB, double fInvYDelta) sal_uInt32 addInverseTextureInterpolator(const B2DPoint& rA, const B2DPoint& rB, double fZEyeA, double fZEyeB, double fInvYDelta)
{ {
double fZDelta(fZEyeB - fZEyeA);
const double fInvZEyeA(fTools::equalZero(fZEyeA) ? fZEyeA : 1.0 / fZEyeA); const double fInvZEyeA(fTools::equalZero(fZEyeA) ? fZEyeA : 1.0 / fZEyeA);
const double fInvZEyeB(fTools::equalZero(fZEyeB) ? fZEyeB : 1.0 / fZEyeB); double fInvZEyeB(fInvZEyeA);
if(fTools::equalZero(fZDelta))
{
fZDelta = 0.0;
}
else
{
fInvZEyeB = fTools::equalZero(fZEyeB) ? fZEyeB : 1.0 / fZEyeB;
fZDelta = (fInvZEyeB - fInvZEyeA) * fInvYDelta;
}
const B2DPoint aInvA(rA * fInvZEyeA); const B2DPoint aInvA(rA * fInvZEyeA);
const B2DPoint aInvB(rB * fInvZEyeB); const B2DPoint aInvB(rB * fInvZEyeB);
double fZDelta(fInvZEyeB - fInvZEyeA); const double aDeltaX((aInvB.getX() - aInvA.getX()) * fInvYDelta);
B2DVector aDelta(aInvB.getX() - aInvA.getX(), aInvB.getY() - aInvA.getY()); const double aDeltaY((aInvB.getY() - aInvA.getY()) * fInvYDelta);
fZDelta *= fInvYDelta; maInverseTextureInterpolators.push_back(
aDelta *= fInvYDelta; ip_triple(
aInvA.getX(), aDeltaX,
aInvA.getY(), aDeltaY,
fInvZEyeA, fZDelta));
maInverseTextureInterpolators.push_back(ip_triple(aInvA.getX(), aDelta.getX(), aInvA.getY(), aDelta.getY(), fInvZEyeA, fZDelta)); return (maInverseTextureInterpolators.size() - 1);
return (maInverseTextureInterpolators.size() - 1L);
} }
void reset() void reset()
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include <sal/types.h> #include <sal/types.h>
#include <basegfx/numeric/ftools.hxx> #include <basegfx/numeric/ftools.hxx>
#undef min
#undef max
#include <algorithm>
namespace basegfx namespace basegfx
{ {
...@@ -242,50 +245,60 @@ namespace basegfx ...@@ -242,50 +245,60 @@ namespace basegfx
inline B2DTuple minimum(const B2DTuple& rTupA, const B2DTuple& rTupB) inline B2DTuple minimum(const B2DTuple& rTupA, const B2DTuple& rTupB)
{ {
B2DTuple aMin( return B2DTuple(
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::min(rTupB.getX(), rTupA.getX()),
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY()); std::min(rTupB.getY(), rTupA.getY()));
return aMin;
} }
inline B2DTuple maximum(const B2DTuple& rTupA, const B2DTuple& rTupB) inline B2DTuple maximum(const B2DTuple& rTupA, const B2DTuple& rTupB)
{ {
B2DTuple aMax( return B2DTuple(
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::max(rTupB.getX(), rTupA.getX()),
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY()); std::max(rTupB.getY(), rTupA.getY()));
return aMax;
} }
inline B2DTuple absolute(const B2DTuple& rTup) inline B2DTuple absolute(const B2DTuple& rTup)
{ {
B2DTuple aAbs( B2DTuple aAbs(
(0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(), fabs(rTup.getX()),
(0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY()); fabs(rTup.getY()));
return aAbs; return aAbs;
} }
inline B2DTuple interpolate(const B2DTuple& rOld1, const B2DTuple& rOld2, double t) inline B2DTuple interpolate(const B2DTuple& rOld1, const B2DTuple& rOld2, double t)
{ {
B2DTuple aInt( if(rOld1 == rOld2)
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), {
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()); return rOld1;
return aInt; }
else if(0.0 >= t)
{
return rOld1;
}
else if(1.0 <= t)
{
return rOld2;
}
else
{
return B2DTuple(
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
}
} }
inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2) inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2)
{ {
B2DTuple aAvg( return B2DTuple(
(rOld1.getX() + rOld2.getX()) * 0.5, rOld1.getX() == rOld2.getX() ? rOld1.getX() : (rOld1.getX() + rOld2.getX()) * 0.5,
(rOld1.getY() + rOld2.getY()) * 0.5); rOld1.getY() == rOld2.getY() ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5);
return aAvg;
} }
inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2, const B2DTuple& rOld3) inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2, const B2DTuple& rOld3)
{ {
B2DTuple aAvg( return B2DTuple(
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), (rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)); (rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
return aAvg;
} }
inline B2DTuple operator+(const B2DTuple& rTupA, const B2DTuple& rTupB) inline B2DTuple operator+(const B2DTuple& rTupA, const B2DTuple& rTupB)
......
...@@ -201,18 +201,16 @@ namespace basegfx ...@@ -201,18 +201,16 @@ namespace basegfx
inline B2I64Tuple minimum(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB) inline B2I64Tuple minimum(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB)
{ {
B2I64Tuple aMin( return B2I64Tuple(
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::min(rTupB.getX(), rTupA.getX()),
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY()); std::min(rTupB.getY(), rTupA.getY()));
return aMin;
} }
inline B2I64Tuple maximum(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB) inline B2I64Tuple maximum(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB)
{ {
B2I64Tuple aMax( return B2I64Tuple(
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::max(rTupB.getX(), rTupA.getX()),
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY()); std::max(rTupB.getY(), rTupA.getY()));
return aMax;
} }
inline B2I64Tuple absolute(const B2I64Tuple& rTup) inline B2I64Tuple absolute(const B2I64Tuple& rTup)
...@@ -223,28 +221,40 @@ namespace basegfx ...@@ -223,28 +221,40 @@ namespace basegfx
return aAbs; return aAbs;
} }
inline B2DTuple interpolate(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, double t) inline B2I64Tuple interpolate(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, double t)
{ {
B2DTuple aInt( if(rOld1 == rOld2)
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), {
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()); return rOld1;
return aInt; }
else if(0.0 >= t)
{
return rOld1;
}
else if(1.0 <= t)
{
return rOld2;
}
else
{
return B2I64Tuple(
basegfx::fround64(((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX()),
basegfx::fround64(((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()));
}
} }
inline B2DTuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2) inline B2I64Tuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2)
{ {
B2DTuple aAvg( return B2I64Tuple(
(rOld1.getX() + rOld2.getX()) * 0.5, rOld1.getX() == rOld2.getX() ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX()) * 0.5),
(rOld1.getY() + rOld2.getY()) * 0.5); rOld1.getY() == rOld2.getY() ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY()) * 0.5));
return aAvg;
} }
inline B2DTuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, const B2I64Tuple& rOld3) inline B2I64Tuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, const B2I64Tuple& rOld3)
{ {
B2DTuple aAvg( return B2I64Tuple(
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), (rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0)),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)); (rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)));
return aAvg;
} }
inline B2I64Tuple operator+(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB) inline B2I64Tuple operator+(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB)
......
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
#define _BGFX_TUPLE_B2ITUPLE_HXX #define _BGFX_TUPLE_B2ITUPLE_HXX
#include <sal/types.h> #include <sal/types.h>
#include <basegfx/numeric/ftools.hxx>
#undef min
#undef max
#include <algorithm>
namespace basegfx namespace basegfx
{ {
...@@ -173,7 +176,10 @@ namespace basegfx ...@@ -173,7 +176,10 @@ namespace basegfx
return B2ITuple(-mnX, -mnY); return B2ITuple(-mnX, -mnY);
} }
bool equalZero() const { return mnX == 0 && mnY == 0; } bool equalZero() const
{
return mnX == 0 && mnY == 0;
}
bool operator==( const B2ITuple& rTup ) const bool operator==( const B2ITuple& rTup ) const
{ {
...@@ -198,36 +204,120 @@ namespace basegfx ...@@ -198,36 +204,120 @@ namespace basegfx
// external operators // external operators
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class B2DTuple; inline B2ITuple minimum(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple minimum(const B2ITuple& rTupA, const B2ITuple& rTupB); return B2ITuple(
std::min(rTupB.getX(), rTupA.getX()),
B2ITuple maximum(const B2ITuple& rTupA, const B2ITuple& rTupB); std::min(rTupB.getY(), rTupA.getY()));
}
B2ITuple absolute(const B2ITuple& rTup); inline B2ITuple maximum(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
return B2ITuple(
std::max(rTupB.getX(), rTupA.getX()),
std::max(rTupB.getY(), rTupA.getY()));
}
B2DTuple interpolate(const B2ITuple& rOld1, const B2ITuple& rOld2, double t); inline B2ITuple absolute(const B2ITuple& rTup)
{
B2ITuple aAbs(
(0 > rTup.getX()) ? -rTup.getX() : rTup.getX(),
(0 > rTup.getY()) ? -rTup.getY() : rTup.getY());
return aAbs;
}
B2DTuple average(const B2ITuple& rOld1, const B2ITuple& rOld2); inline B2ITuple interpolate(const B2ITuple& rOld1, const B2ITuple& rOld2, double t)
{
if(rOld1 == rOld2)
{
return rOld1;
}
else if(0.0 >= t)
{
return rOld1;
}
else if(1.0 <= t)
{
return rOld2;
}
else
{
return B2ITuple(
basegfx::fround(((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX()),
basegfx::fround(((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()));
}
}
B2DTuple average(const B2ITuple& rOld1, const B2ITuple& rOld2, const B2ITuple& rOld3); inline B2ITuple average(const B2ITuple& rOld1, const B2ITuple& rOld2)
{
return B2ITuple(
rOld1.getX() == rOld2.getX() ? rOld1.getX() : basegfx::fround((rOld1.getX() + rOld2.getX()) * 0.5),
rOld1.getY() == rOld2.getY() ? rOld1.getY() : basegfx::fround((rOld1.getY() + rOld2.getY()) * 0.5));
}
B2ITuple operator+(const B2ITuple& rTupA, const B2ITuple& rTupB); inline B2ITuple average(const B2ITuple& rOld1, const B2ITuple& rOld2, const B2ITuple& rOld3)
{
return B2ITuple(
(rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : basegfx::fround((rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0)),
(rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : basegfx::fround((rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)));
}
B2ITuple operator-(const B2ITuple& rTupA, const B2ITuple& rTupB); inline B2ITuple operator+(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aSum(rTupA);
aSum += rTupB;
return aSum;
}
B2ITuple operator/(const B2ITuple& rTupA, const B2ITuple& rTupB); inline B2ITuple operator-(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aSub(rTupA);
aSub -= rTupB;
return aSub;
}
B2ITuple operator*(const B2ITuple& rTupA, const B2ITuple& rTupB); inline B2ITuple operator/(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aDiv(rTupA);
aDiv /= rTupB;
return aDiv;
}
B2ITuple operator*(const B2ITuple& rTup, sal_Int32 t); inline B2ITuple operator*(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aMul(rTupA);
aMul *= rTupB;
return aMul;
}
B2ITuple operator*(sal_Int32 t, const B2ITuple& rTup); inline B2ITuple operator*(const B2ITuple& rTup, sal_Int32 t)
{
B2ITuple aNew(rTup);
aNew *= t;
return aNew;
}
B2ITuple operator/(const B2ITuple& rTup, sal_Int32 t); inline B2ITuple operator*(sal_Int32 t, const B2ITuple& rTup)
{
B2ITuple aNew(rTup);
aNew *= t;
return aNew;
}
B2ITuple operator/(sal_Int32 t, const B2ITuple& rTup); inline B2ITuple operator/(const B2ITuple& rTup, sal_Int32 t)
{
B2ITuple aNew(rTup);
aNew /= t;
return aNew;
}
inline B2ITuple operator/(sal_Int32 t, const B2ITuple& rTup)
{
B2ITuple aNew(t, t);
B2ITuple aTmp(rTup);
aNew /= aTmp;
return aNew;
}
} // end of namespace basegfx } // end of namespace basegfx
#endif /* _BGFX_TUPLE_B2ITUPLE_HXX */ #endif /* _BGFX_TUPLE_B2ITUPLE_HXX */
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include <sal/types.h> #include <sal/types.h>
#include <basegfx/numeric/ftools.hxx> #include <basegfx/numeric/ftools.hxx>
#undef min
#undef max
#include <algorithm>
namespace basegfx namespace basegfx
{ {
...@@ -311,56 +314,66 @@ namespace basegfx ...@@ -311,56 +314,66 @@ namespace basegfx
inline B3DTuple minimum(const B3DTuple& rTupA, const B3DTuple& rTupB) inline B3DTuple minimum(const B3DTuple& rTupA, const B3DTuple& rTupB)
{ {
B3DTuple aMin( return B3DTuple(
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::min(rTupB.getX(), rTupA.getX()),
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(), std::min(rTupB.getY(), rTupA.getY()),
(rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); std::min(rTupB.getZ(), rTupA.getZ()));
return aMin;
} }
inline B3DTuple maximum(const B3DTuple& rTupA, const B3DTuple& rTupB) inline B3DTuple maximum(const B3DTuple& rTupA, const B3DTuple& rTupB)
{ {
B3DTuple aMax( return B3DTuple(
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::max(rTupB.getX(), rTupA.getX()),
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(), std::max(rTupB.getY(), rTupA.getY()),
(rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); std::max(rTupB.getZ(), rTupA.getZ()));
return aMax;
} }
inline B3DTuple absolute(const B3DTuple& rTup) inline B3DTuple absolute(const B3DTuple& rTup)
{ {
B3DTuple aAbs( B3DTuple aAbs(
(0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(), fabs(rTup.getX()),
(0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY(), fabs(rTup.getY()),
(0.0 > rTup.getZ()) ? -rTup.getZ() : rTup.getZ()); fabs(rTup.getZ()));
return aAbs; return aAbs;
} }
inline B3DTuple interpolate(const B3DTuple& rOld1, const B3DTuple& rOld2, double t) inline B3DTuple interpolate(const B3DTuple& rOld1, const B3DTuple& rOld2, double t)
{ {
B3DTuple aInt( if(rOld1 == rOld2)
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), {
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), return rOld1;
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); }
return aInt; else if(0.0 >= t)
{
return rOld1;
}
else if(1.0 <= t)
{
return rOld2;
}
else
{
return B3DTuple(
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(),
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ());
}
} }
inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2) inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2)
{ {
B3DTuple aAvg( return B3DTuple(
(rOld1.getX() + rOld2.getX()) * 0.5, rOld1.getX() == rOld2.getX() ? rOld1.getX() : (rOld1.getX() + rOld2.getX()) * 0.5,
(rOld1.getY() + rOld2.getY()) * 0.5, rOld1.getY() == rOld2.getY() ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5,
(rOld1.getZ() + rOld2.getZ()) * 0.5); rOld1.getZ() == rOld2.getZ() ? rOld1.getZ() : (rOld1.getZ() + rOld2.getZ()) * 0.5);
return aAvg;
} }
inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2, const B3DTuple& rOld3) inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2, const B3DTuple& rOld3)
{ {
B3DTuple aAvg( return B3DTuple(
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), (rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), (rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0),
(rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); (rOld1.getZ() == rOld2.getZ() && rOld2.getZ() == rOld3.getZ()) ? rOld1.getZ() : (rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0));
return aAvg;
} }
inline B3DTuple operator+(const B3DTuple& rTupA, const B3DTuple& rTupB) inline B3DTuple operator+(const B3DTuple& rTupA, const B3DTuple& rTupB)
......
...@@ -232,20 +232,18 @@ namespace basegfx ...@@ -232,20 +232,18 @@ namespace basegfx
inline B3I64Tuple minimum(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB) inline B3I64Tuple minimum(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB)
{ {
B3I64Tuple aMin( return B3I64Tuple(
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::min(rTupB.getX(), rTupA.getX()),
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(), std::min(rTupB.getY(), rTupA.getY()),
(rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); std::min(rTupB.getZ(), rTupA.getZ()));
return aMin;
} }
inline B3I64Tuple maximum(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB) inline B3I64Tuple maximum(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB)
{ {
B3I64Tuple aMax( return B3I64Tuple(
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::max(rTupB.getX(), rTupA.getX()),
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(), std::max(rTupB.getY(), rTupA.getY()),
(rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); std::max(rTupB.getZ(), rTupA.getZ()));
return aMax;
} }
inline B3I64Tuple absolute(const B3I64Tuple& rTup) inline B3I64Tuple absolute(const B3I64Tuple& rTup)
...@@ -257,31 +255,43 @@ namespace basegfx ...@@ -257,31 +255,43 @@ namespace basegfx
return aAbs; return aAbs;
} }
inline B3DTuple interpolate(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, double t) inline B3I64Tuple interpolate(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, double t)
{ {
B3DTuple aInt( if(rOld1 == rOld2)
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), {
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), return rOld1;
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); }
return aInt; else if(0.0 >= t)
{
return rOld1;
}
else if(1.0 <= t)
{
return rOld2;
}
else
{
return B3I64Tuple(
basegfx::fround64(((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX()),
basegfx::fround64(((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()),
basegfx::fround64(((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()));
}
} }
inline B3DTuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2) inline B3I64Tuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2)
{ {
B3DTuple aAvg( return B3I64Tuple(
(rOld1.getX() + rOld2.getX()) * 0.5, rOld1.getX() == rOld2.getX() ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX()) * 0.5),
(rOld1.getY() + rOld2.getY()) * 0.5, rOld1.getY() == rOld2.getY() ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY()) * 0.5),
(rOld1.getZ() + rOld2.getZ()) * 0.5); rOld1.getZ() == rOld2.getZ() ? rOld1.getZ() : basegfx::fround64((rOld1.getZ() + rOld2.getZ()) * 0.5));
return aAvg;
} }
inline B3DTuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, const B3I64Tuple& rOld3) inline B3I64Tuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, const B3I64Tuple& rOld3)
{ {
B3DTuple aAvg( return B3I64Tuple(
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), (rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0)),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), (rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)),
(rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); (rOld1.getZ() == rOld2.getZ() && rOld2.getZ() == rOld3.getZ()) ? rOld1.getZ() : basegfx::fround64((rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)));
return aAvg;
} }
inline B3I64Tuple operator+(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB) inline B3I64Tuple operator+(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB)
......
...@@ -232,20 +232,18 @@ namespace basegfx ...@@ -232,20 +232,18 @@ namespace basegfx
inline B3ITuple minimum(const B3ITuple& rTupA, const B3ITuple& rTupB) inline B3ITuple minimum(const B3ITuple& rTupA, const B3ITuple& rTupB)
{ {
B3ITuple aMin( return B3ITuple(
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::min(rTupB.getX(), rTupA.getX()),
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(), std::min(rTupB.getY(), rTupA.getY()),
(rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); std::min(rTupB.getZ(), rTupA.getZ()));
return aMin;
} }
inline B3ITuple maximum(const B3ITuple& rTupA, const B3ITuple& rTupB) inline B3ITuple maximum(const B3ITuple& rTupA, const B3ITuple& rTupB)
{ {
B3ITuple aMax( return B3ITuple(
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(), std::max(rTupB.getX(), rTupA.getX()),
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(), std::max(rTupB.getY(), rTupA.getY()),
(rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ()); std::max(rTupB.getZ(), rTupA.getZ()));
return aMax;
} }
inline B3ITuple absolute(const B3ITuple& rTup) inline B3ITuple absolute(const B3ITuple& rTup)
...@@ -257,31 +255,43 @@ namespace basegfx ...@@ -257,31 +255,43 @@ namespace basegfx
return aAbs; return aAbs;
} }
inline B3DTuple interpolate(const B3ITuple& rOld1, const B3ITuple& rOld2, double t) inline B3ITuple interpolate(const B3ITuple& rOld1, const B3ITuple& rOld2, double t)
{ {
B3DTuple aInt( if(rOld1 == rOld2)
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(), {
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(), return rOld1;
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()); }
return aInt; else if(0.0 >= t)
{
return rOld1;
}
else if(1.0 <= t)
{
return rOld2;
}
else
{
return B3ITuple(
basegfx::fround(((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX()),
basegfx::fround(((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()),
basegfx::fround(((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()));
}
} }
inline B3DTuple average(const B3ITuple& rOld1, const B3ITuple& rOld2) inline B3ITuple average(const B3ITuple& rOld1, const B3ITuple& rOld2)
{ {
B3DTuple aAvg( return B3ITuple(
(rOld1.getX() + rOld2.getX()) * 0.5, rOld1.getX() == rOld2.getX() ? rOld1.getX() : basegfx::fround((rOld1.getX() + rOld2.getX()) * 0.5),
(rOld1.getY() + rOld2.getY()) * 0.5, rOld1.getY() == rOld2.getY() ? rOld1.getY() : basegfx::fround((rOld1.getY() + rOld2.getY()) * 0.5),
(rOld1.getZ() + rOld2.getZ()) * 0.5); rOld1.getZ() == rOld2.getZ() ? rOld1.getZ() : basegfx::fround((rOld1.getZ() + rOld2.getZ()) * 0.5));
return aAvg;
} }
inline B3DTuple average(const B3ITuple& rOld1, const B3ITuple& rOld2, const B3ITuple& rOld3) inline B3ITuple average(const B3ITuple& rOld1, const B3ITuple& rOld2, const B3ITuple& rOld3)
{ {
B3DTuple aAvg( return B3ITuple(
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0), (rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : basegfx::fround((rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0)),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0), (rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getX() : basegfx::fround((rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)),
(rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)); (rOld1.getZ() == rOld2.getZ() && rOld2.getZ() == rOld3.getZ()) ? rOld1.getX() : basegfx::fround((rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)));
return aAvg;
} }
inline B3ITuple operator+(const B3ITuple& rTupA, const B3ITuple& rTupB) inline B3ITuple operator+(const B3ITuple& rTupA, const B3ITuple& rTupB)
......
...@@ -29,12 +29,6 @@ ...@@ -29,12 +29,6 @@
namespace basegfx namespace basegfx
{ {
bool B2DHomPoint::implIsHomogenized() const
{
const double fOne(1.0);
return ::basegfx::fTools::equal(fOne, mfW);
}
void B2DHomPoint::implHomogenize() void B2DHomPoint::implHomogenize()
{ {
const double fFactor(1.0 / mfW); const double fFactor(1.0 / mfW);
...@@ -43,68 +37,6 @@ namespace basegfx ...@@ -43,68 +37,6 @@ namespace basegfx
mfW = 1.0; mfW = 1.0;
} }
void B2DHomPoint::implTestAndHomogenize() const
{
if(!implIsHomogenized())
((B2DHomPoint*)this)->implHomogenize();
}
B2DPoint B2DHomPoint::getB2DPoint() const
{
implTestAndHomogenize();
return B2DPoint(maTuple.getX(), maTuple.getY());
}
double B2DHomPoint::getX() const
{
implTestAndHomogenize();
return maTuple.getX();
}
double B2DHomPoint::getY() const
{
implTestAndHomogenize();
return maTuple.getY();
}
void B2DHomPoint::setX(double fX)
{
maTuple.setX(implIsHomogenized() ? fX : fX * mfW );
}
void B2DHomPoint::setY(double fY)
{
maTuple.setY(implIsHomogenized() ? fY : fY * mfW );
}
B2DHomPoint& B2DHomPoint::operator+=( const B2DHomPoint& rPnt )
{
maTuple.setX(getX() * rPnt.mfW + rPnt.getX() * mfW);
maTuple.setY(getY() * rPnt.mfW + rPnt.getY() * mfW);
mfW = mfW * rPnt.mfW;
return *this;
}
B2DHomPoint& B2DHomPoint::operator-=( const B2DHomPoint& rPnt )
{
maTuple.setX(getX() * rPnt.mfW - rPnt.getX() * mfW);
maTuple.setY(getY() * rPnt.mfW - rPnt.getY() * mfW);
mfW = mfW * rPnt.mfW;
return *this;
}
B2DHomPoint& B2DHomPoint::operator*=(double t)
{
if(!::basegfx::fTools::equalZero(t))
{
mfW /= t;
}
return *this;
}
B2DHomPoint& B2DHomPoint::operator*=( const B2DHomMatrix& rMat ) B2DHomPoint& B2DHomPoint::operator*=( const B2DHomMatrix& rMat )
{ {
const double fTempX( rMat.get(0,0)*maTuple.getX() + const double fTempX( rMat.get(0,0)*maTuple.getX() +
...@@ -124,132 +56,6 @@ namespace basegfx ...@@ -124,132 +56,6 @@ namespace basegfx
return *this; return *this;
} }
B2DHomPoint& B2DHomPoint::operator/=(double t)
{
mfW *= t;
return *this;
}
B2DHomPoint& B2DHomPoint::operator-(void)
{
mfW = -mfW;
return *this;
}
bool B2DHomPoint::operator==( const B2DHomPoint& rPnt ) const
{
implTestAndHomogenize();
return (maTuple == rPnt.maTuple);
}
bool B2DHomPoint::operator!=( const B2DHomPoint& rPnt ) const
{
implTestAndHomogenize();
return (maTuple != rPnt.maTuple);
}
B2DHomPoint& B2DHomPoint::operator=( const B2DHomPoint& rPnt )
{
maTuple = rPnt.maTuple;
mfW = rPnt.mfW;
return *this;
}
B2DHomPoint minimum(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
B2DHomPoint aMin(
(rVecB.getX() < rVecA.getX()) ? rVecB.getX() : rVecA.getX(),
(rVecB.getY() < rVecA.getY()) ? rVecB.getY() : rVecA.getY());
return aMin;
}
B2DHomPoint maximum(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
B2DHomPoint aMax(
(rVecB.getX() > rVecA.getX()) ? rVecB.getX() : rVecA.getX(),
(rVecB.getY() > rVecA.getY()) ? rVecB.getY() : rVecA.getY());
return aMax;
}
B2DHomPoint absolute(const B2DHomPoint& rVec)
{
B2DHomPoint aAbs(
(0.0 > rVec.getX()) ? -rVec.getX() : rVec.getX(),
(0.0 > rVec.getY()) ? -rVec.getY() : rVec.getY());
return aAbs;
}
B2DHomPoint interpolate(B2DHomPoint& rOld1, B2DHomPoint& rOld2, double t)
{
B2DHomPoint aInt(
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
return aInt;
}
B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2)
{
B2DHomPoint aAvg(
(rOld1.getX() + rOld2.getX()) * 0.5,
(rOld1.getY() + rOld2.getY()) * 0.5);
return aAvg;
}
B2DHomPoint average(B2DHomPoint& rOld1, B2DHomPoint& rOld2, B2DHomPoint& rOld3)
{
B2DHomPoint aAvg(
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
return aAvg;
}
B2DHomPoint operator+(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
B2DHomPoint aSum(rVecA);
aSum += rVecB;
return aSum;
}
B2DHomPoint operator-(const B2DHomPoint& rVecA, const B2DHomPoint& rVecB)
{
B2DHomPoint aSub(rVecA);
aSub -= rVecB;
return aSub;
}
B2DHomPoint operator*(const B2DHomPoint& rVec, double t)
{
B2DHomPoint aNew(rVec);
aNew *= t;
return aNew;
}
B2DHomPoint operator*(double t, const B2DHomPoint& rVec)
{
B2DHomPoint aNew(rVec);
aNew *= t;
return aNew;
}
B2DHomPoint operator*( const B2DHomMatrix& rMat, const B2DHomPoint& rPoint )
{
B2DHomPoint aNew(rPoint);
return aNew*=rMat;
}
B2DHomPoint operator/(const B2DHomPoint& rVec, double t)
{
B2DHomPoint aNew(rVec);
aNew /= t;
return aNew;
}
B2DHomPoint operator/(double t, const B2DHomPoint& rVec)
{
B2DHomPoint aNew(rVec);
aNew /= t;
return aNew;
}
} // end of namespace basegfx } // end of namespace basegfx
// eof // eof
...@@ -362,19 +362,20 @@ namespace basegfx ...@@ -362,19 +362,20 @@ namespace basegfx
{ {
const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0) // Ignore Y, this is not needed at all for Y-Oriented gradients
{ // if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
return 0.0; // {
} // return 0.0;
// }
if(aCoor.getY() <= 0.0) if(aCoor.getY() <= 0.0)
{ {
return 0.0; return 0.0; // start value for inside
} }
if(aCoor.getY() >= 1.0) if(aCoor.getY() >= 1.0)
{ {
return 1.0; return 1.0; // end value for outside
} }
const sal_uInt32 nSteps(rGradInfo.getSteps()); const sal_uInt32 nSteps(rGradInfo.getSteps());
...@@ -391,16 +392,17 @@ namespace basegfx ...@@ -391,16 +392,17 @@ namespace basegfx
{ {
const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0) // Ignore Y, this is not needed at all for Y-Oriented gradients
{ //if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
return 0.0; //{
} // return 0.0;
//}
const double fAbsY(fabs(aCoor.getY())); const double fAbsY(fabs(aCoor.getY()));
if(fAbsY >= 1.0) if(fAbsY >= 1.0)
{ {
return 0.0; return 1.0; // use end value when outside in Y
} }
const sal_uInt32 nSteps(rGradInfo.getSteps()); const sal_uInt32 nSteps(rGradInfo.getSteps());
......
...@@ -33,117 +33,12 @@ namespace basegfx ...@@ -33,117 +33,12 @@ namespace basegfx
{ {
const B2ITuple& B2ITuple::getEmptyTuple() const B2ITuple& B2ITuple::getEmptyTuple()
{ {
return EmptyTuple::get(); return EmptyTuple::get();
} }
// external operators // external operators
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
B2ITuple minimum(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aMin(
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY());
return aMin;
}
B2ITuple maximum(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aMax(
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY());
return aMax;
}
B2ITuple absolute(const B2ITuple& rTup)
{
B2ITuple aAbs(
(0 > rTup.getX()) ? -rTup.getX() : rTup.getX(),
(0 > rTup.getY()) ? -rTup.getY() : rTup.getY());
return aAbs;
}
B2DTuple interpolate(const B2ITuple& rOld1, const B2ITuple& rOld2, double t)
{
B2DTuple aInt(
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
return aInt;
}
B2DTuple average(const B2ITuple& rOld1, const B2ITuple& rOld2)
{
B2DTuple aAvg(
(rOld1.getX() + rOld2.getX()) * 0.5,
(rOld1.getY() + rOld2.getY()) * 0.5);
return aAvg;
}
B2DTuple average(const B2ITuple& rOld1, const B2ITuple& rOld2, const B2ITuple& rOld3)
{
B2DTuple aAvg(
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
return aAvg;
}
B2ITuple operator+(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aSum(rTupA);
aSum += rTupB;
return aSum;
}
B2ITuple operator-(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aSub(rTupA);
aSub -= rTupB;
return aSub;
}
B2ITuple operator/(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aDiv(rTupA);
aDiv /= rTupB;
return aDiv;
}
B2ITuple operator*(const B2ITuple& rTupA, const B2ITuple& rTupB)
{
B2ITuple aMul(rTupA);
aMul *= rTupB;
return aMul;
}
B2ITuple operator*(const B2ITuple& rTup, sal_Int32 t)
{
B2ITuple aNew(rTup);
aNew *= t;
return aNew;
}
B2ITuple operator*(sal_Int32 t, const B2ITuple& rTup)
{
B2ITuple aNew(rTup);
aNew *= t;
return aNew;
}
B2ITuple operator/(const B2ITuple& rTup, sal_Int32 t)
{
B2ITuple aNew(rTup);
aNew /= t;
return aNew;
}
B2ITuple operator/(sal_Int32 t, const B2ITuple& rTup)
{
B2ITuple aNew(t, t);
B2ITuple aTmp(rTup);
aNew /= aTmp;
return aNew;
}
} // end of namespace basegfx } // end of namespace basegfx
// eof // eof
...@@ -164,7 +164,7 @@ namespace drawinglayer ...@@ -164,7 +164,7 @@ namespace drawinglayer
{ {
const double fScaler(basegfx::tools::getLinearGradientAlpha(rUV, maGradientInfo)); const double fScaler(basegfx::tools::getLinearGradientAlpha(rUV, maGradientInfo));
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler); rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
} }
} // end of namespace texture } // end of namespace texture
} // end of namespace drawinglayer } // end of namespace drawinglayer
...@@ -227,7 +227,7 @@ namespace drawinglayer ...@@ -227,7 +227,7 @@ namespace drawinglayer
{ {
const double fScaler(basegfx::tools::getAxialGradientAlpha(rUV, maGradientInfo)); const double fScaler(basegfx::tools::getAxialGradientAlpha(rUV, maGradientInfo));
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler); rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
} }
} // end of namespace texture } // end of namespace texture
} // end of namespace drawinglayer } // end of namespace drawinglayer
...@@ -284,7 +284,7 @@ namespace drawinglayer ...@@ -284,7 +284,7 @@ namespace drawinglayer
{ {
const double fScaler(basegfx::tools::getRadialGradientAlpha(rUV, maGradientInfo)); const double fScaler(basegfx::tools::getRadialGradientAlpha(rUV, maGradientInfo));
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler); rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
} }
} // end of namespace texture } // end of namespace texture
} // end of namespace drawinglayer } // end of namespace drawinglayer
...@@ -361,7 +361,7 @@ namespace drawinglayer ...@@ -361,7 +361,7 @@ namespace drawinglayer
{ {
const double fScaler(basegfx::tools::getEllipticalGradientAlpha(rUV, maGradientInfo)); const double fScaler(basegfx::tools::getEllipticalGradientAlpha(rUV, maGradientInfo));
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler); rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
} }
} // end of namespace texture } // end of namespace texture
} // end of namespace drawinglayer } // end of namespace drawinglayer
...@@ -420,7 +420,7 @@ namespace drawinglayer ...@@ -420,7 +420,7 @@ namespace drawinglayer
{ {
const double fScaler(basegfx::tools::getSquareGradientAlpha(rUV, maGradientInfo)); const double fScaler(basegfx::tools::getSquareGradientAlpha(rUV, maGradientInfo));
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler); rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
} }
} // end of namespace texture } // end of namespace texture
} // end of namespace drawinglayer } // end of namespace drawinglayer
...@@ -497,7 +497,7 @@ namespace drawinglayer ...@@ -497,7 +497,7 @@ namespace drawinglayer
{ {
const double fScaler(basegfx::tools::getRectangularGradientAlpha(rUV, maGradientInfo)); const double fScaler(basegfx::tools::getRectangularGradientAlpha(rUV, maGradientInfo));
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler); rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
} }
} // end of namespace texture } // end of namespace texture
} // end of namespace drawinglayer } // end of namespace drawinglayer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment