emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 6b2e95a 24/31: Add gamma-correction to alpha-blending


From: Oleh Krehel
Subject: [elpa] master 6b2e95a 24/31: Add gamma-correction to alpha-blending
Date: Fri, 01 May 2015 14:29:01 +0000

branch: master
commit 6b2e95a35377681e32199baa55e79fb55d2adca1
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add gamma-correction to alpha-blending
    
    * colir.el (colir-compose-method): Make 'colir-compose-alpha default.
    (colir-compose-alpha): Add gamma-correction.
---
 colir.el |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/colir.el b/colir.el
index c9a0ada..f5ce0ae 100644
--- a/colir.el
+++ b/colir.el
@@ -32,7 +32,7 @@
 
 (require 'color)
 
-(defcustom colir-compose-method 'colir-compose-overlay
+(defcustom colir-compose-method 'colir-compose-alpha
   "Select a method to compose two color channels."
   :type '(choice
           (const colir-compose-alpha)
@@ -52,10 +52,11 @@
       (* 2 a b)
     (- 1 (* 2 (- 1 a) (- 1 b)))))
 
-(defun colir-compose-alpha (a b &optional alpha)
+(defun colir-compose-alpha (a b &optional alpha gamma)
   "Compose A and B channels."
   (setq alpha (or alpha 0.5))
-  (+ (* a alpha) (* b (- 1 alpha))))
+  (setq gamma (or gamma 2.2))
+  (+ (* (expt a gamma) alpha) (* (expt b gamma) (- 1 alpha))))
 
 (defun colir-blend (c1 c2)
   "Blend the two colors C1 and C2 using `colir-compose-method'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]