Module: ChunkyPNG
- Defined in:
- lib/chunky_png.rb,
lib/chunky_png/chunk.rb,
lib/chunky_png/color.rb,
lib/chunky_png/image.rb,
lib/chunky_png/point.rb,
lib/chunky_png/canvas.rb,
lib/chunky_png/vector.rb,
lib/chunky_png/palette.rb,
lib/chunky_png/rmagick.rb,
lib/chunky_png/dimension.rb,
lib/chunky_png/datastream.rb,
lib/chunky_png/canvas/drawing.rb,
lib/chunky_png/canvas/masking.rb,
lib/chunky_png/canvas/operations.rb,
lib/chunky_png/canvas/resampling.rb,
lib/chunky_png/canvas/png_decoding.rb,
lib/chunky_png/canvas/png_encoding.rb,
lib/chunky_png/canvas/stream_exporting.rb,
lib/chunky_png/canvas/stream_importing.rb,
lib/chunky_png/canvas/adam7_interlacing.rb,
lib/chunky_png/canvas/data_url_exporting.rb,
lib/chunky_png/canvas/data_url_importing.rb
Overview
ChunkyPNG - the pure ruby library to access PNG files.
The ChunkyPNG module defines some constants that are used in the PNG specification, specifies some exception classes, and serves as a namespace for all the other modules and classes in this library.
- Image
-
class to represent PNG images, including metadata.
- Canvas
-
class to represent the image’s canvas.
- Color
-
module to work with color values.
- Palette
-
represents the palette of colors used on a Canvas.
- Datastream
-
represents the internal structure of a PNG Image.
- Color
-
represents one chunk of data within a Datastream.
- Point
-
geometry helper class representing a 2-dimensional point.
- Dimension
-
geometry helper class representing a dimension (i.e. width x height).
- Vector
-
geometry helper class representing a series of points.
Defined Under Namespace
Modules: Chunk, Color, RMagick Classes: CRCMismatch, Canvas, Datastream, Dimension, Exception, ExpectationFailed, Image, NotSupported, OutOfBounds, Palette, Point, SignatureMismatch, Vector
Constant Summary collapse
- VERSION =
The current version of ChunkyPNG. This value will be updated automatically by them
gem:release
rake task. "1.2.5"
Class Method Summary collapse
-
.Color(*args) ⇒ Integer
Factory method to return a color value, based on the arguments given.
-
.Dimension(*args) ⇒ ChunkyPNG::Dimension
Creates a Dimension instance using arguments that can be interpreted as width and height.
-
.Point(*args) ⇒ ChunkyPNG::Point
Factory method to create Point instances.
-
.Vector(*args) ⇒ ChunkyPNG::Vector
Factory method for Vector instances.
Class Method Details
.Color(r, g, b, a) ⇒ Integer .Color(r, g, b) ⇒ Integer .Color(hex_value, opacity = nil) ⇒ Integer .Color(color_name, opacity = nil) ⇒ Integer .Color(color_value, opacity = nil) ⇒ Integer
Factory method to return a color value, based on the arguments given.
29 30 31 32 33 34 35 36 37 |
# File 'lib/chunky_png/color.rb', line 29 def self.Color(*args) case args.length when 1; ChunkyPNG::Color.parse(args.first) when 2; (ChunkyPNG::Color.parse(args.first) & 0xffffff00) | args[1].to_i when 3; ChunkyPNG::Color.rgb(*args) when 4; ChunkyPNG::Color.rgba(*args) else raise ArgumentError, "Don't know how to create a color from #{args.inspect}!" end end |
.Dimension(width, height) ⇒ ChunkyPNG::Dimension .Dimension(string) ⇒ ChunkyPNG::Dimension .Dimension(ary) ⇒ ChunkyPNG::Dimension .Dimension(hash) ⇒ ChunkyPNG::Dimension
Creates a Dimension instance using arguments that can be interpreted as width and height.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chunky_png/dimension.rb', line 30 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 ChunkyPNG::Dimension::DIMENSION_REGEXP; ChunkyPNG::Dimension.new($1, $2) else if source.respond_to?(:width) && source.respond_to?(:height) ChunkyPNG::Dimension.new(source.width, source.height) else raise ArgumentError, "Don't know how to construct a point from #{source.inspect}!" end end else raise ArgumentError, "Don't know how to construct a point from #{args.inspect}!" end end |
.Point(x, y) ⇒ ChunkyPNG::Point .Point(array) ⇒ ChunkyPNG::Point .Point(hash) ⇒ ChunkyPNG::Point .Point(string) ⇒ ChunkyPNG::Point
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chunky_png/point.rb', line 31 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 ChunkyPNG::Point::POINT_REGEXP; 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 ArgumentError, "Don't know how to construct a point from #{source.inspect}!" end end else raise ArgumentError, "Don't know how to construct a point from #{args.inspect}!" end end |
.Vector(x0, y0, x1, y1, x2, y2, ...) ⇒ ChunkyPNG::Vector .Vector(string) ⇒ ChunkyPNG::Vector .Vector(pointlike, pointlike, pointlike, ...) ⇒ ChunkyPNG::Vector
Factory method for Vector instances.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chunky_png/vector.rb', line 19 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 |