Method: MaRuKu::Out::Latex#latex_color
- Defined in:
- lib/maruku/output/to_latex.rb
#latex_color(s, command = 'color') ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/maruku/output/to_latex.rb', line 176 def latex_color(s, command='color') if s =~ /^\#(\w\w)(\w\w)(\w\w)$/ r = $1.hex; g = $2.hex; b=$3.hex # convert from 0-255 to 0.0-1.0 r = r / 255.0; g = g / 255.0; b = b / 255.0; "\\#{command}[rgb]{%0.2f,%0.2f,%0.2f}" % [r,g,b] elsif s =~ /^\#(\w)(\w)(\w)$/ r = $1.hex; g = $2.hex; b=$3.hex # convert from 0-15 to 0.0-1.0 r = r / 15.0; g = g / 15.0; b = b / 15.0; "\\#{command}[rgb]{%0.2f,%0.2f,%0.2f}" % [r,g,b] else "\\#{command}{#{s}}" end end |