module ChunkyPNG
def self.Color(*args)
-
(ChunkyPNG::ExpectationFailed)
- if the arguments weren't understood as a color.
Returns:
-
(Integer)
- The color value, with the opacity applied if one was given. -
(Integer)
- The hex color value, with the opacity applied if one was given. -
(Integer)
- The hex color value, with the opacity applied if one was given. -
(Integer)
- The rgb color value. -
(Integer)
- The rgba color value.
Parameters:
-
The
(Integer, :to_i
) -- color value. -
(
) --
-
(
) --
-
(
) --
-
(
) --
Overloads:
-
Color(color_value, opacity = nil)
-
Color(color_name, opacity = nil)
-
Color(hex_value, opacity = nil)
-
Color(r, g, b)
-
Color(r, g, b, a)
def self.Color(*args) case args.length when 4; ChunkyPNG::Color.rgba(*args) when 3; ChunkyPNG::Color.rgb(*args) when 2; (ChunkyPNG::Color(args[0]) & 0xffffff00) | args[1].to_i when 1 case source = args.first.to_s when Integer, /^\d+$/; source.to_i when ChunkyPNG::Color::HEX_COLOR_REGEXP; ChunkyPNG::Color.from_hex(source) when ChunkyPNG::Color::HTML_COLOR_REGEXP; ChunkyPNG::Color.html_color(source) else raise ChunkyPNG::ExpectationFailed; "Don't know how to create a color from #{source.inspect}!" end else raise ChunkyPNG::ExpectationFailed; "Don't know how to create a color from #{args.inspect}!" end end
def self.Dimension(*args)
- See: ChunkyPNG::Dimension -
Returns:
-
(ChunkyPNG::Dimension)
- The instantiated dimension. -
(ChunkyPNG::Dimension)
- The instantiated dimension. -
(ChunkyPNG::Dimension)
- The instantiated dimension. -
(ChunkyPNG::Dimension)
- The instantiated dimension.
Parameters:
-
hash
(Hash
) -- An hash with a 'height' or :height key for the -
ary
(Array
) -- An array with the desired width as first element and the -
string
(String
) -- A string from which a width and height value can be parsed, e.g. -
height
(Integer
) -- The height-component of the dimension. -
width
(Integer
) -- The width-component of the dimension.
Overloads:
-
Dimension(hash)
-
Dimension(ary)
-
Dimension(string)
-
Dimension(width, height)
def self.Dimension(*args) case args.length when 2; ChunkyPNG::Dimension.new(*args) when 1; case source = args.first when ChunkyPNG::Dimension; source when ChunkyPNG::Point; ChunkyPNG::Dimension.new(source.x, source.y) when Array; ChunkyPNG::Dimension.new(source[0], source[1]) when Hash; ChunkyPNG::Dimension.new(source[:width] || source['width'], source[:height] || source['height']) when /^[\(\[\{]?(\d+)\s*[x,]?\s*(\d+)[\)\]\}]?$/; ChunkyPNG::Dimension.new($1, $2) else if source.respond_to?(:width) && source.respond_to?(:height) ChunkyPNG::Dimension.new(source.width, source.height) else raise ChunkyPNG::ExpectationFailed, "Don't know how to construct a point from #{source.inspect}!" end end else raise ChunkyPNG::ExpectationFailed, "Don't know how to construct a point from #{args.inspect}!" end end
def self.Point(*args)
- See: ChunkyPNG::Point -
Raises:
-
(ChunkyPNG::ExpectationFailed)
- if the arguments weren't understood.
Returns:
-
(ChunkyPNG::Point)
- The instantiated point. -
(ChunkyPNG::Point)
- The instantiated point. -
(ChunkyPNG::Point)
- The instantiated point. -
(ChunkyPNG::Point)
- The instantiated point.
Parameters:
-
string
(String
) -- A string that contains the coordinates, e.g. '0, 4', -
array
(Hash
) -- A hash with the :x or 'x' and :y or -
array
(Array
) -- A two element array which represent the x- and y-coordinate. -
y
(Integer, :to_i
) -- The y-coordinate -
x
(Integer, :to_i
) -- The x-coordinate
Overloads:
-
Point(string)
-
Point(hash)
-
Point(array)
-
Point(x, y)
def self.Point(*args) case args.length when 2; ChunkyPNG::Point.new(*args) when 1; case source = args.first when ChunkyPNG::Point; source when ChunkyPNG::Dimension; ChunkyPNG::Point.new(source.width, source.height) when Array; ChunkyPNG::Point.new(source[0], source[1]) when Hash; ChunkyPNG::Point.new(source[:x] || source['x'], source[:y] || source['y']) when /^[\(\[\{]?(\d+)\s*[,]?\s*(\d+)[\)\]\}]?$/; ChunkyPNG::Point.new($1.to_i, $2.to_i) else if source.respond_to?(:x) && source.respond_to?(:y) ChunkyPNG::Point.new(source.x, source.y) else raise ChunkyPNG::ExpectationFailed, "Don't know how to construct a point from #{source.inspect}!" end end else raise ChunkyPNG::ExpectationFailed, "Don't know how to construct a point from #{args.inspect}!" end end
def self.Vector(*args)
-
(ChunkyPNG::Vector)
- The instantiated vector. -
(ChunkyPNG::Vector)
- The instantiated vector. -
(ChunkyPNG::Vector)
- The instantiated vector.
Overloads:
-
Vector(pointlike, pointlike, pointlike, ...)
-
Vector(string)
-
Vector(x0, y0, x1, y1, x2, y2, ...)
def self.Vector(*args) return args.first if args.length == 1 && args.first.kind_of?(ChunkyPNG::Vector) if args.length == 1 && args.first.respond_to?(:scan) ChunkyPNG::Vector.new(ChunkyPNG::Vector.multiple_from_string(args.first)) # e.g. ['1,1 2,2 3,3'] else ChunkyPNG::Vector.new(ChunkyPNG::Vector.multiple_from_array(args)) # e.g. [[1,1], [2,2], [3,3]] or [1,1,2,2,3,3] end end