mirror of https://github.com/adamdruppe/arsd.git
Implement "lighten" + "darken" blend-modes
This commit is contained in:
parent
6e469c27bd
commit
9a4f8467f8
|
@ -272,6 +272,9 @@ private struct OriginRectangle {
|
||||||
// misc
|
// misc
|
||||||
private {
|
private {
|
||||||
Point pos(Rectangle r) => r.upperLeft;
|
Point pos(Rectangle r) => r.upperLeft;
|
||||||
|
|
||||||
|
T max(T)(T a, T b) => (a >= b) ? a : b;
|
||||||
|
T min(T)(T a, T b) => (a <= b) ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
@ -491,6 +494,7 @@ void blendPixel(BlendMode mode, BlendAccuracy accuracy = BlendAccuracy.rgba)(
|
||||||
ref Pixel target,
|
ref Pixel target,
|
||||||
const Pixel source,
|
const Pixel source,
|
||||||
) if (mode == Blend.multiply) {
|
) if (mode == Blend.multiply) {
|
||||||
|
|
||||||
return alphaBlend!(accuracy,
|
return alphaBlend!(accuracy,
|
||||||
(a, b) => n255thsOf(a, b)
|
(a, b) => n255thsOf(a, b)
|
||||||
)(target, source);
|
)(target, source);
|
||||||
|
@ -512,7 +516,10 @@ void blendPixel(BlendMode mode, BlendAccuracy accuracy = BlendAccuracy.rgba)(
|
||||||
ref Pixel target,
|
ref Pixel target,
|
||||||
const Pixel source,
|
const Pixel source,
|
||||||
) if (mode == Blend.darken) {
|
) if (mode == Blend.darken) {
|
||||||
assert(false, "TODO");
|
|
||||||
|
return alphaBlend!(accuracy,
|
||||||
|
(a, b) => min(a, b)
|
||||||
|
)(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
|
@ -520,7 +527,10 @@ void blendPixel(BlendMode mode, BlendAccuracy accuracy = BlendAccuracy.rgba)(
|
||||||
ref Pixel target,
|
ref Pixel target,
|
||||||
const Pixel source,
|
const Pixel source,
|
||||||
) if (mode == Blend.lighten) {
|
) if (mode == Blend.lighten) {
|
||||||
assert(false, "TODO");
|
|
||||||
|
return alphaBlend!(accuracy,
|
||||||
|
(a, b) => max(a, b)
|
||||||
|
)(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
|
Loading…
Reference in New Issue