Sha256: 344c9e7be6877cf1024e62ee4271d5c3934f37848f066ff5ff581fa1bb3446f3

Contents?: true

Size: 521 Bytes

Versions: 73

Compression:

Stored size: 521 Bytes

Contents

# frozen_string_literal: true

# rgb utility
class Atome
  def rgb_html(string)
    #    `
    #  col = w3color(#{string});
    #  rgb_col=col.toRgb();
    #  return Opal.hash(rgb_col)
    # `
    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

73 entries across 73 versions & 1 rubygems

Version Path
atome-0.5.7.3.9 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.3.6 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.3.5 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.3.3 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.3.2 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.3.1 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.3.0 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.1.8 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.1.7 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.1.0 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.0.7 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.0.5 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.0.4 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.0.3 lib/platform_specific/opal/extensions/color.rb
atome-0.5.7.0.2 lib/platform_specific/opal/extensions/color.rb
atome-0.5.6.8.7 lib/platform_specific/opal/extensions/color.rb
atome-0.5.6.8.6 lib/platform_specific/opal/extensions/color.rb
atome-0.5.6.8.5 lib/platform_specific/opal/extensions/color.rb
atome-0.5.6.8.3 lib/platform_specific/opal/extensions/color.rb
atome-0.5.6.7.8 lib/platform_specific/opal/extensions/color.rb