def _color_image_math(cs, lum_cb, lum_cs): """Returns ImageMath operands for color blend mode""" cs = [_float(c) for c in cs] lum_cb = _float(lum_cb) lum_cs = _float(lum_cs) return set_lum_im(cs, lum_cb, lum_cs)
def _color_dodge_image_math(cb, cs_inv): """Returns ImageMath operands for color dodge blend mode""" cb = _float(cb) cs_inv = _float(cs_inv) cm = ((cb != 0) * (cs_inv == 0) + (cb / cs_inv)) * 255 return _convert(cm, 'L')
def _hue(cb, cs, lum_cb): """Returns ImageMath operands for hue blend mode""" cb = [_float(c) for c in cb] cs = [_float(c) for c in cs] lum_cb = _float(lum_cb) return set_lum(set_sat(cs, sat(cb)), lum_cb)
def _soft_light(cb, cs, d_cb): """Returns ImageMath operands for soft light""" cb = _float(cb) / 255 cs = _float(cs) / 255 d_cb = _float(d_cb) / 255 c1 = (cs <= .5) * (cb - (1 - 2 * cs) * cb * (1 - cb)) c2 = (cs > .5) * (cb + (2 * cs - 1) * d_cb) return _convert((c1 + c2) * 255, 'L')
def _color_dodge(cb, cs_inv): cb = _float(cb) cs_inv = _float(cs_inv) cm = ((cb != 0) * (cs_inv == 0) + (cb / cs_inv)) * 255 return _convert(cm, 'L')