class Rubyvis::Color

Represents an abstract (possibly translucent) color. The color is divided into two parts: the color attribute, an opaque color format string, and the opacity attribute, a float in [0, 1]. The color space is dependent on the implementing class; all colors support the Color.rgb() method to convert to RGB color space for interpolation.

Constants

NAMES

Association between names and colors

Attributes

color[R]

An opaque color format string, such as “f00”.

opacity[R]

The opacity, a float in [0, 1].

Public Class Methods

new(color,opacity) click to toggle source

Constructs a color with the specified color format string and opacity. This constructor should not be invoked directly; use Rubyvis.color instead.

# File lib/rubyvis/color/color.rb, line 251
def initialize(color,opacity)
  @color=color
  @opacity=opacity
end
transparent() click to toggle source
# File lib/rubyvis/color/color.rb, line 276
def self.transparent
  Rubyvis.rgb(0,0,0,0)
end

Public Instance Methods

brighter(k) click to toggle source

Returns a new color that is a brighter version of this color. The behavior of this method may vary slightly depending on the underlying color space. Although brighter and darker are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.

  • @param [k] {number} an optional scale factor; defaults to 1.

# File lib/rubyvis/color/color.rb, line 261
def brighter(k)
  self.rgb.brighter(k)
end
darker(k) click to toggle source

Returns a new color that is a brighter version of this color. The behavior of this method may vary slightly depending on the underlying color space. Although brighter and darker are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.

  • @param [k] {number} an optional scale factor; defaults to 1.

# File lib/rubyvis/color/color.rb, line 272
def darker(k)
  self.rgb.darker(k)
end