Issue #2303 - Please add Constant type of gradient interpolation ...
... to make multi-color hard-edge gradient fills possible Add a new "step" gradient-segment blending function, which is 0 before the midpoint, and 1 at, and after, the midpoint. This creates a hard-edge transition between the two adjacent color stops at the midpoint. Creating such a transition was already possible, but required duplicating the same color at the opposing ends of two adjacent stops, which is cumbersome.
This commit is contained in:
@ -90,6 +90,8 @@ static inline gdouble gimp_gradient_calc_sphere_increasing_factor (gdouble mid
|
||||
gdouble pos);
|
||||
static inline gdouble gimp_gradient_calc_sphere_decreasing_factor (gdouble middle,
|
||||
gdouble pos);
|
||||
static inline gdouble gimp_gradient_calc_step_factor (gdouble middle,
|
||||
gdouble pos);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpGradient, gimp_gradient, GIMP_TYPE_DATA,
|
||||
@ -503,6 +505,10 @@ gimp_gradient_get_color_at (GimpGradient *gradient,
|
||||
factor = gimp_gradient_calc_sphere_decreasing_factor (middle, pos);
|
||||
break;
|
||||
|
||||
case GIMP_GRADIENT_SEGMENT_STEP:
|
||||
factor = gimp_gradient_calc_step_factor (middle, pos);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("%s: Unknown gradient type %d.", G_STRFUNC, seg->type);
|
||||
break;
|
||||
@ -2273,3 +2279,10 @@ gimp_gradient_calc_sphere_decreasing_factor (gdouble middle,
|
||||
/* Works for convex decreasing and concave increasing */
|
||||
return 1.0 - sqrt(1.0 - pos * pos);
|
||||
}
|
||||
|
||||
static inline gdouble
|
||||
gimp_gradient_calc_step_factor (gdouble middle,
|
||||
gdouble pos)
|
||||
{
|
||||
return pos >= middle;
|
||||
}
|
||||
|
Reference in New Issue
Block a user