diff --git a/.gitmodules b/.gitmodules index 5af3b9b..25a213d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,11 +1,9 @@ [submodule "samples/intro"] - path = samples/intro - url = https://gist.github.com/5026392a419124312cb7.git - + path = samples/intro + url = https://gist.github.com/5026392a419124312cb7.git [submodule "samples/images"] path = samples/images url = https://gist.github.com/00ba7eb0aa1d82140503.git - [submodule "samples/text"] path = samples/text url = https://gist.github.com/52d7b8e332194946bc69.git @@ -15,22 +13,15 @@ [submodule "samples/build_groups"] path = samples/build_groups url = https://gist.github.com/andymeneely/bda48487e3b8c9d15edb - [submodule "samples/backend"] - path = samples/backend - url = https://gist.github.com/7b4a3acd0e758aedf87ba549e2025a11.git - + path = samples/backend + url = https://gist.github.com/7b4a3acd0e758aedf87ba549e2025a11.git [submodule "samples/shapes"] - path = samples/shapes - url = https://gist.github.com/59089c972b8b0e5d7e76598010e69291.git - -[submodule "samples/saves"] - path = samples/saves - url = https://gist.github.com/3c60c13b25f525abd037db4055abf35c.git - + path = samples/shapes + url = https://gist.github.com/59089c972b8b0e5d7e76598010e69291.git [submodule "samples/data"] - path = samples/data - url = https://gist.github.com/6f89115805e205c647a779b7b4866151.git + path = samples/data + url = https://gist.github.com/6f89115805e205c647a779b7b4866151.git [submodule "samples/colors"] - path = samples/colors - url = https://gist.github.com/fac2f4a16a23c2bada126e93d6523971.git + path = samples/colors + url = https://gist.github.com/fac2f4a16a23c2bada126e93d6523971.git diff --git a/samples/saves b/samples/saves deleted file mode 160000 index 711ec5a..0000000 --- a/samples/saves +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 711ec5a0596a62f6b699a202b7f557d9cd5d20fe diff --git a/samples/saves/.gitignore b/samples/saves/.gitignore new file mode 100644 index 0000000..eaaf8de --- /dev/null +++ b/samples/saves/.gitignore @@ -0,0 +1 @@ +_output/* diff --git a/samples/saves/_hand.rb b/samples/saves/_hand.rb new file mode 100644 index 0000000..95d830b --- /dev/null +++ b/samples/saves/_hand.rb @@ -0,0 +1,23 @@ +require 'squib' + +Squib::Deck.new(cards: 8, layout: 'playing-card.yml') do + background color: :cyan + rect x: 37, y: 37, width: 750, height: 1050, fill_color: :black, radius: 25 + rect x: 75, y: 75, width: 675, height: 975, fill_color: :white, radius: 20 + text str: ('A'..'Z').to_a, layout: :bonus_ul, font: 'Sans bold 100' + + # Defaults are sensible + hand # saves to _output/hand.png + + # Here's a prettier version: + # - Each card is trimmed with rounded corners + # - Zero radius means cards rotate about the bottom of the card + # - Cards are shown in reverse order + hand trim: 37.5, trim_radius: 25, + radius: 0, + range: 7.downto(0), + file: 'hand_pretty.png' + + # Tip: you can have the top card be on the left by reversing the range + # angle_range: (Math::PI / 4)..(Math::PI / -4) +end diff --git a/samples/saves/_portrait_landscape.rb b/samples/saves/_portrait_landscape.rb new file mode 100644 index 0000000..18ba1c4 --- /dev/null +++ b/samples/saves/_portrait_landscape.rb @@ -0,0 +1,23 @@ +require 'squib' + +# For decks with both landscape and portrait orientations, +# we recommend using two separate decks. +# For print-on-demand, we can rotate all of the images in the final step. + +# Normal cards +Squib::Deck.new(width: 825, height: 1125) do + background color: '#aaa' + + text str: 'This is portrait and trimmed' + + save_png prefix: 'portrait_', trim: 10, trim_radius: 15 +end + +# Money cards are landscape +Squib::Deck.new(width: 1125, height: 825) do + background color: '#aaa' + + text str: 'This is landscape and trimmed', x: 15, y: 10 + + save_png prefix: 'landscape_', rotate: :clockwise, trim: 25, trim_radius: 15 +end diff --git a/samples/saves/_save_pdf.rb b/samples/saves/_save_pdf.rb new file mode 100644 index 0000000..c9fc60e --- /dev/null +++ b/samples/saves/_save_pdf.rb @@ -0,0 +1,18 @@ +require 'squib' + +Squib::Deck.new(cards: 8) do + background color: :gray + rect x: 37.5, y: 37.5, width: 750, height: 1050, + x_radius: 37.5, y_radius: 37.5, stroke: 3.0, dash: '4 4' + + # Tests for crop marks + save_pdf file: 'crops-default.pdf', crop_marks: true + save_pdf file: 'crops-gapped.pdf', crop_marks: true, trim: 37.5, gap: 20 + + # Test crop marks with all the bells and whistles + rect x: '0.3in', y: '0.4in', width: '2in', height: '2.5in' + save_pdf file: 'crops-custom.pdf', crop_marks: true, 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 diff --git a/samples/saves/_saves.rb b/samples/saves/_saves.rb new file mode 100644 index 0000000..ac98a86 --- /dev/null +++ b/samples/saves/_saves.rb @@ -0,0 +1,45 @@ +require 'squib' + +# This sample demonstrates how to use the various save methods + +Squib::Deck.new(width: 825, height: 1125, cards: 16) do + background color: :gray + rect x: 38, y: 38, width: 750, height: 1050, + x_radius: 38, y_radius: 38, stroke: 3.0, dash: '4 4' + + text str: (1..16).to_a, x: 220, y: 78, font: 'Arial 54' + + # Here's what a regular save_png looks like for just the first card + save_png range: 0, prefix: 'save_png_' + + # save_png supports trim and trim_radius + save_png trim: 30, trim_radius: 38, + range: 0, prefix: 'save_png_trimmed_' + + # Place on multiple pages over the PDF, with bleed beeing trimmed off + save_pdf file: 'save-pdf.pdf', margin: 75, gap: 5, trim: 37 + + # PDFs also support arbitrary paper sizes, in pixels or any other supported units + save_pdf file: 'save-pdf-small.pdf', + width: '7in', height: '5in', + range: 0..1 + + # Note that our PNGs still are not trimmed even though the pdf ones were + save_png range: 1, prefix: 'saves_notrim_' + + # We can also save our PNGs into a single sheet, + # rows are calculated based on cols and number of cards + save_sheet prefix: 'save_single_sheet_', + columns: 2, margin: 75, gap: 5, trim: 37 + + # Or multiple sheets if rows are also specified + save_sheet prefix: 'save_sheet_', + columns: 4, rows: 2, + margin: 75, gap: 5, trim: 37 + + # Sheets support ranges too + save_sheet prefix: 'save_sheet_range_', + range: 0..5, + columns: 2, rows: 2, + margin: 75, gap: 5, trim: 37 +end diff --git a/samples/saves/_showcase.rb b/samples/saves/_showcase.rb new file mode 100644 index 0000000..0f4cfcf --- /dev/null +++ b/samples/saves/_showcase.rb @@ -0,0 +1,25 @@ +require 'squib' + +# Showcases are a neat way to show off your cards in a modern way, using a +# reflection and a persepctive effect to make them look 3D +Squib::Deck.new(cards: 4) do + background color: '#CE534D' + rect fill_color: '#DED4B9', x: 78, y: 78, + width: '2.25in', height: '3.25in', radius: 32 + text str: %w(Grifter Thief Thug Kingpin), + font: 'Helvetica,Sans weight=800 120', + x: 78, y: 78, width: '2.25in', align: :center + svg file: 'spanner.svg', x: (825 - 500) / 2, y: 500, width: 500, height: 500 + + # Defaults are pretty sensible. + showcase file: 'showcase.png' + + # Here's a more complete example. + # Tons of ways to tweak it if you like - check the docs. + showcase trim: 32, trim_radius: 32, margin: 100, face: :right, + scale: 0.85, offset: 0.95, fill_color: :black, + reflect_offset: 25, reflect_strength: 0.1, reflect_percent: 0.4, + file: 'showcase2.png' + + save_png prefix: 'showcase_individual_' # to show that they're not trimmed +end diff --git a/samples/saves/hand_expected.png b/samples/saves/hand_expected.png new file mode 100644 index 0000000..20cdb65 Binary files /dev/null and b/samples/saves/hand_expected.png differ diff --git a/samples/saves/hand_pretty_expected.png b/samples/saves/hand_pretty_expected.png new file mode 100644 index 0000000..5100248 Binary files /dev/null and b/samples/saves/hand_pretty_expected.png differ diff --git a/samples/saves/save-pdf-small_expected.pdf b/samples/saves/save-pdf-small_expected.pdf new file mode 100644 index 0000000..f41262f Binary files /dev/null and b/samples/saves/save-pdf-small_expected.pdf differ diff --git a/samples/saves/save-pdf_expected.pdf b/samples/saves/save-pdf_expected.pdf new file mode 100644 index 0000000..398b628 Binary files /dev/null and b/samples/saves/save-pdf_expected.pdf differ diff --git a/samples/saves/save_png_00_expected.png b/samples/saves/save_png_00_expected.png new file mode 100644 index 0000000..7e9cb05 Binary files /dev/null and b/samples/saves/save_png_00_expected.png differ diff --git a/samples/saves/save_png_trimmed_00_expected.png b/samples/saves/save_png_trimmed_00_expected.png new file mode 100644 index 0000000..3972555 Binary files /dev/null and b/samples/saves/save_png_trimmed_00_expected.png differ diff --git a/samples/saves/save_sheet_00_expected.png b/samples/saves/save_sheet_00_expected.png new file mode 100644 index 0000000..a5e5b57 Binary files /dev/null and b/samples/saves/save_sheet_00_expected.png differ diff --git a/samples/saves/save_sheet_01_expected.png b/samples/saves/save_sheet_01_expected.png new file mode 100644 index 0000000..68e3a8f Binary files /dev/null and b/samples/saves/save_sheet_01_expected.png differ diff --git a/samples/saves/save_sheet_range_00_expected.png b/samples/saves/save_sheet_range_00_expected.png new file mode 100644 index 0000000..aa36e94 Binary files /dev/null and b/samples/saves/save_sheet_range_00_expected.png differ diff --git a/samples/saves/save_sheet_range_01_expected.png b/samples/saves/save_sheet_range_01_expected.png new file mode 100644 index 0000000..c507f01 Binary files /dev/null and b/samples/saves/save_sheet_range_01_expected.png differ diff --git a/samples/saves/save_single_sheet_00_expected.png b/samples/saves/save_single_sheet_00_expected.png new file mode 100644 index 0000000..4cf7e68 Binary files /dev/null and b/samples/saves/save_single_sheet_00_expected.png differ diff --git a/samples/saves/saves_notrim_01_expected.png b/samples/saves/saves_notrim_01_expected.png new file mode 100644 index 0000000..9bf36d2 Binary files /dev/null and b/samples/saves/saves_notrim_01_expected.png differ diff --git a/samples/saves/showcase2_expected.png b/samples/saves/showcase2_expected.png new file mode 100644 index 0000000..a99d83c Binary files /dev/null and b/samples/saves/showcase2_expected.png differ diff --git a/samples/saves/showcase_expected.png b/samples/saves/showcase_expected.png new file mode 100644 index 0000000..7fa01cd Binary files /dev/null and b/samples/saves/showcase_expected.png differ diff --git a/samples/saves/showcase_individual_00_expected.png b/samples/saves/showcase_individual_00_expected.png new file mode 100644 index 0000000..2ca9c33 Binary files /dev/null and b/samples/saves/showcase_individual_00_expected.png differ diff --git a/samples/saves/showcase_individual_01_expected.png b/samples/saves/showcase_individual_01_expected.png new file mode 100644 index 0000000..12d4b68 Binary files /dev/null and b/samples/saves/showcase_individual_01_expected.png differ diff --git a/samples/saves/showcase_individual_02_expected.png b/samples/saves/showcase_individual_02_expected.png new file mode 100644 index 0000000..25c6be9 Binary files /dev/null and b/samples/saves/showcase_individual_02_expected.png differ diff --git a/samples/saves/showcase_individual_03_expected.png b/samples/saves/showcase_individual_03_expected.png new file mode 100644 index 0000000..96daac6 Binary files /dev/null and b/samples/saves/showcase_individual_03_expected.png differ diff --git a/samples/saves/spanner.svg b/samples/saves/spanner.svg new file mode 100644 index 0000000..1f3a747 --- /dev/null +++ b/samples/saves/spanner.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + +