formulas



In [1]:
from sympy import *

In [9]:
import matplotlib.pyplot
matplotlib.pyplot.rcParams['figure.figsize'] = 5, 5

In [10]:
h, l = symbols("h l")

In [11]:
# Average elementary hue angles
R = 0
Y = 67
G = 140
C = 180
B = 239
M = 303

k_r = (0.299*0.2126)**0.5
k_g = (0.587*0.7152)**0.5
k_b = (0.114*0.0722)**0.5

# Delta hue
d_RY = Y - R
d_YG = G - Y
d_GC = C - G
d_CB = B - C
d_BM = M - B
d_MR = 360 - M

# Luminosity
R_L = k_r
Y_L = k_r + k_g - 0.2
G_L = k_g - 0.1
C_L = k_g + k_b - 0.1
B_L = k_b
M_L = k_b + k_r

# Slope
s_RY = (Y_L - R_L)/d_RY
s_YG = (G_L - Y_L)/d_YG
s_GC = (C_L - G_L)/d_GC
s_CB = (B_L - C_L)/d_CB
s_BM = (M_L - B_L)/d_BM
s_MR = (R_L - M_L)/d_MR

plot(
    (-(-R*s_RY + R_L + h*s_RY - 0.5), (h, R, Y)),
    (-(-Y*s_YG + Y_L + h*s_YG - 0.5), (h, Y, G)),
    (-(-G*s_GC + G_L + h*s_GC - 0.5), (h, G, C)),
    (-(-C*s_CB + C_L + h*s_CB - 0.5), (h, C, B)),
    (-(-B*s_BM + B_L + h*s_BM - 0.5), (h, B, M)),
    (-(-M*s_MR + M_L + h*s_MR - 0.5), (h, M, 360)),
    (0.5, (h, 0, 360)),
    axis_center=(0, 0),
);



In [12]:
[R_L, Y_L, G_L, C_L, B_L, M_L]


Out[12]:
[0.25212576226954675,
 0.7000627962473862,
 0.5479370339778395,
 0.6386607905138207,
 0.09072375653598125,
 0.342849518805528]

In [13]:
R, Y, G, C, B, M, d_RY, d_YG, d_GC, d_CB, d_BM, d_MR, R_L, Y_L, G_L, C_L, B_L, M_L, s_RY, s_YG, s_GC, s_CB, s_BM, s_MR = \
    symbols("R Y G C B M d_RY d_YG d_GC d_CB d_BM d_MR R_L Y_L G_L C_L B_L M_L s_RY s_YG s_GC s_CB s_BM s_MR")

In [14]:
[
-(-R*s_RY + R_L + h*s_RY - 0.5),
-(-Y*s_YG + Y_L + h*s_YG - 0.5),
-(-G*s_GC + G_L + h*s_GC - 0.5),
-(-C*s_CB + C_L + h*s_CB - 0.5),
-(-B*s_BM + B_L + h*s_BM - 0.5),
-(-M*s_MR + M_L + h*s_MR - 0.5),
]


Out[14]:
[R*s_RY - R_L - h*s_RY + 0.5,
 Y*s_YG - Y_L - h*s_YG + 0.5,
 G*s_GC - G_L - h*s_GC + 0.5,
 C*s_CB - C_L - h*s_CB + 0.5,
 B*s_BM - B_L - h*s_BM + 0.5,
 M*s_MR - M_L - h*s_MR + 0.5]

In [37]:
plot((x, (x, 0, 0.5)),
     (1 - x, (x, 0.5, 1)),
     xlim=(-2, 2), ylim=(-2, 2),
     axiscenter=(0.0));



In [15]:
x, y = symbols("x y")

In [35]:
plot(-(2*x - 1)**2/2 + 1/2, xlim=(-2, 2), ylim=(-2, 2), axiscenter=(0.0));



In [34]:
(-(2*x - 1)**2 + 1)/2


Out[34]:
-(2*x - 1)**2/2 + 1/2

In [49]:
plot(2*x**2,
     2*(x - 1)**2,
     xlim=(-2, 2), ylim=(-2, 2), axiscenter=(0.0));



In [ ]: