Class: NumPlot::RGB

Inherits:
Object
  • Object
show all
Defined in:
lib/numplot.rb

Overview

The class representing colors in gnuplot.

You can use three types of color specifications like the following examples.

Example: RGB[255, 0, 0] # => Red RGB # => Green RGB # => blue

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (RGB) initialize(*args)

Create a new instance of RGB class.

You can give three styles of arguments to specify a color. * an RGB component as three integers like NumPlot::RGB.new(0, 255, 0) * a “#xxyyzz” style string like NumPlot::RGB.new(“#ff007f”) * a string of the name of a color like NumPlot::RGB.new(“blue”)



99
100
101
102
103
104
105
106
107
# File 'lib/numplot.rb', line 99

def initialize(*args)
  if args.size == 1 && String === args[0]
    @s = args[0]
  elsif args.size == 3
    @s = "#%02x%02x%02x" % args
  else
    raise TypeError, "Unknown color format: #{args.inspect}"
  end
end

Class Method Details

+ (RGB) [](*args)

Create a new RGB object. See #initialize.

Returns:

  • (RGB)

    A new RGB object



119
# File 'lib/numplot.rb', line 119

__yard_ignore_here{ alias [] new }