halostatue / color

Color tools for Ruby.
Other
133 stars 41 forks source link

add Color::RGB.from_rgba #26

Open eliasbaixas opened 6 years ago

eliasbaixas commented 6 years ago

This is my monkey patch :P

Color::RGB.class_eval do 

  def self.from_rgba(rgba)
    r,g,b = *rgba.scan(/\d+/).map(&:to_f)
    self.new(r,g,b, rgba.match(/%/) ? 100 : 255)
  end

end