Sha256: 59ad83ceff9e687164176f5e10aae44bfedcb7f1a821d5853dcd60509b113be8

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 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
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
chunky_png-0.7.3 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.7.1 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.7.0 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.6.0 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.5.8 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.5.7 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.5.6 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.5.5 spec/chunky_png/canvas/drawing_spec.rb
chunky_png-0.5.4 spec/chunky_png/canvas/drawing_spec.rb