From ca6dd1bb90153dbe03195ca246a1c541ec7f1aac Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Sat, 25 May 2024 01:58:36 +0200 Subject: [PATCH] Implement "divide" blend-mode --- pixmappaint.d | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pixmappaint.d b/pixmappaint.d index 98e75c9..aff06c8 100644 --- a/pixmappaint.d +++ b/pixmappaint.d @@ -463,6 +463,8 @@ enum BlendMode { darken, lighten, + + divide, } /// @@ -533,6 +535,17 @@ void blendPixel(BlendMode mode, BlendAccuracy accuracy = BlendAccuracy.rgba)( )(target, source); } +/// ditto +void blendPixel(BlendMode mode, BlendAccuracy accuracy = BlendAccuracy.rgba)( + ref Pixel target, + const Pixel source, +) if (mode == Blend.divide) { + + return alphaBlend!(accuracy, + (b, f) => (f == 0) ? ubyte(0xFF) : clamp255(0xFF * b / f) + )(target, source); +} + /++ Blends the pixel data of `source` into `target`.