-1

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!

t56k
  • 6,769
  • 9
  • 52
  • 115
  • The main issue with your problem is to convert these CMYK codes to RGB. Once you've done that (google it to see that it's not very easy), then it's pretty easy to use Google Apps Script to change the cells colors. – Henrique G. Abreu May 19 '12 at 13:35

1 Answers1

0

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
t56k
  • 6,769
  • 9
  • 52
  • 115