Browse Source

save_pdf: full-length crop marks

Implements #184

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

100
lib/squib/args/sheet.rb

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

2
lib/squib/graphics/save_pdf.rb

@ -38,7 +38,7 @@ module Squib
bar.increment bar.increment
cc.reset_clip cc.reset_clip
cc.translate(-x, -y) 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 x += card.width + sheet.gap - 2 * sheet.trim
if x > (sheet.width - card_width - sheet.margin) if x > (sheet.width - card_width - sheet.margin)
x = 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_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_left: '0.3in', crop_margin_right: '0.45in',
crop_margin_top: '0.4in', crop_margin_bottom: '0.85in' 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 end

Loading…
Cancel
Save