41 :
meStyle (css::awt::GradientStyle_LINEAR)
90 const Color& rStartColor,
const Color& rEndColor )
205 if(
GetStyle() == css::awt::GradientStyle_LINEAR ||
GetStyle() == css::awt::GradientStyle_AXIAL )
208 const double fWidth = aRect.
GetWidth();
209 const double fHeight = aRect.
GetHeight();
210 double fDX = fWidth * fabs( cos( fAngle ) ) +
211 fHeight * fabs( sin( fAngle ) );
212 double fDY = fHeight * fabs( cos( fAngle ) ) +
213 fWidth * fabs( sin( fAngle ) );
214 fDX = (fDX - fWidth) * 0.5 + 0.5;
215 fDY = (fDY - fHeight) * 0.5 + 0.5;
226 if(
GetStyle() == css::awt::GradientStyle_SQUARE ||
GetStyle() == css::awt::GradientStyle_RECT )
229 const double fWidth = aRect.
GetWidth();
230 const double fHeight = aRect.
GetHeight();
231 double fDX = fWidth * fabs( cos( fAngle ) ) + fHeight * fabs( sin( fAngle ) );
232 double fDY = fHeight * fabs( cos( fAngle ) ) + fWidth * fabs( sin( fAngle ) );
234 fDX = ( fDX - fWidth ) * 0.5 + 0.5;
235 fDY = ( fDY - fHeight ) * 0.5 + 0.5;
245 if(
GetStyle() == css::awt::GradientStyle_RADIAL )
251 else if(
GetStyle() == css::awt::GradientStyle_ELLIPTICAL )
263 rCenter =
Point( aRect.
Left() + nZWidth, aRect.
Top() + nZHeight );
285 aStartCol =
Color(cStartLum, cStartLum, cStartLum);
286 aEndCol =
Color(cEndLum, cEndLum, cEndLum);
327 if (
GetStyle() == css::awt::GradientStyle_LINEAR ||
GetStyle() == css::awt::GradientStyle_AXIAL)
343 if (
GetStyle() == css::awt::GradientStyle_LINEAR ||
GetStyle() == css::awt::GradientStyle_AXIAL)
369 bool bLinear = (
GetStyle() == css::awt::GradientStyle_LINEAR);
393 nStartRed = (nStartRed * nFactor) / 100;
394 nStartGreen = (nStartGreen * nFactor) / 100;
395 nStartBlue = (nStartBlue * nFactor) / 100;
397 nEndRed = (nEndRed * nFactor) / 100;
398 nEndGreen = (nEndGreen * nFactor) / 100;
399 nEndBlue = (nEndBlue * nFactor) / 100;
404 std::swap( nStartRed, nEndRed );
405 std::swap( nStartGreen, nEndGreen );
406 std::swap( nStartBlue, nEndBlue );
418 nRed =
static_cast<sal_uInt8>(nStartRed);
419 nGreen =
static_cast<sal_uInt8>(nStartGreen);
420 nBlue =
static_cast<sal_uInt8>(nStartBlue);
426 aPoly[0] = aBorderRect.
TopLeft();
430 aPoly.
Rotate( aCenter, nAngle );
436 aBorderRect = aMirrorRect;
439 aPoly[0] = aBorderRect.
TopLeft();
443 aPoly.
Rotate( aCenter, nAngle );
452 tools::Long nAbsRedSteps = std::abs( nEndRed - nStartRed );
453 tools::Long nAbsGreenSteps = std::abs( nEndGreen - nStartGreen );
454 tools::Long nAbsBlueSteps = std::abs( nEndBlue - nStartBlue );
455 tools::Long nMaxColorSteps = std::max( nAbsRedSteps , nAbsGreenSteps );
456 nMaxColorSteps = std::max( nMaxColorSteps, nAbsBlueSteps );
457 tools::Long nSteps = std::min( nStepCount, nMaxColorSteps );
463 double fScanInc =
static_cast<double>(aRect.
GetHeight()) /
static_cast<double>(nSteps);
464 double fGradientLine =
static_cast<double>(aRect.
Top());
465 double fMirrorGradientLine =
static_cast<double>(aMirrorRect.
Bottom());
467 const double fStepsMinus1 =
static_cast<double>(nSteps) - 1.0;
475 double fAlpha =
static_cast<double>(
i) / fStepsMinus1;
476 double fTempColor =
static_cast<double>(nStartRed) * (1.0-fAlpha) +
static_cast<double>(nEndRed) * fAlpha;
478 fTempColor =
static_cast<double>(nStartGreen) * (1.0-fAlpha) +
static_cast<double>(nEndGreen) * fAlpha;
480 fTempColor =
static_cast<double>(nStartBlue) * (1.0-fAlpha) +
static_cast<double>(nEndBlue) * fAlpha;
486 aRect.
SetTop(
static_cast<tools::Long>( fGradientLine +
static_cast<double>(
i) * fScanInc ) );
487 aRect.
SetBottom(
static_cast<tools::Long>( fGradientLine + (
static_cast<double>(
i) + 1.0 ) * fScanInc ) );
492 aPoly.
Rotate( aCenter, nAngle );
498 aMirrorRect.
SetBottom(
static_cast<tools::Long>( fMirrorGradientLine -
static_cast<double>(
i) * fScanInc ) );
499 aMirrorRect.
SetTop(
static_cast<tools::Long>( fMirrorGradientLine - (
static_cast<double>(
i) + 1.0)* fScanInc ) );
500 aPoly[0] = aMirrorRect.
TopLeft();
504 aPoly.
Rotate( aCenter, nAngle );
519 aRect.
SetTop(
static_cast<tools::Long>( fGradientLine +
static_cast<double>(nSteps) * fScanInc ) );
520 aRect.
SetBottom(
static_cast<tools::Long>( fMirrorGradientLine -
static_cast<double>(nSteps) * fScanInc ) );
525 aPoly.
Rotate( aCenter, nAngle );
543 std::optional<tools::PolyPolygon> xPolyPoly;
570 if (nTempSteps > nCalcSteps)
571 nCalcSteps = nTempSteps;
573 nTempSteps = std::abs( nBlueSteps );
575 if (nTempSteps > nCalcSteps)
576 nCalcSteps = nTempSteps;
578 if (nCalcSteps < nSteps)
586 double fScanLeft = aRect.
Left();
587 double fScanTop = aRect.
Top();
588 double fScanRight = aRect.
Right();
589 double fScanBottom = aRect.
Bottom();
590 double fScanIncX =
static_cast<double>(aRect.
GetWidth()) /
static_cast<double>(nSteps) * 0.5;
591 double fScanIncY =
static_cast<double>(aRect.
GetHeight()) /
static_cast<double>(nSteps) * 0.5;
596 if (
GetStyle() != css::awt::GradientStyle_SQUARE)
598 fScanIncY = std::min( fScanIncY, fScanIncX );
599 fScanIncX = fScanIncY;
602 bool bPaintLastPolygon(
false );
607 xPolyPoly->Insert( aPoly );
608 xPolyPoly->Insert( aPoly );
614 fScanLeft += fScanIncX;
616 fScanTop += fScanIncY;
618 fScanRight -= fScanIncX;
620 fScanBottom -= fScanIncY;
626 if (
GetStyle() == css::awt::GradientStyle_RADIAL ||
GetStyle() == css::awt::GradientStyle_ELLIPTICAL)
634 const tools::Long nStepIndex = ( xPolyPoly ?
i : (
i + 1 ) );
639 bPaintLastPolygon =
true;
641 xPolyPoly->Replace( xPolyPoly->GetObject( 1 ), 0 );
642 xPolyPoly->Replace( aPoly, 1 );
664 if( bPaintLastPolygon )
sal_uInt8 GetLuminance() const
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
css::awt::GradientStyle meStyle
sal_uInt16 mnIntensityEnd
Impl(const Impl &rImplGradient)
sal_uInt16 mnIntensityStart
bool operator==(const Impl &rImpl_Gradient) const
sal_uInt16 GetStartIntensity() const
void SetStyle(css::awt::GradientStyle eStyle)
void SetOfsX(sal_uInt16 nOfsX)
void DrawLinearGradientToMetafile(tools::Rectangle const &rRect, GDIMetaFile &rMetaFile) const
Degree10 GetAngle() const
sal_uInt16 GetEndIntensity() const
void SetStartIntensity(sal_uInt16 nIntens)
void AddGradientActions(tools::Rectangle const &rRect, GDIMetaFile &rMetaFile)
bool operator==(const Gradient &rGradient) const
sal_uInt16 GetOfsX() const
Gradient & operator=(const Gradient &rGradient)
sal_uInt16 GetBorder() const
const Color & GetEndColor() const
sal_uInt16 GetOfsY() const
void DrawComplexGradientToMetafile(tools::Rectangle const &rRect, GDIMetaFile &rMetaFile) const
void SetBorder(sal_uInt16 nBorder)
tools::Long GetMetafileSteps(tools::Rectangle const &rRect) const
const Color & GetStartColor() const
void SetStartColor(const Color &rColor)
void SetSteps(sal_uInt16 nSteps)
css::awt::GradientStyle GetStyle() const
sal_uInt16 GetSteps() const
::o3tl::cow_wrapper< Impl > mpImplGradient
void GetBoundRect(const tools::Rectangle &rRect, tools::Rectangle &rBoundRect, Point &rCenter) const
void SetOfsY(sal_uInt16 nOfsY)
void SetAngle(Degree10 nAngle)
void SetEndColor(const Color &rColor)
void SetEndIntensity(sal_uInt16 nIntens)
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
const sal_uInt32 GRADIENT_DEFAULT_STEPCOUNT
static sal_uInt8 GetGradientColorValue(tools::Long nValue)
tools::Long const nBorder