class NumPlot::RGB

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["#00ff00"] # => Green
RGB["blue"]    # => blue

Public Class Methods

[](*args)
Alias for: new
new(*args) click to toggle source

Create a new instance of RGB class.

You can give three styles of arguments to specify a color.

# 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
Also aliased as: []

Public Instance Methods

to_gnuplot_string() click to toggle source

Convert self to gnuplot “rgbcolor” string. @visibility private

# File lib/numplot.rb, line 111
def to_gnuplot_string
  "rgbcolor \"#{@s}\""
end