[gimp/wip/gradient-edit: 23/42] app: improve curved gradient segment sampling



commit da2116160e3b5622b5dcc8d0c80c8585461e3879
Author: Ell <ell_se yahoo com>
Date:   Sat Aug 12 11:56:21 2017 -0400

    app: improve curved gradient segment sampling
    
    Improve the sampling performance of curved gradient segments, and
    its behavior when the segment's midpoint is close to one of its
    limits.

 app/core/gimpgradient.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c
index b228c52..7987b7a 100644
--- a/app/core/gimpgradient.c
+++ b/app/core/gimpgradient.c
@@ -2179,9 +2179,11 @@ gimp_gradient_calc_curved_factor (gdouble middle,
                                   gdouble pos)
 {
   if (middle < EPSILON)
-    middle = EPSILON;
+    return 1.0;
+  else if (1.0 - middle < EPSILON)
+    return 0.0;
 
-  return pow (pos, log (0.5) / log (middle));
+  return exp (-G_LN2 * log (pos) / log (middle));
 }
 
 static inline gdouble


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