vectorize

This commit is contained in:
Martin Diehl 2020-03-14 22:24:45 +01:00
parent 0becd8c20b
commit 6dcb5b0d0d
1 changed files with 7 additions and 8 deletions

View File

@ -192,9 +192,9 @@ class Color:
HSL[0] = HSL[0]*60.0 # scaling to 360 might be dangerous for small values
if (HSL[0] < 0.0):
HSL[0] = HSL[0] + 360.0
for i in range(2):
HSL[i+1] = min(HSL[i+1],1.0)
HSL[i+1] = max(HSL[i+1],0.0)
HSL[1:] = np.mimimum(HSL[1:],1.0)
HSL[1:] = np.maximum(HSL[1:],0.0)
converted = Color('HSL', HSL)
self.model = converted.model
@ -220,8 +220,7 @@ class Color:
if (self.color[i] > 0.04045): RGB_lin[i] = ((self.color[i]+0.0555)/1.0555)**2.4
else: RGB_lin[i] = self.color[i] /12.92
XYZ = np.dot(convert,RGB_lin)
for i in range(3):
XYZ[i] = max(XYZ[i],0.0)
XYZ = np.maximum(XYZ,0.0)
converted = Color('XYZ', XYZ)
self.model = converted.model
@ -246,9 +245,9 @@ class Color:
for i in range(3):
if (RGB_lin[i] > 0.0031308): RGB[i] = ((RGB_lin[i])**(1.0/2.4))*1.0555-0.0555
else: RGB[i] = RGB_lin[i] *12.92
for i in range(3):
RGB[i] = min(RGB[i],1.0)
RGB[i] = max(RGB[i],0.0)
RGB = np.minimum(RGB,1.0)
RGB = np.maximum(RGB,0.0)
maxVal = max(RGB) # clipping colors according to the display gamut
if (maxVal > 1.0): RGB /= maxVal