ibanez270dx
3/17/2015 - 12:40 AM

Convert Hex color to RGBA

Convert Hex color to RGBA

  def hex_to_rgba(input, alpha=1)
    components = (input.match /#?([0-9A-F]{2})/ )[1..3]
    components.map!{ |x| x + x } if input.size == 4
    "rgba(#{components.collect(&:hex).join(',')},#{alpha})"
  end