From cf980993bedf0ca7550d0b8020e13587a049c9d4 Mon Sep 17 00:00:00 2001 From: Gabe Olesen Date: Wed, 20 Oct 2021 15:27:01 +0100 Subject: [PATCH 01/22] add mix-blend-mode functions --- lib/commons/color/flatten-colors.js | 34 +++++++++++++++++++++++++- test/playground.html | 37 ++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/lib/commons/color/flatten-colors.js b/lib/commons/color/flatten-colors.js index 2c3de0e033..089e04e7c5 100644 --- a/lib/commons/color/flatten-colors.js +++ b/lib/commons/color/flatten-colors.js @@ -6,7 +6,40 @@ import Color from './color'; const blendFunctions = { normal(Cb, Cs) { return Cs; + }, + multiply(Cb, Cs) { + return (Cs * Cb) / 255; } + // screen(Cb, Cs) { + // return null; + // }, + // overlay(Cb, Cs) { + // return null; + // }, + // darken(Cb, Cs) { + // return null; + // }, + // lighten(Cb, Cs) { + // return null; + // }, + // colorDodge(Cb, Cs) { + // return null; + // }, + // colorBurn(Cb, Cs) { + // return null; + // }, + // hardLight(Cb, Cs) { + // return null; + // }, + // softLight(Cb, Cs) { + // return null; + // }, + // difference(Cb, Cs) { + // return null; + // }, + // exclusion(Cb, Cs) { + // return null; + // } }; // Simple Alpha Compositing written as non-premultiplied. @@ -60,7 +93,6 @@ function flattenColors(fgColor, bgColor, blendMode = 'normal') { bgColor.alpha, blendMode ); - // formula: αo = αs + αb x (1 - αs) // clamp alpha between 0 and 1 const a = Math.max( diff --git a/test/playground.html b/test/playground.html index 4de25a4c17..c7d6a8bf1f 100644 --- a/test/playground.html +++ b/test/playground.html @@ -1,8 +1,43 @@ O hai + + + +
+
+
+
+ Hello World +
+
+
Test1 result
+
+
+