Sha256: 9cd553cd8bad13e11857513e7a67909419b54cb7e241a8a8dc0072e6f09f2142

Contents?: true

Size: 408 Bytes

Versions: 11

Compression:

Stored size: 408 Bytes

Contents

# frozen_string_literal: true

# rgb utility
class Atome
  def rgb_html(string)
    js_code = <<-JS
  var col = w3color('#{string}');
  var rgb_col = col.toRgb();
  return rgb_col;
    JS

    JS.eval(js_code)
  end

  def to_rgb(string)
    rgb_color = rgb_html(string)

    {
      red: rgb_color[:r] / 255,
      green: rgb_color[:g] / 255,
      blue: rgb_color[:b] / 255,
      alpha: 1
    }
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
atome-0.5.7.6.5 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.6.0 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.5.9 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.5.4 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.5.3 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.5.1 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.4.8 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.4.7 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.4.6 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.4.3 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.4.2 lib/platform_specific/opal/extensions/color.rb