Sha256: 40e0a5de56be0bd68a42adef57198ba3f47dba12956f7ef8de1a894936099c80

Contents?: true

Size: 1.56 KB

Versions: 15

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe ChunkyPNG::Canvas::Drawing do
  
  describe '#point' do
    it "should compose colors correctly" do
      canvas = ChunkyPNG::Canvas.new(1, 1, ChunkyPNG::Color.rgb(200, 150, 100))
      canvas.point(0,0, ChunkyPNG::Color.rgba(100, 150, 200, 128))
      canvas[0,0].should == ChunkyPNG::Color.rgb(150, 150, 150)
    end
  end
  
  describe '#line' do
    it "should draw lines correctly with anti-aliasing" do
      canvas = ChunkyPNG::Canvas.new(32, 32, ChunkyPNG::Color::WHITE)
      
      canvas.line( 0,  0, 31, 31, ChunkyPNG::Color::BLACK)
      canvas.line( 0, 31, 31,  0, ChunkyPNG::Color::BLACK)
      canvas.line(15, 31, 15,  0, ChunkyPNG::Color.rgba(200,   0,   0, 128))
      canvas.line( 0, 15, 31, 15, ChunkyPNG::Color.rgba(200,   0,   0, 128))
      canvas.line( 0, 15, 31, 31, ChunkyPNG::Color.rgba(  0, 200,   0, 128))
      canvas.line( 0, 15, 31,  0, ChunkyPNG::Color.rgba(  0, 200,   0, 128))
      canvas.line(15,  0, 31, 31, ChunkyPNG::Color.rgba(  0,   0, 200, 128))
      canvas.line(15,  0,  0, 31, ChunkyPNG::Color.rgba(  0,   0, 200, 128))
      
      canvas.should == reference_canvas('lines')
    end
  end
  
  describe '#rect' do
    it "should draw a rectangle with the correct colors" do
      canvas = ChunkyPNG::Canvas.new(16, 16, ChunkyPNG::Color::WHITE)
      canvas.rect(1, 1, 10, 10, ChunkyPNG::Color.rgb(0, 255, 0), ChunkyPNG::Color.rgba(255, 0, 0, 100))
      canvas.rect(5, 5, 14, 14, ChunkyPNG::Color.rgb(0, 0, 255), ChunkyPNG::Color.rgba(255, 255, 0, 100))
      canvas.should == reference_canvas('rect')
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
chunky_png-1.0.0.beta2 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-1.0.0.beta1 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.12.0 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.11.1 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.11.0 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.10.5 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.10.4 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.10.3 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.10.2 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.10.1 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.10.0 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.9.2 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.9.1 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.9.0 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.8.0 spec/chunky_png/canvas/drawing_spec.rb