Browse Source

docs: documenting and sampling sprues

dev
Andy Meneely 8 years ago
parent
commit
17ecf87385
  1. 5
      docs/dsl/save_pdf.rst
  2. 5
      docs/dsl/save_sheet.rst
  3. 16
      docs/help.rst
  4. 1
      docs/index.rst
  5. 195
      docs/sprues.rst
  6. 2
      lib/squib/sprues/sprue_schema.rb
  7. 18
      samples/sprues/_builtin_sprues.rb
  8. 42
      samples/sprues/sprue.yml

5
docs/dsl/save_pdf.rst

@ -16,6 +16,11 @@ dir
the directory to save to. Created if it doesn't exist.
sprue
default: ``nil``
the sprue file to use. If ``nil``, then no sprue is used and the cards are laid out automatically using the parameters below. If non-nil, Squib checks for a built-in sprue file of that name. Otherwise, it attempts to open a file relative to the current directory. For more information on Squib Sprues, see :doc:`/sprues`.
width
default: ``3300``

5
docs/dsl/save_sheet.rst

@ -11,6 +11,11 @@ range
the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
sprue
default: ``nil``
the sprue file to use. If ``nil``, then no sprue is used and the cards are laid out automatically using the parameters below. If non-nil, Squib checks for a built-in sprue file of that name. Otherwise, it attempts to open a file relative to the current directory. For more information on Squib Sprues, see :doc:`/sprues`.
columns
default: ``5``

16
docs/help.rst

@ -139,7 +139,23 @@ But, as a tester, you'll want to have Bundler install Squib from my repository.
After changing your Gemfile, you'll need to run ``bundle install``. That will generate a ``Gemfile.lock`` file - that's Bundler's way of saying exactly what it's planning on using. You don't modify the Gemfile.lock, but you can look at it to see what version of Squib it's locked onto.
Make a Sprue!
-------------
Do you have a sprue file that lays out cards in sheets in a way others might use? Perhaps for a specific type of sticker sheet, die cutter, duplex, or other situation. If you think there is *one* other person in the world who would appreciate it, we would love to have it in Squib!
The easiest way to do this to create a new `GitHub Issue <https://github.com/andymeneely/squib/issues/new>`_ and just copy the Sprue file in.
Or, better yet, you can do a pull request! Add the sprue file to the ``/lib/squib/builtin/sprues`` folder.
Make a Layout!
--------------
Do you have any layouts that others might use? Maybe based on print-on-demand templates. Or take a game that you think has a great card layout and reverse-engineer it for others. Don't be shy!
The easiest way to do this to create a new `GitHub Issue <https://github.com/andymeneely/squib/issues/new>`_ and just copy the layout yaml file in.
Or, better yet, you can do a pull request! Add the file to the ``/lib/squib/layouts`` folder.
Help by Fixing Bugs
-------------------

1
docs/index.rst

@ -21,6 +21,7 @@ Contents:
config
backends
build_groups
sprues
help
dsl/index.rst

195
docs/sprues.rst

@ -0,0 +1,195 @@
Sprue Thy Sheets
================
A `sprue <https://en.wikipedia.org/wiki/Sprue_(manufacturing)>`_ is a Squib feature that customizes how cards get arranged on a sheet as part of :doc:`/dsl/save_pdf` or :doc:`/dsl/save_sheet` (PNG). This is particularly useful for:
* Working with specific dies
* Cutting out hex chits with fewer cuts
* Working with quirky duplex printing
* Printing front-to-back and having a fold in the middle
* Printing to specific sticker sheets
* Making an A4 version and a US Letter version for i18n
Without using a sprue, the :doc:`/dsl/save_sheet` and :doc:`/dsl/save_sheet` will simply lay out your cards one after another with the gap and margins you specify.
Like Layouts, Squib comes with a library of built-in sprues that you can use. You can make a sprue yourself, or you can generate one from the command line.
.. note::
Would someone else find your sprue useful? Contribute one!! This is an easy way to help out the Squib community.
Make Your Own Sprue on Command Line
-----------------------------------
Squib comes with a handy little command-line interface that will generate a sprue file based on your own parameters. Of course, you can edit the sprue file once you're done to fix any quirks you like.
Here's an example run::
$ squib make_sprue
1. in
2. cm
3. mm
What measure unit should we use? 1
1. A4, portrait
2. A4, landscape
3. US letter, portrait
4. US letter, landscape
5. Custom size
What paper size you are using? 3
Sheet margins? (in) 0.125
1. left
2. right
3. center
How to align cards on sheet? [left] 3
Card width? (in) 2.5
Card height? (in) 3.5
Gap between cards? (in) 0
1. rows
2. columns
How to layout your cards? [rows]
1
1. true
2. false
Generate crop lines? [true]
1
Output to? |sprue.yml| my_sprue.yml
Of course, a Squib sprue is just a YAML file with a specific structure. Here's an example (generated from the run above)::
---
sheet_width: 8.5in
sheet_height: 11in
card_width: 2.5in
card_height: 3.5in
cards:
- x: 0.5in
y: 0.125in
- x: 3.0in
y: 0.125in
- x: 5.5in
y: 0.125in
- x: 0.5in
y: 3.625in
- x: 3.0in
y: 3.625in
- x: 5.5in
y: 3.625in
- x: 0.5in
y: 7.125in
- x: 3.0in
y: 7.125in
- x: 5.5in
y: 7.125in
crop_line:
lines:
- type: :vertical
position: 0.5in
- type: :vertical
position: 3.0in
- type: :vertical
position: 5.5in
- type: :vertical
position: 8.0in
- type: :horizontal
position: 0.125in
- type: :horizontal
position: 3.625in
- type: :horizontal
position: 7.125in
- type: :horizontal
position: 10.625in
Sprue Format
------------
Here are the options for the sprue file. The entire structure of the Yaml file is a Hash
Top-Level parameters
^^^^^^^^^^^^^^^^^^^^
sheet_width
Width of the sheet, supports :doc:`/units`.
sheet_height
Width of the sheet, supports :doc:`/units`.
card_width
Intended width of the card. Sprues will allow any size of card, but if the size of the incoming card does not match this size then a warning will be printed to stdout. Supports :doc:`/units`.
card_height
Intended height of the card. Sprues will allow any size of card, but if the size of the incoming card does not match this size then a warning will be printed to stdout. Supports :doc:`/units`.
position_reference
Default: ``topleft``
Can be ``topleft`` or ``center``. Are the ``card`` coordinates refer to the top-left of the card, or the middle of the card?
cards
^^^^^
At the top-level should be a ``cards`` key. Within that is an array of hashes that contain the x-y coordinates to indicate the locations of the cards. The order of the coordinates indicates the order of the cards that will be laid out. When there are more cards in the deck than the number of x-y coordinates in the list, a new "page" will be made (i.e. a new page in the PDF or a new sheet for PNG sheets).
x
Horizontal distance card from the left side of the page. Supports :doc:`/units`.
y
Vertical distance card from the top side of the page. Supports :doc:`/units`.
rotate
Default: ``0`` (none)
Rotate the card around its position_reference. Allows ``clockwise``, ``counterclockwise``, or ``turnaround``, or numerical angle.
crop_line
^^^^^^^^^
Optionally, at the top-level you can specify lines to be drawn.
style
Values: ``solid``,``dotted``,``dashed``
width
The stroke width of the crop line. Supports :doc:`/units`.
color
The stroke color of the crop line, using :doc:`/colors`
overlay
Values: ``on_margin``, ``overlay_on_cards``, ``beneath_cards``.
Specifies how the crop line is drawn: before drawing cards, after drawing cards, or only in the margins.
lines
A hash that has the following options below
type
Values: ``horizontal`` or ``vertical``
position
The x-position or y-position of the crop line (depending on ``type``)
Front-to-Back Printing
----------------------
While Squib does not natively support card "fronts" and "backs" (`yet <https://github.com/andymeneely/squib/issues/93>`_), you can use sprues and the ``range`` option (see :doc:`/ranges`).
Consider this sample:
.. warning::
To be written
Built-in Sprues
---------------
Here's a list of built-in sprues that come with Squib. You can get the original YAML files `on GitHub here <https://github.com/andymeneely/squib/tree/master/lib/squib/builtin/sprues>`_.
a4_euro_card.yml
^^^^^^^^^^^^^^^^
.. raw:: html
<img src="sprues/sprue_a4_euro_card.yml_01.png"
class="figure" width=550>

2
lib/squib/sprues/sprue_schema.rb

@ -37,8 +37,6 @@ module Squib
'cards' => [[{
'x' => UNIT_REGEX,
'y' => UNIT_REGEX,
# NOTE: Don't think that we should specify rotation on a per card
# basis, but just included here for now
'rotate' => [
:optional, Numeric,
ClassyHash::G.enum(:clockwise, :counterclockwise, :turnaround),

18
samples/sprues/_builtin_sprues.rb

@ -0,0 +1,18 @@
require 'squib'
Squib::Deck.new(cards: 8) do
background color: :white
rect stroke_width: 5, stroke_dash: '7 7'
text str: %w(First Second Third Fourth Fifth Sixth Seventh Eighth),
font: 'Sans 96', align: :center, valign: :middle,
height: :deck, width: :deck
%w(
a4_euro_card.yml
a4_poker_card_8up.yml
a4_poker_card_9up.yml
a4_usa_card.yml
).each do |builtin|
save_sheet sprue: builtin, prefix: "sprue_#{builtin}_", dir: '.'
end
end

42
samples/sprues/sprue.yml

@ -0,0 +1,42 @@
---
sheet_width: 8.5in
sheet_height: 11in
card_width: 2.5in
card_height: 3.5in
cards:
- x: 0.5in
y: 0.125in
- x: 3.0in
y: 0.125in
- x: 5.5in
y: 0.125in
- x: 0.5in
y: 3.625in
- x: 3.0in
y: 3.625in
- x: 5.5in
y: 3.625in
- x: 0.5in
y: 7.125in
- x: 3.0in
y: 7.125in
- x: 5.5in
y: 7.125in
crop_line:
lines:
- type: :vertical
position: 0.5in
- type: :vertical
position: 3.0in
- type: :vertical
position: 5.5in
- type: :vertical
position: 8.0in
- type: :horizontal
position: 0.125in
- type: :horizontal
position: 3.625in
- type: :horizontal
position: 7.125in
- type: :horizontal
position: 10.625in
Loading…
Cancel
Save