Sha256: 0559087b91671ce372949d99e3864185b371c1eb9485b055406a9804831b5aa5

Contents?: true

Size: 746 Bytes

Versions: 18

Compression:

Stored size: 746 Bytes

Contents

class Integer
  # Converts a hexadecimal number into a Color. Must be
  # the equivalent of the full hexadecimal form (for example,
  # <tt>0x123456</tt>).
  def to_color
    Colorist::Color.new(self)
  end
end

class Float
  # Converts a number from 0.0 to 1.0 to the grayscale equivalent
  # of that brightness value. Especially useful for adding percentages
  # to a color.
  def to_color
    Colorist::Color.from_rgb(self * 255, self * 255, self * 255)
  end
end

class String
  # Converts a CSS-style color string to a Color. Can be
  # in the full form (<tt>\#112233</tt>), the abbreviated form
  # (<tt>\#123</tt>) or a CSS named color (<tt>"black"</tt> or <tt>"maroon"</tt>).
  def to_color
    Colorist::Color.from_string(self)
  end
end

Version data entries

18 entries across 18 versions & 6 rubygems

Version Path
be9-colorist-0.0.3 lib/colorist/core_extensions.rb
mbleigh-colorist-0.0.1 lib/colorist/core_extensions.rb
mbleigh-colorist-0.0.2 lib/colorist/core_extensions.rb
slippyd-colorist-0.0.3.1 lib/colorist/core_extensions.rb
slippyd-colorist-0.0.4 lib/colorist/core_extensions.rb
lorraine-0.0.7 vendor/colorist/colorist/core_extensions.rb
lorraine-0.0.6 vendor/colorist/colorist/core_extensions.rb
lorraine-0.0.5 vendor/colorist/colorist/core_extensions.rb
lorraine-0.0.4 vendor/colorist/colorist/core_extensions.rb
lorraine-0.0.3 vendor/colorist/colorist/core_extensions.rb
lorraine-0.0.2 vendor/colorist/colorist/core_extensions.rb
kmandrup-colorist-0.1.5 lib/colorist/core_extensions.rb
kmandrup-colorist-0.1.4 lib/colorist/core_extensions.rb
kmandrup-colorist-0.1.3 lib/colorist/core_extensions.rb
kmandrup-colorist-0.1.2 lib/colorist/core_extensions.rb
slippyd-colorist-0.0.5 lib/colorist/core_extensions.rb
colorist-0.0.1 lib/colorist/core_extensions.rb
colorist-0.0.2 lib/colorist/core_extensions.rb