diff --git a/lib/squib/graphics/image.rb b/lib/squib/graphics/image.rb index 4a0e51c..697852c 100644 --- a/lib/squib/graphics/image.rb +++ b/lib/squib/graphics/image.rb @@ -56,7 +56,6 @@ module Squib cc.rotate(trans.angle) cc.scale(scale_width, scale_height) cc.operator = paint.blend unless paint.blend == :none - #FIXME Alpha is no longer used since we are not using cc.paint anymore if paint.mask.to_s.empty? cc.render_rsvg_handle(svg, svg_args.id) else diff --git a/spec/graphics/graphics_images_spec.rb b/spec/graphics/graphics_images_spec.rb index 42ef5d8..84d0d27 100644 --- a/spec/graphics/graphics_images_spec.rb +++ b/spec/graphics/graphics_images_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' require 'squib' +require 'ostruct' describe Squib::Card do @@ -7,6 +8,9 @@ describe Squib::Card do let(:context) { double(Cairo::Context) } let(:svg) { double(RSVG::Handle) } let(:png) { double(Cairo::ImageSurface) } + let(:box) { OpenStruct.new({x: 37, y: 38, width: :native, height: :native})} + let(:paint) { OpenStruct.new({alpha: 0.9, blend: :none, mask: '' })} + let(:trans) { OpenStruct.new({angle: 0.0})} before(:each) do allow(Cairo::Context).to receive(:new).and_return(context) @@ -33,7 +37,7 @@ describe Squib::Card do card = Squib::Card.new(deck, 100, 150) # png(file, x, y, alpha, blend, angle) - card.png('foo.png', 37, 38, :native, :native, 0.9, :none, 0.0, nil) + card.png('foo.png', box, paint, trans) end it 'sets blend when needed' do @@ -41,11 +45,14 @@ describe Squib::Card do expect(context).to receive(:operator=).with(:overlay).once card = Squib::Card.new(deck, 100, 150) - card.png('foo.png', 37, 38, :native, :native, 0.9, :overlay, 0.0, nil) + paint.blend = :overlay + card.png('foo.png', box, paint, trans) end end context '#svg' do + let(:svg_args) { OpenStruct.new({data: '', id: 'id'}) } + it 'makes all the expected calls on a smoke test' do expect(svg).to receive(:width).and_return(100).twice expect(svg).to receive(:height).and_return(100).twice @@ -58,8 +65,7 @@ describe Squib::Card do expect(context).to receive(:restore).once card = Squib::Card.new(deck, 100, 150) - # svg(file, data, id, x, y, width, height, alpha, blend, angle) - card.svg(nil, '', 'id', 37, 38, :native, :native, 0.9, :none, 0.0, nil) + card.svg(nil, svg_args, box, paint, trans) end it 'sets blend when needed' do @@ -68,7 +74,8 @@ describe Squib::Card do expect(context).to receive(:operator=).with(:overlay).once card = Squib::Card.new(deck, 100, 150) - card.svg(nil, '', nil, 37, 38, :native, :native, 0.9, :overlay, 0.0, nil) + paint.blend = :overlay + card.svg(nil, svg_args, box, paint, trans) end it 'sets width & height when needed' do @@ -78,7 +85,9 @@ describe Squib::Card do expect(context).to receive(:scale).with(2.0, 3.0).once card = Squib::Card.new(deck, 100, 150) - card.svg(nil, '', nil, 37, 38, 200, 300, 0.9, :none, 0.0, nil) + box.width = 200 + box.height = 300 + card.svg(nil, svg_args, box, paint, trans) end end