Browse Source

save_pdf: full-length crop marks

Implements #184

[skip ci]
dev
Andy Meneely 9 years ago
parent
commit
db0bf38ec0
  1. 32
      lib/squib/args/sheet.rb
  2. 2
      lib/squib/graphics/save_pdf.rb
  3. 7
      samples/saves/_save_pdf.rb

32
lib/squib/args/sheet.rb

@ -60,6 +60,10 @@ module Squib
end
end
def validate_crop_marks(arg)
arg.to_s.downcase.to_sym unless arg == false
end
def validate_fill_color(arg)
colorify(arg, @custom_colors)
end
@ -85,6 +89,33 @@ module Squib
end
def crop_coords(x, y, deck_w, deck_h)
case crop_marks
when false
[]
when :full
[
{
# Vertical, Left
x1: x + trim + crop_margin_left, y1: 0,
x2: x + trim + crop_margin_left, y2: height - margin + 1
},
{
# Vertical, Right
x1: x + deck_w - trim - crop_margin_right, y1: 0,
x2: x + deck_w - trim - crop_margin_right, y2: height - margin + 1
},
{
# Horizontal, Top
x1: 0 , y1: y + trim + crop_margin_top,
x2: width - margin + 1, y2: y + trim + crop_margin_top
},
{
# Horizontal, Bottom
x1: 0 , y1: y + deck_h - trim - crop_margin_bottom,
x2: width - margin + 1, y2: y + deck_h - trim - crop_margin_bottom
},
]
else # e.g. :margin
[
{ # Vertical, Upper-left
x1: x + trim + crop_margin_left, y1: 0,
@ -120,6 +151,7 @@ module Squib
},
]
end
end
end

2
lib/squib/graphics/save_pdf.rb

@ -38,7 +38,7 @@ module Squib
bar.increment
cc.reset_clip
cc.translate(-x, -y)
draw_crop_marks(cc, x, y, sheet) if sheet.crop_marks
draw_crop_marks(cc, x, y, sheet)
x += card.width + sheet.gap - 2 * sheet.trim
if x > (sheet.width - card_width - sheet.margin)
x = sheet.margin

7
samples/saves/_save_pdf.rb

@ -15,4 +15,11 @@ Squib::Deck.new(cards: 8) do
crop_stroke_dash: '5 5', crop_stroke_color: :red, crop_stroke_width: 4.0,
crop_margin_left: '0.3in', crop_margin_right: '0.45in',
crop_margin_top: '0.4in', crop_margin_bottom: '0.85in'
# Full crop marks
save_pdf file: 'crops-full.pdf', crop_marks: :full,
trim: 0, gap: 20,
crop_stroke_dash: '5 5', crop_stroke_color: :red, crop_stroke_width: 4.0,
crop_margin_left: '0.3in', crop_margin_right: '0.45in',
crop_margin_top: '0.4in', crop_margin_bottom: '0.85in'
end

Loading…
Cancel
Save