Colouring cells in Google Docs with cell value
-
09-06-2021 - |
Pregunta
Anyone know if it's possible to colour the cells of a Google Docs spreadsheet with their values? The cells are populated with CMYK codes.
Cheers!
Solución
I've written a rough CMYK-to-RGB converter for Rails the logic from which could be applied anywhere. See below.
def paint(co1)
c1, m1, y1, k1 = co1.split(",")
c2, m2, y2, k2 = co2.split(",")
c1 = c1.to_i*2.55
m1 = m1.to_i*2.55
y1 = y1.to_i*2.55
k1 = k1.to_i*2.55
if c1.to_i + k1.to_i < 255
@r1 = 255 - (c1.to_i + k1.to_i)
else
@r1 = 0
end
if m1.to_i + k1.to_i < 255
@g1 = 255 - (m1.to_i + k1.to_i)
else
@g1 = 0
end
if y1.to_i + k1.to_i < 255
@b1 = 255 - (y1.to_i + k1.to_i)
else
@b1 = 0
end
return @r1, @b1, @g1
end
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow