|
|
|
@ -28,15 +28,15 @@ describe Squib::Graphics::CairoContextWrapper do |
|
|
|
expect { subject.set_source_squibcolor(nil) }.to raise_error('nil is not a valid color') |
|
|
|
expect { subject.set_source_squibcolor(nil) }.to raise_error('nil is not a valid color') |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context 'regex variations for linear gradients' do |
|
|
|
context 'regex variations for linear gradients' do |
|
|
|
before(:each) do |
|
|
|
before(:each) do |
|
|
|
dbl = double(Cairo::LinearPattern) |
|
|
|
dbl = double(Cairo::LinearPattern) |
|
|
|
|
|
|
|
mtx = double(Cairo::Matrix) |
|
|
|
expect(Cairo::LinearPattern).to receive(:new).with(1,2,3,4).and_return(dbl) |
|
|
|
expect(Cairo::LinearPattern).to receive(:new).with(1,2,3,4).and_return(dbl) |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, 'blue') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, 'blue') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, 'red') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, 'red') |
|
|
|
|
|
|
|
expect(cairo).to receive(:matrix).and_return(mtx) |
|
|
|
|
|
|
|
expect(dbl).to receive(:matrix=).with(mtx) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -49,9 +49,12 @@ describe Squib::Graphics::CairoContextWrapper do |
|
|
|
context 'regex variations for radial gradients' do |
|
|
|
context 'regex variations for radial gradients' do |
|
|
|
before(:each) do |
|
|
|
before(:each) do |
|
|
|
dbl = double(Cairo::RadialPattern) |
|
|
|
dbl = double(Cairo::RadialPattern) |
|
|
|
|
|
|
|
mtx = double(Cairo::Matrix) |
|
|
|
expect(Cairo::RadialPattern).to receive(:new).with(1,2,5,3,4,6).and_return(dbl) |
|
|
|
expect(Cairo::RadialPattern).to receive(:new).with(1,2,5,3,4,6).and_return(dbl) |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, 'blue') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, 'blue') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, 'red') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, 'red') |
|
|
|
|
|
|
|
expect(cairo).to receive(:matrix).and_return(mtx) |
|
|
|
|
|
|
|
expect(dbl).to receive(:matrix=).with(mtx) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -64,24 +67,32 @@ describe Squib::Graphics::CairoContextWrapper do |
|
|
|
context 'regex handles hash notation' do |
|
|
|
context 'regex handles hash notation' do |
|
|
|
it 'on radial patterns' do |
|
|
|
it 'on radial patterns' do |
|
|
|
dbl = double(Cairo::RadialPattern) |
|
|
|
dbl = double(Cairo::RadialPattern) |
|
|
|
|
|
|
|
mtx = double(Cairo::Matrix) |
|
|
|
expect(Cairo::RadialPattern).to receive(:new).with(1,2,5,3,4,6).and_return(dbl) |
|
|
|
expect(Cairo::RadialPattern).to receive(:new).with(1,2,5,3,4,6).and_return(dbl) |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, '#def') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, '#def') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, '#112233') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, '#112233') |
|
|
|
|
|
|
|
expect(cairo).to receive(:matrix).and_return(mtx) |
|
|
|
|
|
|
|
expect(dbl).to receive(:matrix=).with(mtx) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
subject.set_source_squibcolor('(1,2,5) (3,4,6) #def@0 #112233@1') |
|
|
|
subject.set_source_squibcolor('(1,2,5) (3,4,6) #def@0 #112233@1') |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'on linear patterns' do |
|
|
|
it 'on linear patterns' do |
|
|
|
dbl = double(Cairo::LinearPattern) |
|
|
|
dbl = double(Cairo::LinearPattern) |
|
|
|
|
|
|
|
mtx = double(Cairo::Matrix) |
|
|
|
expect(Cairo::LinearPattern).to receive(:new).with(1,2,3,4).and_return(dbl) |
|
|
|
expect(Cairo::LinearPattern).to receive(:new).with(1,2,3,4).and_return(dbl) |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, '#def') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(0.0, '#def') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, '#112233') |
|
|
|
expect(dbl).to receive(:add_color_stop).with(1.0, '#112233') |
|
|
|
|
|
|
|
expect(cairo).to receive(:matrix).and_return(mtx) |
|
|
|
|
|
|
|
expect(dbl).to receive(:matrix=).with(mtx) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
expect(cairo).to receive(:set_source).with(dbl) |
|
|
|
subject.set_source_squibcolor('(1,2) (3,4) #def@0 #112233@1') |
|
|
|
subject.set_source_squibcolor('(1,2) (3,4) #def@0 #112233@1') |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context 'flips' do |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context '#flip' do |
|
|
|
it 'in the basic case' do |
|
|
|
it 'in the basic case' do |
|
|
|
dbl = double(Cairo::Matrix) |
|
|
|
dbl = double(Cairo::Matrix) |
|
|
|
expect(Cairo::Matrix).to receive(:new).with(-1.0, 0.0, 0.0, -1.0, 6.0, 8.0).and_return(dbl) |
|
|
|
expect(Cairo::Matrix).to receive(:new).with(-1.0, 0.0, 0.0, -1.0, 6.0, 8.0).and_return(dbl) |
|
|
|
|