Please FF - if you do not revise the blending function design, could you at least create separate HDR function definitions from non-HDR definitions..
The problem is that the parameter count differs btwn. non-HDR functions and HDR functions, which makes it very impractical.
Consider the following alternative (and much cleaner) script of your blending script example:
Code |
---|
function prepare()
BL_MODE = get_intslider_input(BLENDING_MODE)
HDR = (1 == get_checkbox_input(HDR))
BLENDFUNCTIONS = {
blend_normal,
blend_darken,
blend_multiply,
blend_color_burn,
blend_linear_burn,
blend_lighten,
blend_screen,
blend_color_dodge,
blend_linear_dodge,
blend_overlay,
blend_soft_light,
blend_hard_light,
blend_vivid_light,
blend_linear_light,
blend_difference,
blend_hue,
blend_saturation,
blend_color,
blend_luminosity
}
end;
function get_sample(x, y)
local r, g, b, a = get_sample_map(x, y, BACKGROUND)
local r2, g2, b2, a2 = get_sample_map(x, y, FOREGROUND)
local opacity = get_sample_grayscale(x, y, OPACITY)
return BLENDFUNCTIONS[BL_MODE](r, g, b, a, r2, g2, b2, a2, opacity, HDR)
end;
|
Now this a much better alternative compared to the cluttering and inefficient conditional check seen in:
But the darn parameter inconsistency caused by the additional HDR parameter present in some modes, causes the script to either fail on non-HDR modes (as presented above) or fail on HDR modes...
I suggest not mixing things here, so the HDR modes are available as separate functions (since these are really different), i.e.:
blend_normal_hdr
blend_darken_hdr
blend_multiply_hdr
blend_lighten_hdr
blend_linear_dodge_hdr
blend_difference_hdr
blend_hue_hdr
blend_saturation_hdr
blend_color_hdr
blend_luminosity_hdr