sprues: better handling of trim args
parent
3bf5eeb102
commit
aee8884a9e
|
|
@ -44,7 +44,12 @@ gap
|
|||
trim
|
||||
default: ``0``
|
||||
|
||||
the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play). Supports :doc:`/units`.
|
||||
the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play). Supports :doc:`/units`. Must be the same for all cards.
|
||||
|
||||
trim_radius
|
||||
default: ``0``
|
||||
|
||||
the rounded rectangle radius around the card to trim before saving. Supports :doc:`/units`. Must be the same for all cards.
|
||||
|
||||
crop_marks
|
||||
default: ``false``
|
||||
|
|
|
|||
|
|
@ -54,7 +54,12 @@ gap
|
|||
trim
|
||||
default ``0``
|
||||
|
||||
the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play). Supports :doc:`/units`.
|
||||
the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play). Supports :doc:`/units`. Must be the same for all cards.
|
||||
|
||||
trim_radius
|
||||
default: ``0``
|
||||
|
||||
the rounded rectangle radius around the card to trim before saving. Supports :doc:`/units`. Must be the same for all cards.
|
||||
|
||||
rtl
|
||||
default ``false``
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ module Squib
|
|||
else
|
||||
tmpl = Sprue.load sprue_file.sprue, dpi
|
||||
Graphics::SaveSpruePNG.
|
||||
new(self, tmpl, batch).
|
||||
new(self, tmpl, sheet).
|
||||
render_sheet(range)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ module Squib
|
|||
|
||||
def self.parameters
|
||||
{
|
||||
count_format: '%02d',
|
||||
crop_margin_bottom: 0,
|
||||
crop_margin_left: 0,
|
||||
crop_margin_right: 0,
|
||||
|
|
@ -35,6 +36,7 @@ module Squib
|
|||
gap: 0,
|
||||
height: 2550,
|
||||
margin: 75,
|
||||
prefix: 'sheet_',
|
||||
rows: :infinite,
|
||||
columns: 5,
|
||||
trim_radius: 38,
|
||||
|
|
@ -91,8 +93,12 @@ module Squib
|
|||
(count.to_f / columns.to_f).ceil
|
||||
end
|
||||
|
||||
def full_filename
|
||||
"#{dir}/#{file}"
|
||||
def full_filename(i=nil)
|
||||
if i.nil?
|
||||
"#{dir}/#{file}"
|
||||
else
|
||||
"#{dir}/#{prefix}#{count_format % i}.png"
|
||||
end
|
||||
end
|
||||
|
||||
def crop_coords(x, y, deck_w, deck_h)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ module Squib
|
|||
module Graphics
|
||||
# Helper class to generate templated sheet.
|
||||
class SaveSprue
|
||||
def initialize(deck, tmpl, save_args)
|
||||
def initialize(deck, tmpl, sheet_args)
|
||||
@deck = deck
|
||||
@tmpl = tmpl
|
||||
@page_number = 1
|
||||
@save_args = save_args #might be Args::Sheet or Args::SaveBatch
|
||||
@sheet_args = sheet_args # might be Args::Sheet or Args::SaveBatch
|
||||
@overlay_lines = @tmpl.crop_lines.select do |line|
|
||||
line['overlay_on_cards']
|
||||
end
|
||||
|
|
@ -32,7 +32,7 @@ module Squib
|
|||
draw_card cc, card,
|
||||
slot['x'], slot['y'],
|
||||
slot['rotate'],
|
||||
@save_args.trim[i], @save_args.trim_radius[i]
|
||||
@sheet_args.trim, @sheet_args.trim_radius
|
||||
|
||||
bar.increment
|
||||
end
|
||||
|
|
@ -122,15 +122,11 @@ module Squib
|
|||
end
|
||||
|
||||
def check_oversized_card
|
||||
all_fit = @save_args.trim.inject(true) do |fits, trim|
|
||||
fits &&
|
||||
(@deck.width - 2.0 * trim) <= @tmpl.card_width &&
|
||||
(@deck.height - 2.0 * trim) <= @tmpl.card_height
|
||||
end
|
||||
Squib.logger.warn {
|
||||
'Card size is larger than sprue\'s expected card size. '\
|
||||
'Cards may overlap.'
|
||||
} unless all_fit
|
||||
"Card size is larger than sprue's expected card size "\
|
||||
"of #{@tmpl.card_width}x#{@tmpl.card_height}. Cards may overlap."
|
||||
} if (@deck.width - 2.0 * @sheet_args.trim) > @tmpl.card_width ||
|
||||
(@deck.height - 2.0 * @sheet_args.trim) > @tmpl.card_height
|
||||
end
|
||||
|
||||
def draw_card(cc, card, x, y, angle, trim, trim_radius)
|
||||
|
|
@ -182,7 +178,7 @@ module Squib
|
|||
end
|
||||
|
||||
def full_filename
|
||||
@save_args.full_filename
|
||||
@sheet_args.full_filename
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -202,7 +198,7 @@ module Squib
|
|||
end
|
||||
|
||||
def full_filename
|
||||
@save_args.full_filename @page_number
|
||||
@sheet_args.full_filename @page_number
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
require 'squib'
|
||||
require_relative '../../lib/squib'
|
||||
|
||||
# This is a more advanced example of Sprues
|
||||
# (mostly so we can have a torturous regression test)
|
||||
# - Uses a custom sprue
|
||||
# - Weird rotations
|
||||
# - Center-positioned
|
||||
# - Uses per-card trim and trim_radius
|
||||
# - Multiple pages
|
||||
Squib::Deck.new(cards: 6, width: '2.2in', height: '2.1in') do
|
||||
background color: :blue #blue never shows up! Yay clipping...
|
||||
|
|
@ -18,16 +17,8 @@ Squib::Deck.new(cards: 6, width: '2.2in', height: '2.1in') do
|
|||
text str: (0..9).map{ |i| "Card #{i}\n\n" },
|
||||
font: 'Sans 32', align: :center, valign: :middle,
|
||||
height: :deck, width: :deck
|
||||
|
||||
# Per-card trims just for funsies
|
||||
trims = ['0.2in'] * 9
|
||||
trims[0] = '0.3in'
|
||||
trims[3] = '0.4in'
|
||||
trim_radii = ['10pt'] * 9
|
||||
trim_radii[1] = '0.2in'
|
||||
trim_radii[3] = '0.75in'
|
||||
|
||||
save_sheet sprue: 'my_sprues/weird_sprue.yml',
|
||||
trim: trims, trim_radius: trim_radii,
|
||||
trim: '0.2in', trim_radius: '10pt',
|
||||
prefix: "advanced_sprues_"
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue