Thesedefinitionsarepackedinastd::vector<ColorStop>ColorStops, seetypedefbelow.
*/ class BASEGFX_DLLPUBLIC BColorStop
{ private: // offset in the range of [0.0 .. 1.0] double mfStopOffset;
// RGB color of ColorStop entry
BColor maStopColor;
public: // constructor - defaults are needed to have a default constructor // e.g. for usage in std::vector::insert (even when only reducing) // ensure [0.0 .. 1.0] range for mfStopOffset
BColorStop(double fStopOffset = 0.0, const BColor& rStopColor = BColor())
: mfStopOffset(fStopOffset)
, maStopColor(rStopColor)
{ // NOTE: I originally *corrected* mfStopOffset here by using // mfStopOffset(std::max(0.0, std::min(fOffset, 1.0))) // While that is formally correct, it moves an invalid // entry to 0.0 or 1.0, thus creating additional wrong // Start/EndColor entries. That may then 'overlay' the // correct entry when corrections are applied to the // vector of entries (see sortAndCorrectColorStops) // which leads to getting the wanted Start/EndColor // to be factically deleted, what is an error.
}
// constructor with two colors to explicitly create a // BColorStops for StartColor @0.0 & EndColor @1.0
BColorStops(const BColor& rStart, const BColor& rEnd);
// helper data struct to support buffering entries in // gradient texture mapping, see usages for more info struct BColorStopRange
{
basegfx::BColor maColorStart;
basegfx::BColor maColorEnd; double mfOffsetStart; double mfOffsetEnd;
/* Helper to grep the correct ColorStop out of ColorStopsandinterpolateasneededforgiven relativevalueinfPositionintherangeof[0.0..1.0]. Italsotakescareofevtl.givenRequestedSteps.
*/
BColor getInterpolatedBColor(double fPosition, sal_uInt32 nRequestedSteps,
BColorStopRange& rLastColorStopRange) const;
/* Tooling method that allows to replace the StartColor in a vectorofColorStops.Avectorin'orderedstate'isexpected, soyoumayuse/haveusedsortAndCorrect. Thismethodisforconvenience&backwardscompatibility,please thinkabouthandlingmulti-coloredgradientsdirectly.
*/ void replaceStartColor(const BColor& rStart);
/* Tooling method that allows to replace the EndColor in a vectorofColorStops.Avectorin'orderedstate'isexpected, soyoumayuse/haveusedsortAndCorrect. Thismethodisforconvenience&backwardscompatibility,please thinkabouthandlingmulti-coloredgradientsdirectly.
*/ void replaceEndColor(const BColor& rEnd);
/* Tooling method to linearly blend the Colors contained in agivenColorStopvectoragainstagivenColorusingthe givenintensityvalues. TheintensityvaluesfStartIntensity,fEndIntensityare intherangeof[0.0..1.0]anddescribehowmuchthe blendissupposedtobedoneatthestartcolorposition andtheendcolorpositionrespectively,where0.0means tofullyusethegivenBlendColor,1.0meanstonotchange theexistingcolorintheColorStop. EverycolorentryinthegivenColorStopisblended relativetoit'sStopPosition,interpolatingthe givenintensitieswiththerange[0.0..1.0]todoso.
*/ void blendToIntensity(double fStartIntensity, double fEndIntensity, const BColor& rBlendColor);
/* Tooling method to guarantee sort and correctness for thegivenColorStopsvector. Avectorfulfillingtheseconditionsiscalledtobe in'orderedstate'.
// check if we need last-ColorStop-correction. This returns true if the last // two ColorStops have the same offset but different Colors. In that case the // tessellation for gradients does have to create an extra ending/closing entry bool checkPenultimate() const;
/* Tooling method to check if a ColorStop vector is defined byasinglecolor.Itreturnstrueifthisisthecase. Iftrueisreturned,rSingleColorcontainsthatsingle colorforconvenience. NOTE:IfnoColorStopisdefined,afallbacktoBColor-default (whichisblack)andtruewillbereturned
*/ bool isSingleColor(BColor& rSingleColor) const;
/* Tooling method to reverse ColorStops, including offsets. Whenalsomirroringoffsetsavalidsortkeepsvalid.
*/ void reverseColorStops();
// createSpaceAtStart creates fOffset space at start by // translating/scaling all entries to the right void createSpaceAtStart(double fOffset);
// removeSpaceAtStart removes fOffset space from start by // translating/scaling entries more or equal to fOffset // to the left. Entries less than fOffset will be removed void removeSpaceAtStart(double fOffset);
// try to detect if an empty/no-color-change area exists // at the start and return offset to it. Returns 0.0 if not. double detectPossibleOffsetAtStart() const;
// returns true if the color stops are symmetrical in color and offset, otherwise false. bool isSymmetrical() const; // assume that the color stops represent an Axial gradient // and replace with gradient stops to represent the same // gradient as linear gradient void doApplyAxial();
// apply Steps as 'hard' color stops void doApplySteps(sal_uInt16 nStepCount);
// Tooling to handle // - border correction/integration // - apply StartStopIntensity to color stops // - convert type from 'axial' to linear // - apply Steps as 'hard' color stops void tryToRecreateBorder(basegfx::BColorStops* pAssociatedTransparencyStops = nullptr); void tryToApplyBorder(); void tryToApplyStartEndIntensity();
// If a linear gradient is symmetrical it is converted to an axial gradient. // Does nothing in other cases and for other gradient types. void tryToConvertToAxial(); void tryToApplyAxial(); void tryToApplySteps();
};
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.