From 114ba4279dea733f216b4e2d2b3cafb6c931c3bb Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Mon, 20 Apr 2020 17:50:25 +0200 Subject: [PATCH] make negative dim and contrast work (not really useful) --- html/script.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/html/script.js b/html/script.js index d7842c2..ba90ce2 100644 --- a/html/script.js +++ b/html/script.js @@ -3008,11 +3008,20 @@ function dim(evt) { evt.context.globalCompositeOperation = 'multiply'; evt.context.fillStyle = 'rgba(0,0,0,'+dim+')'; evt.context.fillRect(0, 0, evt.context.canvas.width, evt.context.canvas.height); + } else if (dim < -0.0001) { + evt.context.globalCompositeOperation = 'screen'; + console.log(evt.context.globalCompositeOperation); + evt.context.fillStyle = 'rgba(255, 255, 255,'+(-dim)+')'; + evt.context.fillRect(0, 0, evt.context.canvas.width, evt.context.canvas.height); } if (contrast > 0.0001) { evt.context.globalCompositeOperation = 'overlay'; evt.context.fillStyle = 'rgba(0,0,0,'+contrast+')'; evt.context.fillRect(0, 0, evt.context.canvas.width, evt.context.canvas.height); + } else if (contrast < -0.0001) { + evt.context.globalCompositeOperation = 'overlay'; + evt.context.fillStyle = 'rgba(255, 255, 255,'+ (-contrast)+')'; + evt.context.fillRect(0, 0, evt.context.canvas.width, evt.context.canvas.height); } evt.context.globalCompositeOperation = 'source-over'; }