Skip to content

Blend modes and formulas

Evgeny Kopylov edited this page Mar 23, 2021 · 1 revision

This page contains a complete list of blend modes and formulas behind them.

Variables in formulas below have the following meaning:

  • A, B ─ colors
  • a, b ─ color components
  • A ─ pixel color from active (top) layer
  • B ─ pixel color from background layer
Mode name Function name Formula
Normal group
Dissolve dissolve f(A, B) = B if A['A'] < (rand() % 255) + 1 else (A['RGB'], 255)
Darken group
Darken darken f(a, b) = min(a, b)
Multiply multiply f(a, b) = a*b / 255
Color Burn color_burn f(a, b) = max(0, 255 - (255 - b)*255 / (1 if a == 0 else a))
Linear Burn linear_burn f(a, b) = max(0, a + b - 255)
Darker Color darker_color f(A, B) = A if lum(A) < lum(B) else B
Lighten group
Lighten lighten f(a, b) = max(a, b)
Screen screen f(a, b) = 255 - (255 - a)*(255 - b) / 255 = a + b - a*b / 255
Color Dodge color_dodge f(a, b) = min(255, b*255 / (1 if a == 255 else (255 - a)))
Linear Dodge linear_dodge f(a, b) = min(255, a + b)
Lighter Color lighter_color f(A, B) = A if lum(A) > lum(B) else B
Contrast group
Overlay overlay f(a, b) = multiply(a, 2*b) if b < 128 else screen(a, 2*b - 255)
Soft Light soft_light Too complex to represent as a single line
Hard Light hard_light f(a, b) = overlay(b, a) = multiply(b, 2*a) if a < 128 else screen(b, 2*a - 255)
Vivid Light vivid_light f(a, b) = color_burn(2*a, b) if a < 128 else color_dodge(2*a - 255, b)
Linear Light linear_light f(a, b) = linear_burn(2*a, b) if a < 128 else linear_dodge(2*a - 255, b)
Pin Light pin_light f(a, b) = darken(2*a, b) if a < 128 else lighten(2*a - 255, b)
Hard Mix hard_mix Too complex to represent as a single line
Inversion group
Difference difference f(a, b) = |b - a|
Exclusion exclusion f(a, b) = a + b - 2*a*b / 255
Cancellation group
Subtract subtract f(a, b) = max(0, b - a)
Divide divide f(a, b) = min(255, b*255 / (1 if a == 0 else a))
Component group
Hue hue f(A, B) = set_lum(set_sat(A, sat(B)), lum(B))
Saturation saturation f(A, B) = set_lum(set_sat(B, sat(A)), lum(B))
Color color f(A, B) = set_lum(A, lum(B))
Luminosity luminosity f(A, B) = set_lum(B, lum(A))
Clone this wiki locally