mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-27 08:36:59 +00:00
api: polsih up the composition blending
This commit is contained in:
parent
149acea6a4
commit
dfa3efdb4e
2 changed files with 8 additions and 7 deletions
12
inc/thorvg.h
12
inc/thorvg.h
|
@ -209,13 +209,13 @@ enum class BlendMethod : uint8_t
|
||||||
SoftLight, ///< The same as Overlay but with applying pure black or white does not result in pure black or white. (255 - 2 * S) * (D * D) + (2 * S * D)
|
SoftLight, ///< The same as Overlay but with applying pure black or white does not result in pure black or white. (255 - 2 * S) * (D * D) + (2 * S * D)
|
||||||
Difference, ///< Subtracts the bottom layer from the top layer or the other way around, to always get a non-negative value. (S - D) if (S > D), otherwise (D - S)
|
Difference, ///< Subtracts the bottom layer from the top layer or the other way around, to always get a non-negative value. (S - D) if (S > D), otherwise (D - S)
|
||||||
Exclusion, ///< The result is twice the product of the top and bottom layers, subtracted from their sum. S + D - (2 * S * D)
|
Exclusion, ///< The result is twice the product of the top and bottom layers, subtracted from their sum. S + D - (2 * S * D)
|
||||||
Hue, ///< Combine with HSL(Sh + Ds + Dl) then convert it to RGB.
|
Hue, ///< Combine with HSL(Sh + Ds + Dl) then convert it to RGB. @since 1.0
|
||||||
Saturation, ///< Combine with HSL(Dh + Ss + Dl) then convert it to RGB.
|
Saturation, ///< Combine with HSL(Dh + Ss + Dl) then convert it to RGB. @since 1.0
|
||||||
Color, ///< Combine with HSL(Sh + Ss + Dl) then convert it to RGB.
|
Color, ///< Combine with HSL(Sh + Ss + Dl) then convert it to RGB. @since 1.0
|
||||||
Luminosity, ///< Combine with HSL(Dh + Ds + Sl) then convert it to RGB.
|
Luminosity, ///< Combine with HSL(Dh + Ds + Sl) then convert it to RGB. @since 1.0
|
||||||
Add, ///< Simply adds pixel values of one layer with the other. (S + D)
|
Add, ///< Simply adds pixel values of one layer with the other. (S + D)
|
||||||
HardMix, ///< Adds S and D; result is 255 if the sum is greater than or equal to 255, otherwise 0.
|
HardMix, ///< Adds S and D; result is 255 if the sum is greater than or equal to 255, otherwise 0. @since 1.0
|
||||||
Composition = 255 ///< Used for intermediate composition. @since 1.0
|
Composition = 255 ///< Used for intermediate composition. Only valid when applied to a Scene. @since 1.0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,8 @@ uint8_t Paint::opacity() const noexcept
|
||||||
|
|
||||||
Result Paint::blend(BlendMethod method) noexcept
|
Result Paint::blend(BlendMethod method) noexcept
|
||||||
{
|
{
|
||||||
if (method <= BlendMethod::HardMix || method == BlendMethod::Composition) {
|
//Composition is only allowed to Scene.
|
||||||
|
if (method <= BlendMethod::HardMix || (method == BlendMethod::Composition && type() == Type::Scene)) {
|
||||||
pImpl->blend(method);
|
pImpl->blend(method);
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue