chunky_png 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/chunky_png.gemspec +3 -3
- data/lib/chunky_png.rb +3 -3
- data/lib/chunky_png/canvas.rb +25 -39
- data/lib/chunky_png/canvas/adam7_interlacing.rb +1 -1
- data/lib/chunky_png/canvas/drawing.rb +72 -1
- data/lib/chunky_png/canvas/masking.rb +4 -4
- data/lib/chunky_png/canvas/operations.rb +6 -6
- data/lib/chunky_png/canvas/png_decoding.rb +10 -10
- data/lib/chunky_png/canvas/png_encoding.rb +4 -4
- data/lib/chunky_png/canvas/resampling.rb +3 -3
- data/lib/chunky_png/canvas/stream_importing.rb +1 -1
- data/lib/chunky_png/chunk.rb +2 -2
- data/lib/chunky_png/color.rb +10 -10
- data/lib/chunky_png/datastream.rb +2 -2
- data/lib/chunky_png/dimension.rb +6 -6
- data/lib/chunky_png/image.rb +2 -2
- data/lib/chunky_png/palette.rb +3 -3
- data/lib/chunky_png/point.rb +3 -3
- data/lib/chunky_png/vector.rb +8 -1
- data/spec/chunky_png/canvas/drawing_spec.rb +47 -0
- data/spec/chunky_png/canvas_spec.rb +29 -0
- data/spec/chunky_png/color_spec.rb +1 -1
- data/spec/resources/bezier_five_point.png +0 -0
- data/spec/resources/bezier_four_point.png +0 -0
- data/spec/resources/bezier_four_point_flipped.png +0 -0
- data/spec/resources/bezier_four_point_s.png +0 -0
- data/spec/resources/bezier_six_point.png +0 -0
- data/spec/resources/bezier_three_point.png +0 -0
- data/spec/resources/bezier_three_point_flipped.png +0 -0
- metadata +10 -3
data/chunky_png.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
|
4
4
|
# Do not change the version and date fields by hand. This will be done
|
5
5
|
# automatically by the gem release script.
|
6
|
-
s.version = "1.0
|
7
|
-
s.date = "2011-03-
|
6
|
+
s.version = "1.1.0"
|
7
|
+
s.date = "2011-03-19"
|
8
8
|
|
9
9
|
s.summary = "Pure ruby library for read/write, chunk-level access to PNG files"
|
10
10
|
s.description = <<-EOT
|
@@ -38,6 +38,6 @@ Gem::Specification.new do |s|
|
|
38
38
|
|
39
39
|
# Do not change the files and test_files fields by hand. This will be done
|
40
40
|
# automatically by the gem release script.
|
41
|
-
s.files = %w(.gitignore .infinity_test .yardopts BENCHMARKS.rdoc Gemfile LICENSE README.rdoc Rakefile benchmarks/decoding_benchmark.rb benchmarks/encoding_benchmark.rb benchmarks/filesize_benchmark.rb chunky_png.gemspec lib/chunky_png.rb lib/chunky_png/canvas.rb lib/chunky_png/canvas/adam7_interlacing.rb lib/chunky_png/canvas/drawing.rb lib/chunky_png/canvas/masking.rb lib/chunky_png/canvas/operations.rb lib/chunky_png/canvas/png_decoding.rb lib/chunky_png/canvas/png_encoding.rb lib/chunky_png/canvas/resampling.rb lib/chunky_png/canvas/stream_exporting.rb lib/chunky_png/canvas/stream_importing.rb lib/chunky_png/chunk.rb lib/chunky_png/color.rb lib/chunky_png/compatibility.rb lib/chunky_png/datastream.rb lib/chunky_png/dimension.rb lib/chunky_png/image.rb lib/chunky_png/palette.rb lib/chunky_png/point.rb lib/chunky_png/rmagick.rb lib/chunky_png/vector.rb spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/masking_spec.rb spec/chunky_png/canvas/operations_spec.rb spec/chunky_png/canvas/png_decoding_spec.rb spec/chunky_png/canvas/png_encoding_spec.rb spec/chunky_png/canvas/resampling_spec.rb spec/chunky_png/canvas/stream_exporting_spec.rb spec/chunky_png/canvas/stream_importing_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/dimension_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/point_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png/vector_spec.rb spec/chunky_png_spec.rb spec/png_suite/background_chunks/bgai4a08.png spec/png_suite/background_chunks/bgai4a16.png spec/png_suite/background_chunks/bgan6a08.png spec/png_suite/background_chunks/bgan6a16.png spec/png_suite/background_chunks/bgbn4a08.png spec/png_suite/background_chunks/bggn4a16.png spec/png_suite/background_chunks/bgwn6a08.png spec/png_suite/background_chunks/bgyn6a16.png spec/png_suite/basic/basi0g01.png spec/png_suite/basic/basi0g01.rgba spec/png_suite/basic/basi0g02.png spec/png_suite/basic/basi0g02.rgba spec/png_suite/basic/basi0g04.png spec/png_suite/basic/basi0g04.rgba spec/png_suite/basic/basi0g08.png spec/png_suite/basic/basi0g08.rgba spec/png_suite/basic/basi0g16.png spec/png_suite/basic/basi0g16.rgba spec/png_suite/basic/basi2c08.png spec/png_suite/basic/basi2c08.rgba spec/png_suite/basic/basi2c16.png spec/png_suite/basic/basi2c16.rgba spec/png_suite/basic/basi3p01.png spec/png_suite/basic/basi3p01.rgba spec/png_suite/basic/basi3p02.png spec/png_suite/basic/basi3p02.rgba spec/png_suite/basic/basi3p04.png spec/png_suite/basic/basi3p04.rgba spec/png_suite/basic/basi3p08.png spec/png_suite/basic/basi3p08.rgba spec/png_suite/basic/basi4a08.png spec/png_suite/basic/basi4a08.rgba spec/png_suite/basic/basi4a16.png spec/png_suite/basic/basi4a16.rgba spec/png_suite/basic/basi6a08.png spec/png_suite/basic/basi6a08.rgba spec/png_suite/basic/basi6a16.png spec/png_suite/basic/basi6a16.rgba spec/png_suite/basic/basn0g01.png spec/png_suite/basic/basn0g01.rgba spec/png_suite/basic/basn0g02.png spec/png_suite/basic/basn0g02.rgba spec/png_suite/basic/basn0g04.png spec/png_suite/basic/basn0g04.rgba spec/png_suite/basic/basn0g08.png spec/png_suite/basic/basn0g08.rgba spec/png_suite/basic/basn0g16.png spec/png_suite/basic/basn0g16.rgba spec/png_suite/basic/basn2c08.png spec/png_suite/basic/basn2c08.rgba spec/png_suite/basic/basn2c16.png spec/png_suite/basic/basn2c16.rgba spec/png_suite/basic/basn3p01.png spec/png_suite/basic/basn3p01.rgba spec/png_suite/basic/basn3p02.png spec/png_suite/basic/basn3p02.rgba spec/png_suite/basic/basn3p04.png spec/png_suite/basic/basn3p04.rgba spec/png_suite/basic/basn3p08.png spec/png_suite/basic/basn3p08.rgba spec/png_suite/basic/basn4a08.png spec/png_suite/basic/basn4a08.rgba spec/png_suite/basic/basn4a16.png spec/png_suite/basic/basn4a16.rgba spec/png_suite/basic/basn6a08.png spec/png_suite/basic/basn6a08.rgba spec/png_suite/basic/basn6a16.png spec/png_suite/basic/basn6a16.rgba spec/png_suite/broken/x00n0g01.png spec/png_suite/broken/xcrn0g04.png spec/png_suite/broken/xlfn0g04.png spec/png_suite/chunk_ordering/oi1n0g16.png spec/png_suite/chunk_ordering/oi1n2c16.png spec/png_suite/chunk_ordering/oi2n0g16.png spec/png_suite/chunk_ordering/oi2n2c16.png spec/png_suite/chunk_ordering/oi4n0g16.png spec/png_suite/chunk_ordering/oi4n2c16.png spec/png_suite/chunk_ordering/oi9n0g16.png spec/png_suite/chunk_ordering/oi9n2c16.png spec/png_suite/compression_levels/z00n2c08.png spec/png_suite/compression_levels/z03n2c08.png spec/png_suite/compression_levels/z06n2c08.png spec/png_suite/compression_levels/z09n2c08.png spec/png_suite/filtering/f00n0g08.png spec/png_suite/filtering/f00n0g08.rgba spec/png_suite/filtering/f00n0g08_reference.png spec/png_suite/filtering/f00n0g08_reference.rgba spec/png_suite/filtering/f00n2c08.png spec/png_suite/filtering/f00n2c08.rgba spec/png_suite/filtering/f00n2c08_reference.png spec/png_suite/filtering/f00n2c08_reference.rgba spec/png_suite/filtering/f01n0g08.png spec/png_suite/filtering/f01n0g08.rgba spec/png_suite/filtering/f01n0g08_reference.png spec/png_suite/filtering/f01n0g08_reference.rgba spec/png_suite/filtering/f01n2c08.png spec/png_suite/filtering/f01n2c08.rgba spec/png_suite/filtering/f01n2c08_reference.png spec/png_suite/filtering/f01n2c08_reference.rgba spec/png_suite/filtering/f02n0g08.png spec/png_suite/filtering/f02n0g08.rgba spec/png_suite/filtering/f02n0g08_reference.png spec/png_suite/filtering/f02n0g08_reference.rgba spec/png_suite/filtering/f02n2c08.png spec/png_suite/filtering/f02n2c08.rgba spec/png_suite/filtering/f02n2c08_reference.png spec/png_suite/filtering/f02n2c08_reference.rgba spec/png_suite/filtering/f03n0g08.png spec/png_suite/filtering/f03n0g08.rgba spec/png_suite/filtering/f03n0g08_reference.png spec/png_suite/filtering/f03n0g08_reference.rgba spec/png_suite/filtering/f03n2c08.png spec/png_suite/filtering/f03n2c08.rgba spec/png_suite/filtering/f03n2c08_reference.png spec/png_suite/filtering/f03n2c08_reference.rgba spec/png_suite/filtering/f04n0g08.png spec/png_suite/filtering/f04n0g08.rgba spec/png_suite/filtering/f04n0g08_reference.png spec/png_suite/filtering/f04n0g08_reference.rgba spec/png_suite/filtering/f04n2c08.png spec/png_suite/filtering/f04n2c08.rgba spec/png_suite/filtering/f04n2c08_reference.png spec/png_suite/filtering/f04n2c08_reference.rgba spec/png_suite/gamma/g03n0g16.png spec/png_suite/gamma/g03n2c08.png spec/png_suite/gamma/g03n3p04.png spec/png_suite/gamma/g04n0g16.png spec/png_suite/gamma/g04n2c08.png spec/png_suite/gamma/g04n3p04.png spec/png_suite/gamma/g05n0g16.png spec/png_suite/gamma/g05n2c08.png spec/png_suite/gamma/g05n3p04.png spec/png_suite/gamma/g07n0g16.png spec/png_suite/gamma/g07n2c08.png spec/png_suite/gamma/g07n3p04.png spec/png_suite/gamma/g10n0g16.png spec/png_suite/gamma/g10n2c08.png spec/png_suite/gamma/g10n3p04.png spec/png_suite/gamma/g25n0g16.png spec/png_suite/gamma/g25n2c08.png spec/png_suite/gamma/g25n3p04.png spec/png_suite/metadata/cm0n0g04.png spec/png_suite/metadata/cm7n0g04.png spec/png_suite/metadata/cm9n0g04.png spec/png_suite/other/ccwn2c08.png spec/png_suite/other/ccwn3p08.png spec/png_suite/other/cdfn2c08.png spec/png_suite/other/cdhn2c08.png spec/png_suite/other/cdsn2c08.png spec/png_suite/other/cdun2c08.png spec/png_suite/other/ch1n3p04.png spec/png_suite/other/ch2n3p08.png spec/png_suite/other/cs3n2c16.png spec/png_suite/other/cs3n3p08.png spec/png_suite/other/cs5n2c08.png spec/png_suite/other/cs5n3p08.png spec/png_suite/other/cs8n2c08.png spec/png_suite/other/cs8n3p08.png spec/png_suite/other/ct0n0g04.png spec/png_suite/other/ct1n0g04.png spec/png_suite/other/ctzn0g04.png spec/png_suite/other/pp0n2c16.png spec/png_suite/other/pp0n6a08.png spec/png_suite/other/ps1n0g08.png spec/png_suite/other/ps1n2c16.png spec/png_suite/other/ps2n0g08.png spec/png_suite/other/ps2n2c16.png spec/png_suite/sizes/s01i3p01.png spec/png_suite/sizes/s01n3p01.png spec/png_suite/sizes/s02i3p01.png spec/png_suite/sizes/s02n3p01.png spec/png_suite/sizes/s03i3p01.png spec/png_suite/sizes/s03n3p01.png spec/png_suite/sizes/s04i3p01.png spec/png_suite/sizes/s04n3p01.png spec/png_suite/sizes/s05i3p02.png spec/png_suite/sizes/s05n3p02.png spec/png_suite/sizes/s06i3p02.png spec/png_suite/sizes/s06n3p02.png spec/png_suite/sizes/s07i3p02.png spec/png_suite/sizes/s07n3p02.png spec/png_suite/sizes/s08i3p02.png spec/png_suite/sizes/s08n3p02.png spec/png_suite/sizes/s09i3p02.png spec/png_suite/sizes/s09n3p02.png spec/png_suite/sizes/s32i3p04.png spec/png_suite/sizes/s32n3p04.png spec/png_suite/sizes/s33i3p04.png spec/png_suite/sizes/s33n3p04.png spec/png_suite/sizes/s34i3p04.png spec/png_suite/sizes/s34n3p04.png spec/png_suite/sizes/s35i3p04.png spec/png_suite/sizes/s35n3p04.png spec/png_suite/sizes/s36i3p04.png spec/png_suite/sizes/s36n3p04.png spec/png_suite/sizes/s37i3p04.png spec/png_suite/sizes/s37n3p04.png spec/png_suite/sizes/s38i3p04.png spec/png_suite/sizes/s38n3p04.png spec/png_suite/sizes/s39i3p04.png spec/png_suite/sizes/s39n3p04.png spec/png_suite/sizes/s40i3p04.png spec/png_suite/sizes/s40n3p04.png spec/png_suite/transparency/tbbn1g04.png spec/png_suite/transparency/tbbn2c16.png spec/png_suite/transparency/tbbn3p08.png spec/png_suite/transparency/tbgn2c16.png spec/png_suite/transparency/tbgn3p08.png spec/png_suite/transparency/tbrn2c08.png spec/png_suite/transparency/tbwn1g16.png spec/png_suite/transparency/tbwn3p08.png spec/png_suite/transparency/tbyn3p08.png spec/png_suite/transparency/tp0n1g08.png spec/png_suite/transparency/tp0n2c08.png spec/png_suite/transparency/tp0n3p08.png spec/png_suite/transparency/tp1n3p08.png spec/png_suite_spec.rb spec/resources/adam7.png spec/resources/circles.png spec/resources/clock.png spec/resources/clock_base.png spec/resources/clock_mask.png spec/resources/clock_mask_updated.png spec/resources/clock_nn_xdown_ydown.png spec/resources/clock_nn_xdown_yup.png spec/resources/clock_nn_xup_yup.png spec/resources/clock_updated.png spec/resources/composited.png spec/resources/cropped.png spec/resources/damaged_chunk.png spec/resources/damaged_signature.png spec/resources/lines.png spec/resources/operations.png spec/resources/partial_circles.png spec/resources/pixelstream.rgb spec/resources/pixelstream.rgba spec/resources/pixelstream_best_compression.png spec/resources/pixelstream_fast_rgba.png spec/resources/pixelstream_reference.png spec/resources/polygon_filled_horizontal.png spec/resources/polygon_filled_vertical.png spec/resources/polygon_triangle_filled.png spec/resources/polygon_unfilled.png spec/resources/rect.png spec/resources/replaced.png spec/resources/text_chunk.png spec/resources/ztxt_chunk.png spec/spec_helper.rb tasks/benchmarks.rake tasks/github-gem.rake)
|
41
|
+
s.files = %w(.gitignore .infinity_test .yardopts BENCHMARKS.rdoc Gemfile LICENSE README.rdoc Rakefile benchmarks/decoding_benchmark.rb benchmarks/encoding_benchmark.rb benchmarks/filesize_benchmark.rb chunky_png.gemspec lib/chunky_png.rb lib/chunky_png/canvas.rb lib/chunky_png/canvas/adam7_interlacing.rb lib/chunky_png/canvas/drawing.rb lib/chunky_png/canvas/masking.rb lib/chunky_png/canvas/operations.rb lib/chunky_png/canvas/png_decoding.rb lib/chunky_png/canvas/png_encoding.rb lib/chunky_png/canvas/resampling.rb lib/chunky_png/canvas/stream_exporting.rb lib/chunky_png/canvas/stream_importing.rb lib/chunky_png/chunk.rb lib/chunky_png/color.rb lib/chunky_png/compatibility.rb lib/chunky_png/datastream.rb lib/chunky_png/dimension.rb lib/chunky_png/image.rb lib/chunky_png/palette.rb lib/chunky_png/point.rb lib/chunky_png/rmagick.rb lib/chunky_png/vector.rb spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/masking_spec.rb spec/chunky_png/canvas/operations_spec.rb spec/chunky_png/canvas/png_decoding_spec.rb spec/chunky_png/canvas/png_encoding_spec.rb spec/chunky_png/canvas/resampling_spec.rb spec/chunky_png/canvas/stream_exporting_spec.rb spec/chunky_png/canvas/stream_importing_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/dimension_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/point_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png/vector_spec.rb spec/chunky_png_spec.rb spec/png_suite/background_chunks/bgai4a08.png spec/png_suite/background_chunks/bgai4a16.png spec/png_suite/background_chunks/bgan6a08.png spec/png_suite/background_chunks/bgan6a16.png spec/png_suite/background_chunks/bgbn4a08.png spec/png_suite/background_chunks/bggn4a16.png spec/png_suite/background_chunks/bgwn6a08.png spec/png_suite/background_chunks/bgyn6a16.png spec/png_suite/basic/basi0g01.png spec/png_suite/basic/basi0g01.rgba spec/png_suite/basic/basi0g02.png spec/png_suite/basic/basi0g02.rgba spec/png_suite/basic/basi0g04.png spec/png_suite/basic/basi0g04.rgba spec/png_suite/basic/basi0g08.png spec/png_suite/basic/basi0g08.rgba spec/png_suite/basic/basi0g16.png spec/png_suite/basic/basi0g16.rgba spec/png_suite/basic/basi2c08.png spec/png_suite/basic/basi2c08.rgba spec/png_suite/basic/basi2c16.png spec/png_suite/basic/basi2c16.rgba spec/png_suite/basic/basi3p01.png spec/png_suite/basic/basi3p01.rgba spec/png_suite/basic/basi3p02.png spec/png_suite/basic/basi3p02.rgba spec/png_suite/basic/basi3p04.png spec/png_suite/basic/basi3p04.rgba spec/png_suite/basic/basi3p08.png spec/png_suite/basic/basi3p08.rgba spec/png_suite/basic/basi4a08.png spec/png_suite/basic/basi4a08.rgba spec/png_suite/basic/basi4a16.png spec/png_suite/basic/basi4a16.rgba spec/png_suite/basic/basi6a08.png spec/png_suite/basic/basi6a08.rgba spec/png_suite/basic/basi6a16.png spec/png_suite/basic/basi6a16.rgba spec/png_suite/basic/basn0g01.png spec/png_suite/basic/basn0g01.rgba spec/png_suite/basic/basn0g02.png spec/png_suite/basic/basn0g02.rgba spec/png_suite/basic/basn0g04.png spec/png_suite/basic/basn0g04.rgba spec/png_suite/basic/basn0g08.png spec/png_suite/basic/basn0g08.rgba spec/png_suite/basic/basn0g16.png spec/png_suite/basic/basn0g16.rgba spec/png_suite/basic/basn2c08.png spec/png_suite/basic/basn2c08.rgba spec/png_suite/basic/basn2c16.png spec/png_suite/basic/basn2c16.rgba spec/png_suite/basic/basn3p01.png spec/png_suite/basic/basn3p01.rgba spec/png_suite/basic/basn3p02.png spec/png_suite/basic/basn3p02.rgba spec/png_suite/basic/basn3p04.png spec/png_suite/basic/basn3p04.rgba spec/png_suite/basic/basn3p08.png spec/png_suite/basic/basn3p08.rgba spec/png_suite/basic/basn4a08.png spec/png_suite/basic/basn4a08.rgba spec/png_suite/basic/basn4a16.png spec/png_suite/basic/basn4a16.rgba spec/png_suite/basic/basn6a08.png spec/png_suite/basic/basn6a08.rgba spec/png_suite/basic/basn6a16.png spec/png_suite/basic/basn6a16.rgba spec/png_suite/broken/x00n0g01.png spec/png_suite/broken/xcrn0g04.png spec/png_suite/broken/xlfn0g04.png spec/png_suite/chunk_ordering/oi1n0g16.png spec/png_suite/chunk_ordering/oi1n2c16.png spec/png_suite/chunk_ordering/oi2n0g16.png spec/png_suite/chunk_ordering/oi2n2c16.png spec/png_suite/chunk_ordering/oi4n0g16.png spec/png_suite/chunk_ordering/oi4n2c16.png spec/png_suite/chunk_ordering/oi9n0g16.png spec/png_suite/chunk_ordering/oi9n2c16.png spec/png_suite/compression_levels/z00n2c08.png spec/png_suite/compression_levels/z03n2c08.png spec/png_suite/compression_levels/z06n2c08.png spec/png_suite/compression_levels/z09n2c08.png spec/png_suite/filtering/f00n0g08.png spec/png_suite/filtering/f00n0g08.rgba spec/png_suite/filtering/f00n0g08_reference.png spec/png_suite/filtering/f00n0g08_reference.rgba spec/png_suite/filtering/f00n2c08.png spec/png_suite/filtering/f00n2c08.rgba spec/png_suite/filtering/f00n2c08_reference.png spec/png_suite/filtering/f00n2c08_reference.rgba spec/png_suite/filtering/f01n0g08.png spec/png_suite/filtering/f01n0g08.rgba spec/png_suite/filtering/f01n0g08_reference.png spec/png_suite/filtering/f01n0g08_reference.rgba spec/png_suite/filtering/f01n2c08.png spec/png_suite/filtering/f01n2c08.rgba spec/png_suite/filtering/f01n2c08_reference.png spec/png_suite/filtering/f01n2c08_reference.rgba spec/png_suite/filtering/f02n0g08.png spec/png_suite/filtering/f02n0g08.rgba spec/png_suite/filtering/f02n0g08_reference.png spec/png_suite/filtering/f02n0g08_reference.rgba spec/png_suite/filtering/f02n2c08.png spec/png_suite/filtering/f02n2c08.rgba spec/png_suite/filtering/f02n2c08_reference.png spec/png_suite/filtering/f02n2c08_reference.rgba spec/png_suite/filtering/f03n0g08.png spec/png_suite/filtering/f03n0g08.rgba spec/png_suite/filtering/f03n0g08_reference.png spec/png_suite/filtering/f03n0g08_reference.rgba spec/png_suite/filtering/f03n2c08.png spec/png_suite/filtering/f03n2c08.rgba spec/png_suite/filtering/f03n2c08_reference.png spec/png_suite/filtering/f03n2c08_reference.rgba spec/png_suite/filtering/f04n0g08.png spec/png_suite/filtering/f04n0g08.rgba spec/png_suite/filtering/f04n0g08_reference.png spec/png_suite/filtering/f04n0g08_reference.rgba spec/png_suite/filtering/f04n2c08.png spec/png_suite/filtering/f04n2c08.rgba spec/png_suite/filtering/f04n2c08_reference.png spec/png_suite/filtering/f04n2c08_reference.rgba spec/png_suite/gamma/g03n0g16.png spec/png_suite/gamma/g03n2c08.png spec/png_suite/gamma/g03n3p04.png spec/png_suite/gamma/g04n0g16.png spec/png_suite/gamma/g04n2c08.png spec/png_suite/gamma/g04n3p04.png spec/png_suite/gamma/g05n0g16.png spec/png_suite/gamma/g05n2c08.png spec/png_suite/gamma/g05n3p04.png spec/png_suite/gamma/g07n0g16.png spec/png_suite/gamma/g07n2c08.png spec/png_suite/gamma/g07n3p04.png spec/png_suite/gamma/g10n0g16.png spec/png_suite/gamma/g10n2c08.png spec/png_suite/gamma/g10n3p04.png spec/png_suite/gamma/g25n0g16.png spec/png_suite/gamma/g25n2c08.png spec/png_suite/gamma/g25n3p04.png spec/png_suite/metadata/cm0n0g04.png spec/png_suite/metadata/cm7n0g04.png spec/png_suite/metadata/cm9n0g04.png spec/png_suite/other/ccwn2c08.png spec/png_suite/other/ccwn3p08.png spec/png_suite/other/cdfn2c08.png spec/png_suite/other/cdhn2c08.png spec/png_suite/other/cdsn2c08.png spec/png_suite/other/cdun2c08.png spec/png_suite/other/ch1n3p04.png spec/png_suite/other/ch2n3p08.png spec/png_suite/other/cs3n2c16.png spec/png_suite/other/cs3n3p08.png spec/png_suite/other/cs5n2c08.png spec/png_suite/other/cs5n3p08.png spec/png_suite/other/cs8n2c08.png spec/png_suite/other/cs8n3p08.png spec/png_suite/other/ct0n0g04.png spec/png_suite/other/ct1n0g04.png spec/png_suite/other/ctzn0g04.png spec/png_suite/other/pp0n2c16.png spec/png_suite/other/pp0n6a08.png spec/png_suite/other/ps1n0g08.png spec/png_suite/other/ps1n2c16.png spec/png_suite/other/ps2n0g08.png spec/png_suite/other/ps2n2c16.png spec/png_suite/sizes/s01i3p01.png spec/png_suite/sizes/s01n3p01.png spec/png_suite/sizes/s02i3p01.png spec/png_suite/sizes/s02n3p01.png spec/png_suite/sizes/s03i3p01.png spec/png_suite/sizes/s03n3p01.png spec/png_suite/sizes/s04i3p01.png spec/png_suite/sizes/s04n3p01.png spec/png_suite/sizes/s05i3p02.png spec/png_suite/sizes/s05n3p02.png spec/png_suite/sizes/s06i3p02.png spec/png_suite/sizes/s06n3p02.png spec/png_suite/sizes/s07i3p02.png spec/png_suite/sizes/s07n3p02.png spec/png_suite/sizes/s08i3p02.png spec/png_suite/sizes/s08n3p02.png spec/png_suite/sizes/s09i3p02.png spec/png_suite/sizes/s09n3p02.png spec/png_suite/sizes/s32i3p04.png spec/png_suite/sizes/s32n3p04.png spec/png_suite/sizes/s33i3p04.png spec/png_suite/sizes/s33n3p04.png spec/png_suite/sizes/s34i3p04.png spec/png_suite/sizes/s34n3p04.png spec/png_suite/sizes/s35i3p04.png spec/png_suite/sizes/s35n3p04.png spec/png_suite/sizes/s36i3p04.png spec/png_suite/sizes/s36n3p04.png spec/png_suite/sizes/s37i3p04.png spec/png_suite/sizes/s37n3p04.png spec/png_suite/sizes/s38i3p04.png spec/png_suite/sizes/s38n3p04.png spec/png_suite/sizes/s39i3p04.png spec/png_suite/sizes/s39n3p04.png spec/png_suite/sizes/s40i3p04.png spec/png_suite/sizes/s40n3p04.png spec/png_suite/transparency/tbbn1g04.png spec/png_suite/transparency/tbbn2c16.png spec/png_suite/transparency/tbbn3p08.png spec/png_suite/transparency/tbgn2c16.png spec/png_suite/transparency/tbgn3p08.png spec/png_suite/transparency/tbrn2c08.png spec/png_suite/transparency/tbwn1g16.png spec/png_suite/transparency/tbwn3p08.png spec/png_suite/transparency/tbyn3p08.png spec/png_suite/transparency/tp0n1g08.png spec/png_suite/transparency/tp0n2c08.png spec/png_suite/transparency/tp0n3p08.png spec/png_suite/transparency/tp1n3p08.png spec/png_suite_spec.rb spec/resources/adam7.png spec/resources/bezier_five_point.png spec/resources/bezier_four_point.png spec/resources/bezier_four_point_flipped.png spec/resources/bezier_four_point_s.png spec/resources/bezier_six_point.png spec/resources/bezier_three_point.png spec/resources/bezier_three_point_flipped.png spec/resources/circles.png spec/resources/clock.png spec/resources/clock_base.png spec/resources/clock_mask.png spec/resources/clock_mask_updated.png spec/resources/clock_nn_xdown_ydown.png spec/resources/clock_nn_xdown_yup.png spec/resources/clock_nn_xup_yup.png spec/resources/clock_updated.png spec/resources/composited.png spec/resources/cropped.png spec/resources/damaged_chunk.png spec/resources/damaged_signature.png spec/resources/lines.png spec/resources/operations.png spec/resources/partial_circles.png spec/resources/pixelstream.rgb spec/resources/pixelstream.rgba spec/resources/pixelstream_best_compression.png spec/resources/pixelstream_fast_rgba.png spec/resources/pixelstream_reference.png spec/resources/polygon_filled_horizontal.png spec/resources/polygon_filled_vertical.png spec/resources/polygon_triangle_filled.png spec/resources/polygon_unfilled.png spec/resources/rect.png spec/resources/replaced.png spec/resources/text_chunk.png spec/resources/ztxt_chunk.png spec/spec_helper.rb tasks/benchmarks.rake tasks/github-gem.rake)
|
42
42
|
s.test_files = %w(spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/masking_spec.rb spec/chunky_png/canvas/operations_spec.rb spec/chunky_png/canvas/png_decoding_spec.rb spec/chunky_png/canvas/png_encoding_spec.rb spec/chunky_png/canvas/resampling_spec.rb spec/chunky_png/canvas/stream_exporting_spec.rb spec/chunky_png/canvas/stream_importing_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/dimension_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/point_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png/vector_spec.rb spec/chunky_png_spec.rb spec/png_suite_spec.rb)
|
43
43
|
end
|
data/lib/chunky_png.rb
CHANGED
@@ -25,7 +25,7 @@ module ChunkyPNG
|
|
25
25
|
|
26
26
|
# The current version of ChunkyPNG. This value will be updated
|
27
27
|
# automatically by them <tt>gem:release</tt> rake task.
|
28
|
-
VERSION = "1.0
|
28
|
+
VERSION = "1.1.0"
|
29
29
|
|
30
30
|
###################################################
|
31
31
|
# PNG international standard defined constants
|
@@ -104,7 +104,7 @@ module ChunkyPNG
|
|
104
104
|
class Exception < ::StandardError
|
105
105
|
end
|
106
106
|
|
107
|
-
# Exception that is raised for an
|
107
|
+
# Exception that is raised for an unsupported PNG image.
|
108
108
|
class NotSupported < ChunkyPNG::Exception
|
109
109
|
end
|
110
110
|
|
@@ -113,7 +113,7 @@ module ChunkyPNG
|
|
113
113
|
class SignatureMismatch < ChunkyPNG::Exception
|
114
114
|
end
|
115
115
|
|
116
|
-
# Exception that is raised if the CRC check for a block
|
116
|
+
# Exception that is raised if the CRC check for a block fails
|
117
117
|
class CRCMismatch < ChunkyPNG::Exception
|
118
118
|
end
|
119
119
|
|
data/lib/chunky_png/canvas.rb
CHANGED
@@ -10,7 +10,7 @@ require 'chunky_png/canvas/masking'
|
|
10
10
|
|
11
11
|
module ChunkyPNG
|
12
12
|
|
13
|
-
# The
|
13
|
+
# The ChunkyPNG::Canvas class represents a raster image as a matrix of
|
14
14
|
# pixels.
|
15
15
|
#
|
16
16
|
# This class supports loading a Canvas from a PNG datastream, and creating a
|
@@ -58,20 +58,25 @@ module ChunkyPNG
|
|
58
58
|
# CONSTRUCTORS
|
59
59
|
#################################################################
|
60
60
|
|
61
|
-
# Initializes a new Canvas instance
|
62
|
-
# @param [Integer] width The width in pixels of this canvas
|
63
|
-
# @param [Integer] width The height in pixels of this canvas
|
64
|
-
# @param [ChunkyPNG::Pixel, Array<ChunkyPNG::Color>] initial The initial value of te pixels:
|
61
|
+
# Initializes a new Canvas instance.
|
65
62
|
#
|
66
|
-
#
|
63
|
+
# @overload initialize(width, height, background_color)
|
64
|
+
# @param [Integer] width The width in pixels of this canvas
|
65
|
+
# @param [Integer] height The height in pixels of this canvas
|
66
|
+
# @param [Integer, ...] background_color The initial background color of this canvas.
|
67
|
+
# This can be a color value or any value that {ChunkyPNG::Color.parse} can handle.
|
67
68
|
#
|
68
|
-
#
|
69
|
-
#
|
69
|
+
# @overload initialize(width, height, initial)
|
70
|
+
# @param [Integer] width The width in pixels of this canvas
|
71
|
+
# @param [Integer] height The height in pixels of this canvas
|
72
|
+
# @param [Array<Integer>] initial The initial pizel values. Must be an array with
|
73
|
+
# <tt>width * height</tt> elements.
|
70
74
|
def initialize(width, height, initial = ChunkyPNG::Color::TRANSPARENT)
|
71
75
|
|
72
76
|
@width, @height = width, height
|
73
77
|
|
74
|
-
if initial.kind_of?(Array)
|
78
|
+
if initial.kind_of?(Array)
|
79
|
+
raise ArgumentError, "The initial array should have #{width}x#{height} = #{width*height} elements!" unless initial.length == width * height
|
75
80
|
@pixels = initial
|
76
81
|
else
|
77
82
|
@pixels = Array.new(width * height, ChunkyPNG::Color.parse(initial))
|
@@ -100,7 +105,7 @@ module ChunkyPNG
|
|
100
105
|
#################################################################
|
101
106
|
|
102
107
|
# Returns the dimension (width x height) for this canvas.
|
103
|
-
# @return [ChunkyPNG::Dimension] A dimension
|
108
|
+
# @return [ChunkyPNG::Dimension] A dimension instance with the width and height set for this canvas.
|
104
109
|
def dimension
|
105
110
|
ChunkyPNG::Dimension.new(width, height)
|
106
111
|
end
|
@@ -112,20 +117,10 @@ module ChunkyPNG
|
|
112
117
|
end
|
113
118
|
|
114
119
|
# Replaces a single pixel in this canvas.
|
115
|
-
#
|
116
|
-
# @
|
117
|
-
#
|
118
|
-
#
|
119
|
-
# @param [Integer] y The y-coordinate of the pixel (row)
|
120
|
-
# @param [Integer] color The new color for the provided coordinates.
|
121
|
-
# @return [Integer] The new color value for this pixel, i.e. <tt>color</tt>.
|
122
|
-
#
|
123
|
-
# @overload []=(point, color)
|
124
|
-
# Sets the color value of a pixel given point-like value.
|
125
|
-
# @param [ChunkyPNG::Point, ...] point The point on the canvas to replace.
|
126
|
-
# @param [Integer] color The new color for the provided coordinates.
|
127
|
-
# @return [Integer] The new color value for this pixel, i.e. <tt>color</tt>.
|
128
|
-
#
|
120
|
+
# @param [Integer] x The x-coordinate of the pixel (column)
|
121
|
+
# @param [Integer] y The y-coordinate of the pixel (row)
|
122
|
+
# @param [Integer] color The new color for the provided coordinates.
|
123
|
+
# @return [Integer] The new color value for this pixel, i.e. <tt>color</tt>.
|
129
124
|
# @raise [ChunkyPNG::OutOfBounds] when the coordinates are outside of the image's dimensions.
|
130
125
|
# @see #set_pixel
|
131
126
|
def []=(x, y, color)
|
@@ -140,7 +135,7 @@ module ChunkyPNG
|
|
140
135
|
#
|
141
136
|
# @param [Integer] x The x-coordinate of the pixel (column)
|
142
137
|
# @param [Integer] y The y-coordinate of the pixel (row)
|
143
|
-
# @param [
|
138
|
+
# @param [Integer] pixel The new color for the provided coordinates.
|
144
139
|
# @return [Integer] The new color value for this pixel, i.e. <tt>color</tt>.
|
145
140
|
def set_pixel(x, y, color)
|
146
141
|
@pixels[y * width + x] = color
|
@@ -151,7 +146,7 @@ module ChunkyPNG
|
|
151
146
|
#
|
152
147
|
# @param [Integer] x The x-coordinate of the pixel (column)
|
153
148
|
# @param [Integer] y The y-coordinate of the pixel (row)
|
154
|
-
# @param [
|
149
|
+
# @param [Integer] pixel The new color value for the provided coordinates.
|
155
150
|
# @return [Integer] The new color value for this pixel, i.e. <tt>color</tt>, or
|
156
151
|
# <tt>nil</tt> if the coordinates are out of bounds.
|
157
152
|
def set_pixel_if_within_bounds(x, y, color)
|
@@ -160,18 +155,9 @@ module ChunkyPNG
|
|
160
155
|
end
|
161
156
|
|
162
157
|
# Returns a single pixel's color value from this canvas.
|
163
|
-
#
|
164
|
-
# @
|
165
|
-
#
|
166
|
-
# @param [ChunkyPNG::Point, ...] point The coordinates of the pixel as point.
|
167
|
-
# @return [Integer] The current color value at the provided coordinates.
|
168
|
-
#
|
169
|
-
# @overload [](x, y)
|
170
|
-
# Returns the color value given a x- and y-coordinate.
|
171
|
-
# @param [Integer] x The x-coordinate of the pixel (column)
|
172
|
-
# @param [Integer] y The y-coordinate of the pixel (row)
|
173
|
-
# @return [Integer] The current color value at the provided coordinates.
|
174
|
-
#
|
158
|
+
# @param [Integer] x The x-coordinate of the pixel (column)
|
159
|
+
# @param [Integer] y The y-coordinate of the pixel (row)
|
160
|
+
# @return [Integer] The current color value at the provided coordinates.
|
175
161
|
# @raise [ChunkyPNG::OutOfBounds] when the coordinates are outside of the image's dimensions.
|
176
162
|
# @see #get_pixel
|
177
163
|
def [](x, y)
|
@@ -257,7 +243,7 @@ module ChunkyPNG
|
|
257
243
|
end
|
258
244
|
|
259
245
|
# Returns the palette used for this canvas.
|
260
|
-
# @return [ChunkyPNG::Palette] A
|
246
|
+
# @return [ChunkyPNG::Palette] A palette which contains all the colors that are
|
261
247
|
# being used for this image.
|
262
248
|
def palette
|
263
249
|
ChunkyPNG::Palette.from_canvas(self)
|
@@ -3,7 +3,7 @@ module ChunkyPNG
|
|
3
3
|
|
4
4
|
# Methods for decoding and encoding Adam7 interlacing.
|
5
5
|
#
|
6
|
-
# Adam7 interlacing
|
6
|
+
# Adam7 interlacing extracts 7 pass images out of a single image, that can be encoded to a
|
7
7
|
# stream separately so the image can be built up progressively. The module is included into
|
8
8
|
# ChunkyPNG canvas and is used to extract the pass images from the original image, or to
|
9
9
|
# reconstruct an original image from separate pass images.
|
@@ -29,6 +29,57 @@ module ChunkyPNG
|
|
29
29
|
set_pixel(x, y, ChunkyPNG::Color.compose(color, get_pixel(x, y)))
|
30
30
|
end
|
31
31
|
|
32
|
+
# Draws a Bezier curve
|
33
|
+
# @param [Array, Point] A collection of control points
|
34
|
+
# @return [Chunky:PNG::Canvas] Itself, with the curve drawn
|
35
|
+
def bezier_curve(points, stroke_color = ChunkyPNG::Color::BLACK)
|
36
|
+
|
37
|
+
points = ChunkyPNG::Vector(*points)
|
38
|
+
case points.length
|
39
|
+
when 0, 1; return self
|
40
|
+
when 2; return line(points[0].x, points[0].y, points[1].x, points[1].y, stroke_color)
|
41
|
+
end
|
42
|
+
|
43
|
+
curve_points = Array.new
|
44
|
+
|
45
|
+
t = 0
|
46
|
+
n = points.length - 1
|
47
|
+
bicof = 0
|
48
|
+
|
49
|
+
while t <= 100
|
50
|
+
cur_p = ChunkyPNG::Point.new(0,0)
|
51
|
+
|
52
|
+
# Generate a float of t.
|
53
|
+
t_f = t / 100.00
|
54
|
+
|
55
|
+
cur_p.x += ((1 - t_f) ** n) * points[0].x
|
56
|
+
cur_p.y += ((1 - t_f) ** n) * points[0].y
|
57
|
+
|
58
|
+
for i in 1...points.length - 1
|
59
|
+
bicof = binomial_coefficient(n , i)
|
60
|
+
|
61
|
+
cur_p.x += (bicof * (1 - t_f) ** (n - i)) * (t_f ** i) * points[i].x
|
62
|
+
cur_p.y += (bicof * (1 - t_f) ** (n - i)) * (t_f ** i) * points[i].y
|
63
|
+
i += 1
|
64
|
+
end
|
65
|
+
|
66
|
+
cur_p.x += (t_f ** n) * points[n].x
|
67
|
+
cur_p.y += (t_f ** n) * points[n].y
|
68
|
+
|
69
|
+
curve_points << cur_p
|
70
|
+
|
71
|
+
bicof = 0
|
72
|
+
t += 1
|
73
|
+
end
|
74
|
+
|
75
|
+
curve_points.each_cons(2) do |p1, p2|
|
76
|
+
line_xiaolin_wu(p1.x.round, p1.y.round, p2.x.round, p2.y.round, stroke_color)
|
77
|
+
end
|
78
|
+
|
79
|
+
return self
|
80
|
+
end
|
81
|
+
|
82
|
+
|
32
83
|
# Draws an anti-aliased line using Xiaolin Wu's algorithm.
|
33
84
|
#
|
34
85
|
# @param [Integer] x0 The x-coordinate of the first control point.
|
@@ -37,7 +88,7 @@ module ChunkyPNG
|
|
37
88
|
# @param [Integer] y1 The y-coordinate of the second control point.
|
38
89
|
# @param [Integer] stroke_color The color to use for this line.
|
39
90
|
# @param [true, false] inclusive Whether to draw the last pixel.
|
40
|
-
# Set to false when drawing
|
91
|
+
# Set to false when drawing multiple lines in a path.
|
41
92
|
# @return [ChunkyPNG::Canvas] Itself, with the line drawn.
|
42
93
|
def line_xiaolin_wu(x0, y0, x1, y1, stroke_color, inclusive = true)
|
43
94
|
|
@@ -239,6 +290,26 @@ module ChunkyPNG
|
|
239
290
|
|
240
291
|
return self
|
241
292
|
end
|
293
|
+
|
294
|
+
private
|
295
|
+
|
296
|
+
# Calculates the binomial coefficient for n over k.
|
297
|
+
#
|
298
|
+
# @param [Integer] n first parameter in coeffient (the number on top when looking at the mathematic formula)
|
299
|
+
# @param [Integer] k k-element, second parameter in coeffient (the number on the bottom when looking at the mathematic formula)
|
300
|
+
# @return [Integer] The binomial coeffcient of (n,k)
|
301
|
+
def binomial_coefficient(n, k)
|
302
|
+
return 1 if n == k || k == 0
|
303
|
+
return n if k == 1
|
304
|
+
return -1 if n < k
|
305
|
+
|
306
|
+
# calculate factorials
|
307
|
+
fact_n = (2..n).inject(1) { |carry, i| carry * i }
|
308
|
+
fact_k = (2..k).inject(1) { |carry, i| carry * i }
|
309
|
+
fact_n_sub_k = (2..(n - k)).inject(1) { |carry, i| carry * i }
|
310
|
+
|
311
|
+
fact_n / (fact_k * fact_n_sub_k)
|
312
|
+
end
|
242
313
|
end
|
243
314
|
end
|
244
315
|
end
|
@@ -2,7 +2,7 @@ module ChunkyPNG
|
|
2
2
|
class Canvas
|
3
3
|
|
4
4
|
# The ChunkyPNG::Canvas::Masking module defines methods to perform masking
|
5
|
-
# and theming
|
5
|
+
# and theming operations on a {ChunkyPNG::Canvas}. The module is included into the Canvas class so all
|
6
6
|
# these methods are available on every canvas.
|
7
7
|
#
|
8
8
|
# @see ChunkyPNG::Canvas
|
@@ -20,7 +20,7 @@ module ChunkyPNG
|
|
20
20
|
#
|
21
21
|
# @param [Integer] old_theme_color The original theme color in this image.
|
22
22
|
# @param [Integer] new_theme_color The color to replace the old theme color with.
|
23
|
-
# @param [Integer] The
|
23
|
+
# @param [Integer] The background color on which the theme colored pixels are placed.
|
24
24
|
# @param [Integer] tolerance The tolerance level to use when extracting the mask image. Five is
|
25
25
|
# the default; increase this if the masked image does not extract all the required pixels,
|
26
26
|
# decrease it if too many pixels get extracted.
|
@@ -45,7 +45,7 @@ module ChunkyPNG
|
|
45
45
|
# {#change_theme_color!} will perform this in one go.
|
46
46
|
#
|
47
47
|
# @param [Integer] mask_color The current theme color.
|
48
|
-
# @param [Integer] bg_color The background color on which the theme colored
|
48
|
+
# @param [Integer] bg_color The background color on which the theme colored pixels are applied.
|
49
49
|
# @param [Integer] tolerance The tolerance level to use when extracting the mask image. Five is
|
50
50
|
# the default; increase this if the masked image does not extract all the required pixels,
|
51
51
|
# decrease it if too many pixels get extracted.
|
@@ -72,7 +72,7 @@ module ChunkyPNG
|
|
72
72
|
|
73
73
|
# Changes the color of a mask image.
|
74
74
|
#
|
75
|
-
# This method works on
|
75
|
+
# This method works on a canvas extracted out of another image using the {#extract_mask} method.
|
76
76
|
# It can then be applied on the extracted base image. See {#change_theme_color!} to perform
|
77
77
|
# these operations in one go.
|
78
78
|
#
|
@@ -19,8 +19,8 @@ module ChunkyPNG
|
|
19
19
|
#
|
20
20
|
# @param [ChunkyPNG::Canvas] other The foreground canvas to compose on the
|
21
21
|
# current canvas, using alpha compositing.
|
22
|
-
# @param [Integer] offset_x The x-offset to apply the new
|
23
|
-
# @param [Integer] offset_y The y-offset to apply the new
|
22
|
+
# @param [Integer] offset_x The x-offset to apply the new foreground on.
|
23
|
+
# @param [Integer] offset_y The y-offset to apply the new foreground on.
|
24
24
|
# @return [ChunkyPNG::Canvas] Returns itself, but with the other canvas composed onto it.
|
25
25
|
# @raise [ChunkyPNG::OutOfBounds] when the other canvas doesn't fit on this one,
|
26
26
|
# given the offset and size of the other canvas.
|
@@ -63,8 +63,8 @@ module ChunkyPNG
|
|
63
63
|
# them with semi-transparent pixels from the foreground image, see {#compose!}.
|
64
64
|
#
|
65
65
|
# @param [ChunkyPNG::Canvas] other The foreground canvas to get the pixels from.
|
66
|
-
# @param [Integer] offset_x The x-offset to apply the new
|
67
|
-
# @param [Integer] offset_y The y-offset to apply the new
|
66
|
+
# @param [Integer] offset_x The x-offset to apply the new foreground on.
|
67
|
+
# @param [Integer] offset_y The y-offset to apply the new foreground on.
|
68
68
|
# @return [ChunkyPNG::Canvas] Returns itself, but with the other canvas placed onto it.
|
69
69
|
# @raise [ChunkyPNG::OutOfBounds] when the other canvas doesn't fit on this one,
|
70
70
|
# given the offset and size of the other canvas.
|
@@ -170,7 +170,7 @@ module ChunkyPNG
|
|
170
170
|
alias_method :flip!, :flip_horizontally!
|
171
171
|
alias_method :flip, :flip_horizontally
|
172
172
|
|
173
|
-
# Flips the image vertically, leaving the
|
173
|
+
# Flips the image vertically, leaving the original intact.
|
174
174
|
#
|
175
175
|
# This will flip the image on its vertical axis, e.g. pixels on the left will now
|
176
176
|
# be pixels on the right. Chaining this method twice will return the original canvas.
|
@@ -239,7 +239,7 @@ module ChunkyPNG
|
|
239
239
|
# Rotates the image 90 degrees counter-clockwise in place.
|
240
240
|
#
|
241
241
|
# This method will change the original canvas. See {#rotate_left} for a
|
242
|
-
# version that leaves the canvas intact and returns a new
|
242
|
+
# version that leaves the canvas intact and returns a new rotated canvas
|
243
243
|
# instead.
|
244
244
|
#
|
245
245
|
# @return [ChunkyPNG::Canvas] Itself, but rotated.
|
@@ -149,7 +149,7 @@ module ChunkyPNG
|
|
149
149
|
end
|
150
150
|
|
151
151
|
# Extract a bit from a byte on a given index.
|
152
|
-
# @param [Integer] byte The byte (0..255) value to extract a
|
152
|
+
# @param [Integer] byte The byte (0..255) value to extract a bit from.
|
153
153
|
# @param [Integer] index The index within the byte. This should be 0..7;
|
154
154
|
# the value will be modded by 8 to enforce this.
|
155
155
|
# @return [Integer] Either 1 or 0.
|
@@ -203,7 +203,7 @@ module ChunkyPNG
|
|
203
203
|
|
204
204
|
# Decodes a scanline of a 1-bit, indexed image into a row of pixels.
|
205
205
|
# @param [String] stream The stream to decode from.
|
206
|
-
# @param [Integer] pos The position in the stream on
|
206
|
+
# @param [Integer] pos The position in the stream on which the scanline starts (including the filter byte).
|
207
207
|
# @param [Integer] width The width in pixels of the scanline.
|
208
208
|
# @return [Array<Integer>] An array of decoded pixels.
|
209
209
|
def decode_png_pixels_from_scanline_indexed_1bit(stream, pos, width)
|
@@ -428,8 +428,8 @@ module ChunkyPNG
|
|
428
428
|
# noop - this method shouldn't get called.
|
429
429
|
end
|
430
430
|
|
431
|
-
# Decodes a scanline in a
|
432
|
-
# This will
|
431
|
+
# Decodes a scanline in a pixelstream that was encoded using SUB filtering.
|
432
|
+
# This will change the pixelstream to have unfiltered values.
|
433
433
|
# @params (see #decode_png_str_scanline)
|
434
434
|
# @return [void]
|
435
435
|
def decode_png_str_scanline_sub(stream, pos, prev_pos, line_length, pixel_size)
|
@@ -438,8 +438,8 @@ module ChunkyPNG
|
|
438
438
|
end
|
439
439
|
end
|
440
440
|
|
441
|
-
# Decodes a scanline in a
|
442
|
-
# This will
|
441
|
+
# Decodes a scanline in a pixelstream that was encoded using UP filtering.
|
442
|
+
# This will change the pixelstream to have unfiltered values.
|
443
443
|
# @params (see #decode_png_str_scanline)
|
444
444
|
# @return [void]
|
445
445
|
def decode_png_str_scanline_up(stream, pos, prev_pos, line_length, pixel_size)
|
@@ -449,8 +449,8 @@ module ChunkyPNG
|
|
449
449
|
end
|
450
450
|
end
|
451
451
|
|
452
|
-
# Decodes a scanline in a
|
453
|
-
# This will
|
452
|
+
# Decodes a scanline in a pixelstream that was encoded using AVERAGE filtering.
|
453
|
+
# This will change the pixelstream to have unfiltered values.
|
454
454
|
# @params (see #decode_png_str_scanline)
|
455
455
|
# @return [void]
|
456
456
|
def decode_png_str_scanline_average(stream, pos, prev_pos, line_length, pixel_size)
|
@@ -461,8 +461,8 @@ module ChunkyPNG
|
|
461
461
|
end
|
462
462
|
end
|
463
463
|
|
464
|
-
# Decodes a scanline in a
|
465
|
-
# This will
|
464
|
+
# Decodes a scanline in a pixelstream that was encoded using PAETH filtering.
|
465
|
+
# This will change the pixelstream to have unfiltered values.
|
466
466
|
# @params (see #decode_png_str_scanline)
|
467
467
|
# @return [void]
|
468
468
|
def decode_png_str_scanline_paeth(stream, pos, prev_pos, line_length, pixel_size)
|
@@ -15,7 +15,7 @@ module ChunkyPNG
|
|
15
15
|
# IEND chunk and possibly a PLTE chunk.
|
16
16
|
#
|
17
17
|
# For interlaced images, the initial image is first split into 7 subimages.
|
18
|
-
# These images get encoded
|
18
|
+
# These images get encoded exactly as above, and the result gets combined
|
19
19
|
# before the compression step.
|
20
20
|
#
|
21
21
|
# @see ChunkyPNG::Canvas::PNGDecoding
|
@@ -36,7 +36,7 @@ module ChunkyPNG
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Writes the canvas to a file, encoded as a PNG image.
|
39
|
-
# @param [String]
|
39
|
+
# @param [String] filename The file to save the PNG image to.
|
40
40
|
# @param constraints (see ChunkyPNG::Canvas::PNGEncoding#to_datastream)
|
41
41
|
# @return [void]
|
42
42
|
def save(filename, constraints = {})
|
@@ -112,7 +112,7 @@ module ChunkyPNG
|
|
112
112
|
else raise ChunkyPNG::Exception, "Unknown encoding preset: #{constraints.inspect}"
|
113
113
|
end
|
114
114
|
|
115
|
-
# Do not create a
|
115
|
+
# Do not create a palette when the encoding is given and does not require a palette.
|
116
116
|
if encoding[:color_mode]
|
117
117
|
if encoding[:color_mode] == ChunkyPNG::COLOR_INDEXED
|
118
118
|
self.encoding_palette = self.palette
|
@@ -178,7 +178,7 @@ module ChunkyPNG
|
|
178
178
|
# Encodes the canvas according to the PNG format specification with a given color
|
179
179
|
# mode and Adam7 interlacing.
|
180
180
|
#
|
181
|
-
# This method will split the original
|
181
|
+
# This method will split the original canvas in 7 smaller canvases and encode them
|
182
182
|
# one by one, concatenating the resulting strings.
|
183
183
|
#
|
184
184
|
# @param [Integer] color_mode The color mode to use for encoding.
|
@@ -11,9 +11,9 @@ module ChunkyPNG
|
|
11
11
|
module Resampling
|
12
12
|
|
13
13
|
# Resamples the canvas.
|
14
|
-
# @param [Integer] new_width The width of the
|
15
|
-
# @param [Integer] new_height The height of the
|
16
|
-
# @
|
14
|
+
# @param [Integer] new_width The width of the resampled canvas.
|
15
|
+
# @param [Integer] new_height The height of the resampled canvas.
|
16
|
+
# @return [ChunkyPNG::Canvas] A new canvas instance with the resampled pixels.
|
17
17
|
def resample_nearest_neighbor!(new_width, new_height)
|
18
18
|
|
19
19
|
resampled_image = self.class.new(new_width.to_i, new_height.to_i)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ChunkyPNG
|
2
2
|
class Canvas
|
3
3
|
|
4
|
-
# Methods to
|
4
|
+
# Methods to quickly load a canvas from a stream, encoded in RGB, RGBA, BGR or ABGR format.
|
5
5
|
module StreamImporting
|
6
6
|
|
7
7
|
# Creates a canvas by reading pixels from an RGB formatted stream with a
|
data/lib/chunky_png/chunk.rb
CHANGED
@@ -4,7 +4,7 @@ module ChunkyPNG
|
|
4
4
|
# contained within, help with handling these chunks. It supports both
|
5
5
|
# reading and writing chunks.
|
6
6
|
#
|
7
|
-
# All
|
7
|
+
# All chunk types are instances of the {ChunkyPNG::Chunk::Base} class. For
|
8
8
|
# some chunk types a specialized class is available, e.g. the IHDR chunk is
|
9
9
|
# represented by the {ChunkyPNG::Chunk::Header} class. These specialized
|
10
10
|
# classes help accessing the content of the chunk. All other chunks are
|
@@ -72,7 +72,7 @@ module ChunkyPNG
|
|
72
72
|
|
73
73
|
# Writes the chunk to the IO stream.
|
74
74
|
#
|
75
|
-
# It will call
|
75
|
+
# It will call the +content+ method to get the content for this chunk,
|
76
76
|
# and will calculate and append the checksum automatically.
|
77
77
|
# @param [IO] io The IO stream to write to.
|
78
78
|
def write(io)
|
data/lib/chunky_png/color.rb
CHANGED
@@ -40,7 +40,7 @@ module ChunkyPNG
|
|
40
40
|
# library, the concepts of pixels and colors are both used, and they are
|
41
41
|
# both represented by a Integer.
|
42
42
|
#
|
43
|
-
# Pixels/colors are represented in RGBA
|
43
|
+
# Pixels/colors are represented in RGBA components. Each of the four
|
44
44
|
# components is stored with a depth of 8 bits (maximum value = 255 =
|
45
45
|
# {ChunkyPNG::Color::MAX}). Together, these components are stored in a 4-byte
|
46
46
|
# Integer.
|
@@ -208,7 +208,7 @@ module ChunkyPNG
|
|
208
208
|
|
209
209
|
# Returns the opaque value of this color by removing the alpha channel.
|
210
210
|
# @param [Integer] value The color to transform.
|
211
|
-
# @return [Integer] The
|
211
|
+
# @return [Integer] The opaque color
|
212
212
|
def opaque!(value)
|
213
213
|
value | 0x000000ff
|
214
214
|
end
|
@@ -320,7 +320,7 @@ module ChunkyPNG
|
|
320
320
|
# operation if alpha composition.
|
321
321
|
#
|
322
322
|
# If the color cannot be decomposed, this method will return the fully
|
323
|
-
#
|
323
|
+
# transparent variant of the mask color.
|
324
324
|
#
|
325
325
|
# @param [Integer] color The color that was the result of compositing.
|
326
326
|
# @param [Integer] mask The opaque variant of the color that was being composed
|
@@ -341,7 +341,7 @@ module ChunkyPNG
|
|
341
341
|
# all of which should be opaque.
|
342
342
|
#
|
343
343
|
# @param [Integer] color The color that was the result of compositing.
|
344
|
-
# @param [Integer] mask The
|
344
|
+
# @param [Integer] mask The opaque variant of the color that was being composed
|
345
345
|
# @param [Integer] bg The background color on which the color was composed.
|
346
346
|
# @param [Integer] tolerance The decomposition tolerance level, a value between 0 and 255.
|
347
347
|
# @return [Boolean] True if the alpha component can be decomposed successfully.
|
@@ -361,7 +361,7 @@ module ChunkyPNG
|
|
361
361
|
# value of this method is undefined.
|
362
362
|
#
|
363
363
|
# @param [Integer] color The color that was the result of compositing.
|
364
|
-
# @param [Integer] mask The
|
364
|
+
# @param [Integer] mask The opaque variant of the color that was being composed
|
365
365
|
# @param [Integer] bg The background color on which the color was composed.
|
366
366
|
# @return [Integer] The best fitting alpha channel, a value between 0 and 255.
|
367
367
|
# @see #alpha_decomposable?
|
@@ -373,7 +373,7 @@ module ChunkyPNG
|
|
373
373
|
# Decomposes an alpha channel for either the r, g or b color channel.
|
374
374
|
# @param [:r, :g, :b] channel The channel to decompose the alpha channel from.
|
375
375
|
# @param [Integer] color The color that was the result of compositing.
|
376
|
-
# @param [Integer] mask The
|
376
|
+
# @param [Integer] mask The opaque variant of the color that was being composed
|
377
377
|
# @param [Integer] bg The background color on which the color was composed.
|
378
378
|
# @return [Integer] The decomposed alpha value for the channel.
|
379
379
|
def decompose_alpha_component(channel, color, mask, bg)
|
@@ -383,7 +383,7 @@ module ChunkyPNG
|
|
383
383
|
|
384
384
|
# Decomposes the alpha channels for the r, g and b color channel.
|
385
385
|
# @param [Integer] color The color that was the result of compositing.
|
386
|
-
# @param [Integer] mask The
|
386
|
+
# @param [Integer] mask The opaque variant of the color that was being composed
|
387
387
|
# @param [Integer] bg The background color on which the color was composed.
|
388
388
|
# @return [Array<Integer>] The decomposed alpha values for the r, g and b channels.
|
389
389
|
def decompose_alpha_components(color, mask, bg)
|
@@ -449,7 +449,7 @@ module ChunkyPNG
|
|
449
449
|
# COLOR CONSTANTS
|
450
450
|
####################################################################
|
451
451
|
|
452
|
-
# @return [Hash<Symbol, Integer>] All the
|
452
|
+
# @return [Hash<Symbol, Integer>] All the predefined color names in HTML.
|
453
453
|
PREDEFINED_COLORS = {
|
454
454
|
:aliceblue => 0xf0f8ff00,
|
455
455
|
:antiquewhite => 0xfaebd700,
|
@@ -607,7 +607,7 @@ module ChunkyPNG
|
|
607
607
|
# all return the same color value.
|
608
608
|
#
|
609
609
|
# You can include a opacity level in the color name (e.g. <tt>'red @ 0.5'</tt>) or give
|
610
|
-
# an
|
610
|
+
# an explicit opacity value as second argument. If no opacity value is given, the color
|
611
611
|
# will be fully opaque.
|
612
612
|
#
|
613
613
|
# @param [Symbol, String] color_name The color name. It may include an opacity specifier
|
@@ -622,7 +622,7 @@ module ChunkyPNG
|
|
622
622
|
base_color_name = $1.gsub(/[^a-z]+/i, '').downcase.to_sym
|
623
623
|
return PREDEFINED_COLORS[base_color_name] | opacity if PREDEFINED_COLORS.has_key?(base_color_name)
|
624
624
|
end
|
625
|
-
raise
|
625
|
+
raise ArgumentError, "Unknown color name #{color_name}!"
|
626
626
|
end
|
627
627
|
|
628
628
|
# @return [Integer] Black pixel/color
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ChunkyPNG
|
2
2
|
|
3
3
|
# The Datastream class represents a PNG formatted datastream. It supports
|
4
|
-
# both reading from and writing to strings,
|
4
|
+
# both reading from and writing to strings, streams and files.
|
5
5
|
#
|
6
6
|
# A PNG datastream begins with the PNG signature, and than contains multiple
|
7
7
|
# chunks, starting with a header (IHDR) chunk and finishing with an end
|
@@ -113,7 +113,7 @@ module ChunkyPNG
|
|
113
113
|
# This will iterate over the chunks using the order in which the chunks
|
114
114
|
# should appear in the PNG file.
|
115
115
|
#
|
116
|
-
# @yield [chunk] Yields the chunks in this
|
116
|
+
# @yield [chunk] Yields the chunks in this datastream, one by one in the correct order.
|
117
117
|
# @yieldparam [ChunkyPNG::Chunk::Base] chunk A chunk in this datastream.
|
118
118
|
# @see ChunkyPNG::Datastream#chunks
|
119
119
|
def each_chunk
|
data/lib/chunky_png/dimension.rb
CHANGED
@@ -57,15 +57,15 @@ module ChunkyPNG
|
|
57
57
|
# @private
|
58
58
|
DIMENSION_REGEXP = /^[\(\[\{]?(\d+)\s*[x,]?\s*(\d+)[\)\]\}]?$/
|
59
59
|
|
60
|
-
# @return [Integer] The width-
|
60
|
+
# @return [Integer] The width-component of this dimension.
|
61
61
|
attr_accessor :width
|
62
62
|
|
63
|
-
# @return [Integer] The height-
|
63
|
+
# @return [Integer] The height-component of this dimension.
|
64
64
|
attr_accessor :height
|
65
65
|
|
66
66
|
# Initializes a new dimension instance.
|
67
|
-
# @param [Integer] width The width-
|
68
|
-
# @param [Integer] height The height-
|
67
|
+
# @param [Integer] width The width-component of the new dimension.
|
68
|
+
# @param [Integer] height The height-component of the new dimension.
|
69
69
|
def initialize(width, height)
|
70
70
|
@width, @height = width.to_i, height.to_i
|
71
71
|
end
|
@@ -78,7 +78,7 @@ module ChunkyPNG
|
|
78
78
|
|
79
79
|
# Checks whether a point is within bounds of this dimension.
|
80
80
|
# @param [ChunkyPNG::Point, ...] A point-like to bounds-check.
|
81
|
-
# @return [true, false] True iff the
|
81
|
+
# @return [true, false] True iff the x and y coordinate fall in this dimension.
|
82
82
|
# @see ChunkyPNG.Point
|
83
83
|
def include?(*point_like)
|
84
84
|
point = ChunkyPNG::Point(*point_like)
|
@@ -110,4 +110,4 @@ module ChunkyPNG
|
|
110
110
|
|
111
111
|
alias_method :to_ary, :to_a
|
112
112
|
end
|
113
|
-
end
|
113
|
+
end
|
data/lib/chunky_png/image.rb
CHANGED
@@ -6,7 +6,7 @@ module ChunkyPNG
|
|
6
6
|
# @see ChunkyPNG::Canvas
|
7
7
|
class Image < Canvas
|
8
8
|
|
9
|
-
# The
|
9
|
+
# The minimum size of bytes the value of a metadata field should be before compression
|
10
10
|
# is enabled for the chunk.
|
11
11
|
METADATA_COMPRESSION_TRESHOLD = 300
|
12
12
|
|
@@ -64,7 +64,7 @@ module ChunkyPNG
|
|
64
64
|
return ds
|
65
65
|
end
|
66
66
|
|
67
|
-
# Reads a ChunkyPNG::Image
|
67
|
+
# Reads a ChunkyPNG::Image instance from a data stream.
|
68
68
|
#
|
69
69
|
# Besides decoding the canvas, this will also read the metadata fields
|
70
70
|
# from the datastream.
|
data/lib/chunky_png/palette.rb
CHANGED
@@ -15,8 +15,8 @@ module ChunkyPNG
|
|
15
15
|
|
16
16
|
# Builds a new palette given a set (Enumerable instance) of colors.
|
17
17
|
#
|
18
|
-
# @param [
|
19
|
-
# This
|
18
|
+
# @param [Enumerable<Integer>] enum The set of colors to include in this palette.
|
19
|
+
# This Enumerable can contains duplicates.
|
20
20
|
# @param [Array] decoding_map An array of colors in the exact order at which
|
21
21
|
# they appeared in the palette chunk, so that this array can be used for decoding.
|
22
22
|
def initialize(enum, decoding_map = nil)
|
@@ -173,7 +173,7 @@ module ChunkyPNG
|
|
173
173
|
end
|
174
174
|
|
175
175
|
# Determines the most suitable colormode for this palette.
|
176
|
-
# @return [Integer] The colormode which would create the
|
176
|
+
# @return [Integer] The colormode which would create the smallest possible
|
177
177
|
# file for images that use this exact palette.
|
178
178
|
def best_color_settings
|
179
179
|
if black_and_white?
|
data/lib/chunky_png/point.rb
CHANGED
@@ -3,7 +3,7 @@ module ChunkyPNG
|
|
3
3
|
# Factory method to create {ChunkyPNG::Point} instances.
|
4
4
|
#
|
5
5
|
# This method tries to be as flexible as possible with regards to the given input: besides
|
6
|
-
#
|
6
|
+
# explicit coordinates, this method also accepts arrays, hashes, strings, {ChunkyPNG::Dimension}
|
7
7
|
# instances and anything that responds to <tt>:x</tt> and <tt>:y</tt>.
|
8
8
|
#
|
9
9
|
# @overload Point(x, y)
|
@@ -81,11 +81,11 @@ module ChunkyPNG
|
|
81
81
|
|
82
82
|
alias_method :==, :eql?
|
83
83
|
|
84
|
-
#
|
84
|
+
# Compares 2 points.
|
85
85
|
#
|
86
86
|
# It will first compare the y coordinate, and it only takes the x-coordinate into
|
87
87
|
# account if the y-coordinates of the points are identical. This way, an array of
|
88
|
-
# points will be sorted into the order in which
|
88
|
+
# points will be sorted into the order in which they would occur in the pixels
|
89
89
|
# array returned by {ChunkyPNG::Canvas#pixels}.
|
90
90
|
#
|
91
91
|
# @param [ChunkyPNG::Point] other The point to compare this point with.
|
data/lib/chunky_png/vector.rb
CHANGED
@@ -40,7 +40,7 @@ module ChunkyPNG
|
|
40
40
|
|
41
41
|
# Initializes a vector based on a list of Point instances.
|
42
42
|
#
|
43
|
-
# You usually do not want to use this method
|
43
|
+
# You usually do not want to use this method directly, but call {ChunkyPNG.Vector} instead.
|
44
44
|
#
|
45
45
|
# @param [Array<ChunkyPNG::Point>] points
|
46
46
|
# @see ChunkyPNG.Vector
|
@@ -64,6 +64,13 @@ module ChunkyPNG
|
|
64
64
|
yield(points.last, points.first) if close
|
65
65
|
end
|
66
66
|
|
67
|
+
# Returns the point with the given indexof this vector.
|
68
|
+
# @param [Integer] index The 0-based index of the point in this vector.
|
69
|
+
# @param [ChunkyPNG::Point] The point instance.
|
70
|
+
def [](index)
|
71
|
+
points[index]
|
72
|
+
end
|
73
|
+
|
67
74
|
# Returns an enumerator that will iterate over all the edges in this vector.
|
68
75
|
# @param (see #each_edge)
|
69
76
|
# @return [Enumerator] The enumerator that iterates over the edges.
|
@@ -120,4 +120,51 @@ describe ChunkyPNG::Canvas::Drawing do
|
|
120
120
|
subject.polygon('(2,2) (20,5) (5,20)').should equal(subject)
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
describe '#bezier_curve' do
|
125
|
+
subject { ChunkyPNG::Canvas.new(24, 24, ChunkyPNG::Color::WHITE) }
|
126
|
+
|
127
|
+
it "should draw a bezier curve starting at the first point" do
|
128
|
+
subject.bezier_curve('3,20 10,10, 20,20')
|
129
|
+
subject[3, 20].should == ChunkyPNG::Color::BLACK
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should draw a bezier curve ending at the last point" do
|
133
|
+
subject.bezier_curve('3,20 10,10, 20,20')
|
134
|
+
subject[20, 20].should == ChunkyPNG::Color::BLACK
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should draw a bezier curve with a color of green" do
|
138
|
+
subject.bezier_curve('3,20 10,10, 20,20', :green)
|
139
|
+
subject[3, 20].should == ChunkyPNG::Color(:green)
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should draw a three point bezier curve" do
|
143
|
+
subject.bezier_curve('1,23 12,10 23,23').should == reference_canvas('bezier_three_point')
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should draw a three point bezier curve flipped" do
|
147
|
+
subject.bezier_curve('1,1 12,15 23,1').should == reference_canvas('bezier_three_point_flipped')
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should draw a four point bezier curve" do
|
151
|
+
subject.bezier_curve('1,23 1,5 22,5 22,23').should == reference_canvas('bezier_four_point')
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should draw a four point bezier curve flipped" do
|
155
|
+
subject.bezier_curve('1,1 1,19 22,19 22,1').should == reference_canvas('bezier_four_point_flipped')
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should draw a four point bezier curve with a shape of an s" do
|
159
|
+
subject.bezier_curve('1,23 1,5 22,23 22,5').should == reference_canvas('bezier_four_point_s')
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should draw a five point bezier curve" do
|
163
|
+
subject.bezier_curve('10,23 1,10 12,5 23,10 14,23').should == reference_canvas('bezier_five_point')
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should draw a six point bezier curve" do
|
167
|
+
subject.bezier_curve('1,23 4,15 8,20 2,2 23,15 23,1').should == reference_canvas('bezier_six_point')
|
168
|
+
end
|
169
|
+
end
|
123
170
|
end
|
@@ -8,6 +8,35 @@ describe ChunkyPNG::Canvas do
|
|
8
8
|
it { should respond_to(:height) }
|
9
9
|
it { should respond_to(:pixels) }
|
10
10
|
|
11
|
+
describe '#initialize' do
|
12
|
+
it "should accept a single color value as background color" do
|
13
|
+
canvas = ChunkyPNG::Canvas.new(2, 2, 'red @ 0.8')
|
14
|
+
canvas[1, 0].should == ChunkyPNG::Color.parse('red @ 0.8')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise an error if the color value is not understood" do
|
18
|
+
lambda { ChunkyPNG::Canvas.new(2, 2, :nonsense) }.should raise_error(ArgumentError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should accept an array as initial pixel values" do
|
22
|
+
canvas = ChunkyPNG::Canvas.new(2, 2, [1,2,3,4])
|
23
|
+
canvas[0, 0].should == 1
|
24
|
+
canvas[1, 0].should == 2
|
25
|
+
canvas[0, 1].should == 3
|
26
|
+
canvas[1, 1].should == 4
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should raise an ArgumentError if the initial array does not have the correct number of elements" do
|
30
|
+
lambda { ChunkyPNG::Canvas.new(2, 2, [1,2,3]) }.should raise_error(ArgumentError)
|
31
|
+
lambda { ChunkyPNG::Canvas.new(2, 2, [1,2,3,4,5]) }.should raise_error(ArgumentError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should use a transparent background by default" do
|
35
|
+
canvas = ChunkyPNG::Canvas.new(1, 1)
|
36
|
+
canvas[0,0].should == ChunkyPNG::Color::TRANSPARENT
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
11
40
|
describe '#dimension' do
|
12
41
|
it "should return the dimensions as a Dimension instance" do
|
13
42
|
subject.dimension.should == ChunkyPNG::Dimension('1x1')
|
@@ -126,7 +126,7 @@ describe ChunkyPNG::Color do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should raise for an unkown color name" do
|
129
|
-
lambda { html_color(:nonsense) }.should raise_error(
|
129
|
+
lambda { html_color(:nonsense) }.should raise_error(ArgumentError)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
- 0
|
8
7
|
- 1
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 1.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Willem van Bergen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-19 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -324,6 +324,13 @@ files:
|
|
324
324
|
- spec/png_suite/transparency/tp1n3p08.png
|
325
325
|
- spec/png_suite_spec.rb
|
326
326
|
- spec/resources/adam7.png
|
327
|
+
- spec/resources/bezier_five_point.png
|
328
|
+
- spec/resources/bezier_four_point.png
|
329
|
+
- spec/resources/bezier_four_point_flipped.png
|
330
|
+
- spec/resources/bezier_four_point_s.png
|
331
|
+
- spec/resources/bezier_six_point.png
|
332
|
+
- spec/resources/bezier_three_point.png
|
333
|
+
- spec/resources/bezier_three_point_flipped.png
|
327
334
|
- spec/resources/circles.png
|
328
335
|
- spec/resources/clock.png
|
329
336
|
- spec/resources/clock_base.png
|