Skip to content

Commit

Permalink
Use consistent color serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
pointlessone committed Dec 21, 2016
1 parent 7018a1b commit 72eaa92
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/prawn/graphics/color.rb
Expand Up @@ -119,7 +119,7 @@ def normalize_color(color)
end

def color_to_s(color)
normalize_color(color).map { |c| '%.3f' % c }.join(' ')
PDF::Core.real_params normalize_color(color)
end

def color_space(color)
Expand Down
2 changes: 1 addition & 1 deletion spec/soft_mask_spec.rb
Expand Up @@ -56,7 +56,7 @@ def make_soft_mask
end

extgstate = PDF::Inspector::ExtGState.analyze(@pdf.render).extgstates.first
expect(extgstate[:soft_mask][:G].data).to eq("q\n/DeviceRGB cs\n0.000 0.000 0.000 scn\n/DeviceRGB CS\n0.000 0.000 0.000 SCN\n1 w\n0 J\n0 j\n[] 0 d\n/DeviceRGB cs\n0.502 0.502 0.502 scn\n100.0 -100.0 200.0 200.0 re\nf\nQ\n")
expect(extgstate[:soft_mask][:G].data).to eq("q\n/DeviceRGB cs\n0.0 0.0 0.0 scn\n/DeviceRGB CS\n0.0 0.0 0.0 SCN\n1 w\n0 J\n0 j\n[] 0 d\n/DeviceRGB cs\n0.502 0.502 0.502 scn\n100.0 -100.0 200.0 200.0 re\nf\nQ\n")
end

it "should not create duplicate extended graphics states" do
Expand Down
6 changes: 3 additions & 3 deletions spec/stamp_spec.rb
Expand Up @@ -161,8 +161,8 @@
@pdf.stamp("MyStamp")
stamps = PDF::Inspector::XObject.analyze(@pdf.render)
stamp_stream = stamps.xobject_streams[:Stamp1].data
expect(stamp_stream).to include("/DeviceCMYK cs\n1.000 1.000 0.200 0.000 scn")
expect(stamp_stream).to include("/DeviceCMYK CS\n1.000 1.000 0.200 0.000 SCN")
expect(stamp_stream).to include("/DeviceCMYK cs\n1.0 1.0 0.2 0.0 scn")
expect(stamp_stream).to include("/DeviceCMYK CS\n1.0 1.0 0.2 0.0 SCN")
end

it "should save the color space even when same as current page color space" do
Expand All @@ -174,6 +174,6 @@
@pdf.stamp("MyStamp")
stamps = PDF::Inspector::XObject.analyze(@pdf.render)
stamp_stream = stamps.xobject_streams[:Stamp1].data
expect(stamp_stream).to include("/DeviceCMYK CS\n1.000 1.000 0.200 0.000 SCN")
expect(stamp_stream).to include("/DeviceCMYK CS\n1.0 1.0 0.2 0.0 SCN")
end
end

0 comments on commit 72eaa92

Please sign in to comment.