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
new(*args)
click to toggle source
Create a new instance of RGB
class.
You can give three styles of arguments to specify a color.
-
an
RGB
component as three integers likeNumPlot::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”)
# 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