Add landscape card support.

Setting c.orientation to :landscape will rotate your exported Inkscape
output images 270 degrees, so that you can upload them to The Game
Crafter and create PnP PDFs and they're oriented correctly.
This commit is contained in:
John Bintz 2014-06-23 21:45:57 -04:00
parent 4a9879074a
commit 901b3b2d60
4 changed files with 30 additions and 3 deletions

View File

@ -92,6 +92,10 @@ Create a `Cardfile` in your working directory. It should look something like thi
# prepend this PDF to the outputted PDF (useful for game rules)
# c.prepend_pdf = "rules.pdf"
# the cards are landscape, so rotate them counterclockwise
# after rendering in Inkscape
# c.orientation = :landscape
c.data_source = "data.ods"
end
```

View File

@ -74,10 +74,24 @@ MSG
ensure_tmp
@exported_pngs = Parallel.map(context.individual_files.each_with_index) do |svg_file, index|
target = Pathname(context.session.png_files_path % index)
target = Pathname(session.png_files_path % index)
target.parent.mkpath
system %{inkscape --export-area-page --export-png "#{target.expand_path}" --export-width #{context.session.png_export_width} --export-background="#ffffffff" "#{svg_file.expand_path}"}
command = %{inkscape --export-area-page --export-png "#{target.expand_path}" --export-background="#ffffffff" }
case session.orientation
when :portrait
command += %{--export-width #{session.png_export_width}}
when :landscape
command += %{--export-height #{session.png_export_width}}
end
command += %{ "#{svg_file.expand_path}"}
system command
if session.orientation == :landscape
system %{convert -verbose "#{target.expand_path}" -rotate 270 "#{target.expand_path}"}
end
target
end
@ -156,6 +170,10 @@ MSG
def write_svgs
context.write_individual_files
end
def session
context.session
end
end
end
end

View File

@ -3,11 +3,12 @@ module SVGGVS
attr_accessor :svg_source, :svg_merged_target, :individual_files_path, :on_card_finished
attr_accessor :png_files_path, :png_export_width, :pdf_card_size, :pdf_dpi
attr_accessor :pdf_target, :card_back, :card_size, :target, :post_read_data
attr_accessor :card_sheet_identifier, :prepend_pdf
attr_accessor :card_sheet_identifier, :prepend_pdf, :orientation
def initialize
@index = 0
@card_sheet_identifier = "Card Data"
@orientation = :portrait
end
def configure

View File

@ -10,6 +10,10 @@
# prepend this PDF to the outputted PDF (useful for game rules)
# c.prepend_pdf = "rules.pdf"
# the cards are landscape, so rotate them counterclockwise
# after rendering in Inkscape
# c.orientation = :landscape
c.data_source = "data.ods"
end