Last active
October 28, 2016 09:20
-
-
Save andymeneely/3c60c13b25f525abd037db4055abf35c to your computer and use it in GitHub Desktop.
Squib: save stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_output/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment