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/version.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, InvalidUTF8, NotSupported, OutOfBounds, Palette, Point, SignatureMismatch, UnitsUnknown, Vector
Constant Summary collapse
- VERSION =
The current version of ChunkyPNG. Set it and commit the change this before running rake release.
"1.4.0"
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.
33 34 35 36 37 38 39 40 41 |
# File 'lib/chunky_png/color.rb', line 33 def self.Color(*args) # rubocop:disable Naming/MethodName # API backwards compatibility case args.length when 1 then ChunkyPNG::Color.parse(args.first) when 2 then (ChunkyPNG::Color.parse(args.first) & 0xffffff00) | args[1].to_i when 3 then ChunkyPNG::Color.rgb(*args) when 4 then 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.
31 32 33 34 35 36 37 38 |
# File 'lib/chunky_png/dimension.rb', line 31 def self.Dimension(*args) case args.length when 2 then ChunkyPNG::Dimension.new(*args) when 1 then build_dimension_from_object(args.first) else raise ArgumentError, "Don't know how to construct a dimension from #{args.inspect}" end end |
.Point(x, y) ⇒ ChunkyPNG::Point .Point(array) ⇒ ChunkyPNG::Point .Point(hash) ⇒ ChunkyPNG::Point .Point(string) ⇒ ChunkyPNG::Point
32 33 34 35 36 37 38 39 |
# File 'lib/chunky_png/point.rb', line 32 def self.Point(*args) case args.length when 2 then ChunkyPNG::Point.new(*args) when 1 then build_point_from_object(args.first) 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.
20 21 22 23 24 25 26 27 28 |
# File 'lib/chunky_png/vector.rb', line 20 def self.Vector(*args) return args.first if args.length == 1 && args.first.is_a?(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 |