squib 0.16.0.pre.preview1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +2 -2
- data/CHANGELOG.md +19 -1
- data/RELEASE TODO.md +4 -3
- data/lib/squib.rb +2 -0
- data/lib/squib/args/drop_shadow.rb +39 -0
- data/lib/squib/args/sheet.rb +3 -8
- data/lib/squib/args/xywh_shorthands.rb +25 -30
- data/lib/squib/dsl/save_png.rb +12 -11
- data/lib/squib/graphics/cairo_context_wrapper.rb +8 -6
- data/lib/squib/graphics/save_images.rb +52 -13
- data/lib/squib/sprues/sprue_schema.rb +4 -3
- data/lib/squib/system_fonts.rb +17 -0
- data/lib/squib/version.rb +2 -1
- data/samples/saves/_saves.rb +10 -0
- data/samples/shadows/_shadow.rb +72 -0
- data/samples/sprues/_negative_coords.rb +7 -0
- data/samples/system_font_debug/_list_fonts.rb +14 -0
- data/samples/units/_cells.rb +1 -1
- data/samples/units/_shorthands.rb +3 -4
- data/squib.gemspec +4 -4
- metadata +26 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ce274e1ac305556f491ca0ec5fe50ce3423aadd4eee2bbda2d143bded8590a7
|
4
|
+
data.tar.gz: 2c98fe372b7eeb24eceafe9e416c582a3e51662300d2c83dabcb3a43f99210c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fe46e736b5a0acd2af24851041de586cd7fe0ab2208a6559b4cba676904ff07fadcdb2fe1d25084838634e1780b43dec32b7a3a7b4926fd173eeb6ccbdf2342
|
7
|
+
data.tar.gz: aecd5504f8dfd17518d9d675c58be8c1dfcbf5d5cff29aa9091308adbf4020e2fcadc91e4da155c69a20e397a5600c92269b8dfec306fcb87271c7342c68c04a
|
data/.github/workflows/tests.yml
CHANGED
@@ -8,9 +8,9 @@ jobs:
|
|
8
8
|
fail-fast: false
|
9
9
|
matrix:
|
10
10
|
os: [ubuntu, macos]
|
11
|
-
ruby: [2.5, 2.6, 2.7, head]
|
11
|
+
ruby: [2.5, 2.6, 2.7, 3.0, head]
|
12
12
|
runs-on: ${{ matrix.os }}-latest
|
13
|
-
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
13
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' || (matrix.ruby == '3.0' && matrix.os == 'macos')}}
|
14
14
|
steps:
|
15
15
|
- uses: actions/checkout@v2
|
16
16
|
- uses: ruby/setup-ruby@v1
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,25 @@
|
|
1
1
|
# Squib CHANGELOG
|
2
2
|
Squib follows [semantic versioning](http://semver.org).
|
3
3
|
|
4
|
-
## v0.
|
4
|
+
## v0.17.1 / 2021-08-11
|
5
|
+
|
6
|
+
Bugs:
|
7
|
+
* Sprues now allow negative coordinates (#336)
|
8
|
+
* Documentation typos (#337)
|
9
|
+
|
10
|
+
## v0.17.0 / 2021-07-23
|
11
|
+
Features:
|
12
|
+
* Drop shadows! The `save_png` method now supports a bunch of `shadow_` arguments that will add a drop shadow just before rendering. This is intended for using in rulebooks or marketing. Try it out by adding `shadow_radius: 8` to your save_png (#306, #264)
|
13
|
+
* Added debug methods for checking font access. `Squib.system_fonts` and `Squib.print_system_fonts` (#334)
|
14
|
+
|
15
|
+
Bugs:
|
16
|
+
* The `rows` argument is always respected in `save_sheet` (#332).
|
17
|
+
|
18
|
+
Chores:
|
19
|
+
* Bump cairo to ~1.17
|
20
|
+
* Bump classy_hash to 1.0
|
21
|
+
|
22
|
+
## v0.16.0 / 2020-11-24
|
5
23
|
|
6
24
|
Features:
|
7
25
|
* Special custom unit: cells. A "cell" defaults to 37.5px, or 1/8in, e.g. `x: '1 cell'` means `x: 37.5`. See the docs for details.
|
data/RELEASE TODO.md
CHANGED
@@ -9,14 +9,15 @@ Be sure to remember to do the following for releases. (Copy into a GitHub issue)
|
|
9
9
|
- [ ] Bump docs/conf.py versions
|
10
10
|
- [ ] Do a full rake locally
|
11
11
|
- [ ] `rake sanity`, and check visually
|
12
|
-
- [ ]
|
12
|
+
- [ ] GitHub Actions is passing on dev branch
|
13
13
|
- [ ] Merge master branch
|
14
14
|
- [ ] Merge release branch
|
15
15
|
- [ ] Push master and release branches
|
16
16
|
- [ ] Create GitHub release tag
|
17
17
|
- [ ] `gem push pkg/squib-x.y.z.gem`
|
18
|
-
- [ ] `gem push --key github --host https://rubygems.pkg.github.com/andymeneely pkg/squib-x.y.z.gem`
|
19
18
|
- [ ] Github milestone closed
|
20
|
-
- [ ] Activate version on squib.readthedocs.org
|
19
|
+
- [ ] Activate version on squib.readthedocs.org (Versions)
|
20
|
+
- [ ] Set default version on squib.readthedocs.org (Advanced Settings)
|
21
21
|
- [ ] Bump version.rb to the next alpha
|
22
|
+
- [ ] Check Docker build
|
22
23
|
- [ ] Publish on BoardGameGeek thread
|
data/lib/squib.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'color_validator'
|
2
|
+
|
3
|
+
module Squib::Args
|
4
|
+
module_function def extract_drop_shadow(opts, deck)
|
5
|
+
DropShadow.new(deck.custom_colors).extract! opts, deck
|
6
|
+
end
|
7
|
+
|
8
|
+
class DropShadow
|
9
|
+
include ArgLoader
|
10
|
+
include ColorValidator
|
11
|
+
|
12
|
+
def initialize(custom_colors)
|
13
|
+
@custom_colors = custom_colors
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.parameters
|
17
|
+
{
|
18
|
+
shadow_color: :black,
|
19
|
+
shadow_offset_x: 3,
|
20
|
+
shadow_offset_y: 3,
|
21
|
+
shadow_radius: nil,
|
22
|
+
shadow_trim: 0,
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.expanding_parameters
|
27
|
+
self.parameters.keys # all of them
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.params_with_units
|
31
|
+
[:shadow_offset_x, :shadow_offset_y, :shadow_radius, :shadow_trim]
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate_shadow_color(arg, _i)
|
35
|
+
colorify(arg, @custom_colors)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/squib/args/sheet.rb
CHANGED
@@ -82,14 +82,9 @@ module Squib::Args
|
|
82
82
|
|
83
83
|
def validate_rows(arg)
|
84
84
|
raise 'columns must be an integer' unless columns.respond_to? :to_i
|
85
|
-
count =
|
86
|
-
|
87
|
-
|
88
|
-
count = range.to_a.length
|
89
|
-
end
|
90
|
-
return 1 if count <= columns
|
91
|
-
return arg if arg.respond_to? :to_i
|
92
|
-
(count.to_f / columns.to_f).ceil
|
85
|
+
count = (range == :all) ? @deck.size : count = range.to_a.length
|
86
|
+
return arg.to_i if arg.respond_to? :to_i
|
87
|
+
(count.to_f / columns.to_f).ceil # e.g. :infinite
|
93
88
|
end
|
94
89
|
|
95
90
|
def full_filename(i=nil)
|
@@ -3,49 +3,44 @@ require_relative 'unit_conversion'
|
|
3
3
|
module Squib
|
4
4
|
module Args
|
5
5
|
module XYWHShorthands
|
6
|
-
WIDTH_MINUS_REGEX = /^width\s*\-\s*/
|
7
|
-
HEIGHT_MINUS_REGEX = /^height\s*\-\s*/
|
8
|
-
WIDTH_DIV_REGEX = /^width\s*\/\s*/
|
9
|
-
HEIGHT_DIV_REGEX = /^height\s*\/\s*/
|
10
|
-
MIDDLE_PLUS_REGEX = /^middle\s*\+\s*/
|
11
|
-
MIDDLE_MINUS_REGEX = /^middle\s*\-\s*/
|
12
6
|
|
7
|
+
MIDDLE_ONLY = /^(middle|center)\s*$/
|
8
|
+
DECK_ONLY = /^deck\s*$/
|
9
|
+
MIDDLE_MINUS_REGEX = /^(middle|center)\s*\-\s*/
|
10
|
+
MIDDLE_PLUS_REGEX = /^(middle|center)\s*\+\s*/
|
11
|
+
DECK_MINUS_REGEX = /^deck\s*\-\s*/
|
12
|
+
DECK_PLUS_REGEX = /^deck\s*\+\s*/
|
13
|
+
DECK_DIV_REGEX = /^deck\s*\/\s*/
|
13
14
|
|
14
15
|
# dimension is usually either deck_width or deck_height
|
15
16
|
def apply_shorthands(arg, deck, axis: :x)
|
16
17
|
dimension = (axis == :x) ? deck.width : deck.height
|
17
18
|
arg_s = arg.to_s
|
18
19
|
case arg_s
|
19
|
-
when
|
20
|
+
when MIDDLE_ONLY
|
20
21
|
dimension / 2.0
|
21
|
-
when
|
22
|
-
dimension / 2.0
|
23
|
-
when 'deck'
|
22
|
+
when DECK_ONLY
|
24
23
|
dimension
|
25
|
-
when
|
26
|
-
n = arg_s.sub
|
27
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
|
28
|
-
deck.width - n
|
29
|
-
when HEIGHT_MINUS_REGEX # e.g. height - 1.5in
|
30
|
-
n = arg_s.sub HEIGHT_MINUS_REGEX, ''
|
31
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
|
32
|
-
deck.height - n
|
33
|
-
when WIDTH_DIV_REGEX # e.g. width / 3
|
34
|
-
n = arg_s.sub WIDTH_DIV_REGEX, ''
|
35
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
36
|
-
deck.width / n
|
37
|
-
when HEIGHT_DIV_REGEX # e.g. height / 3
|
38
|
-
n = arg_s.sub HEIGHT_DIV_REGEX, ''
|
24
|
+
when MIDDLE_MINUS_REGEX # e.g. width: middle - 3
|
25
|
+
n = arg_s.sub MIDDLE_MINUS_REGEX, ''
|
39
26
|
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
40
|
-
|
27
|
+
dimension / 2.0 - n
|
41
28
|
when MIDDLE_PLUS_REGEX # e.g. middle + 1.5in
|
42
29
|
n = arg_s.sub MIDDLE_PLUS_REGEX, ''
|
43
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
|
30
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
44
31
|
dimension / 2.0 + n
|
45
|
-
when
|
46
|
-
n = arg_s.sub
|
47
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
|
48
|
-
dimension
|
32
|
+
when DECK_MINUS_REGEX # e.g. width: deck - 1.5in
|
33
|
+
n = arg_s.sub DECK_MINUS_REGEX, ''
|
34
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
35
|
+
dimension - n
|
36
|
+
when DECK_PLUS_REGEX # e.g. deck + 1.5in (which is weird but ok)
|
37
|
+
n = arg_s.sub DECK_PLUS_REGEX, ''
|
38
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
39
|
+
dimension + n
|
40
|
+
when DECK_DIV_REGEX # e.g. width: deck/3
|
41
|
+
n = arg_s.sub DECK_DIV_REGEX, ''
|
42
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
43
|
+
dimension / n
|
49
44
|
else
|
50
45
|
arg
|
51
46
|
end
|
data/lib/squib/dsl/save_png.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require_relative '../errors_warnings/warn_unexpected_params'
|
2
|
-
|
2
|
+
require_relative '../args/card_range'
|
3
|
+
require_relative '../args/save_batch'
|
4
|
+
require_relative '../args/drop_shadow'
|
3
5
|
|
4
6
|
module Squib
|
5
7
|
class Deck
|
@@ -24,24 +26,23 @@ module Squib
|
|
24
26
|
range
|
25
27
|
dir prefix suffix count_format
|
26
28
|
rotate trim trim_radius
|
29
|
+
shadow_offset_x shadow_offset_y shadow_radius shadow_color shadow_trim
|
27
30
|
)
|
28
31
|
end
|
29
32
|
|
30
33
|
def run(opts)
|
31
34
|
warn_if_unexpected opts
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
35
|
+
range = Args.extract_range opts, deck
|
36
|
+
batch = Args.extract_save_batch opts, deck
|
37
|
+
shadow = Args.extract_drop_shadow opts, deck
|
38
|
+
@bar.start("Saving PNGs to #{batch.summary}", deck.size) do |bar|
|
39
|
+
range.map do |i|
|
40
|
+
deck.cards[i].save_png(batch[i], shadow[i])
|
41
|
+
bar.increment
|
41
42
|
end
|
42
43
|
end
|
43
|
-
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
46
47
|
end
|
47
48
|
end
|
@@ -20,12 +20,14 @@ module Squib
|
|
20
20
|
|
21
21
|
def_delegators :cairo_cxt, :save, :set_source_color, :paint, :restore,
|
22
22
|
:translate, :rotate, :move_to, :update_pango_layout, :width, :height,
|
23
|
-
:show_pango_layout, :rectangle, :rounded_rectangle, :set_line_width,
|
24
|
-
:
|
25
|
-
:operator=, :show_page, :clip, :transform, :mask,
|
26
|
-
:antialias=, :curve_to, :matrix, :matrix=,
|
27
|
-
:
|
28
|
-
:
|
23
|
+
:show_pango_layout, :rectangle, :rounded_rectangle, :set_line_width,
|
24
|
+
:stroke, :fill, :set_source, :scale, :render_rsvg_handle, :circle,
|
25
|
+
:triangle, :line_to, :operator=, :show_page, :clip, :transform, :mask,
|
26
|
+
:create_pango_layout, :antialias=, :curve_to, :matrix, :matrix=,
|
27
|
+
:identity_matrix, :pango_layout_path, :stroke_preserve, :target,
|
28
|
+
:new_path, :new_sub_path, :reset_clip, :fill_preserve, :close_path,
|
29
|
+
:set_line_join, :set_line_cap, :set_dash, :arc, :arc_negative,
|
30
|
+
:pseudo_blur
|
29
31
|
|
30
32
|
# :nodoc:
|
31
33
|
# @api private
|
@@ -1,12 +1,14 @@
|
|
1
|
+
require_relative 'cairo_context_wrapper'
|
2
|
+
|
1
3
|
module Squib
|
2
4
|
class Card
|
3
5
|
|
4
6
|
# :nodoc:
|
5
7
|
# @api private
|
6
|
-
def save_png(batch)
|
7
|
-
surface = if preprocess_save?(batch)
|
8
|
+
def save_png(batch, shadow)
|
9
|
+
surface = if preprocess_save?(batch, shadow)
|
8
10
|
w, h = compute_dimensions(batch.rotate, batch.trim)
|
9
|
-
preprocessed_save(w, h, batch)
|
11
|
+
preprocessed_save(w, h, batch, shadow)
|
10
12
|
else
|
11
13
|
@cairo_surface
|
12
14
|
end
|
@@ -15,8 +17,8 @@ module Squib
|
|
15
17
|
|
16
18
|
# :nodoc:
|
17
19
|
# @api private
|
18
|
-
def preprocess_save?(batch)
|
19
|
-
batch.rotate != false || batch.trim > 0
|
20
|
+
def preprocess_save?(batch, shadow)
|
21
|
+
batch.rotate != false || batch.trim > 0 || !(shadow.shadow_radius.nil?)
|
20
22
|
end
|
21
23
|
|
22
24
|
def compute_dimensions(rotate, trim)
|
@@ -27,25 +29,62 @@ module Squib
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
def preprocessed_save(
|
31
|
-
new_cc = Cairo::Context.new(Cairo::ImageSurface.new(
|
32
|
+
def preprocessed_save(w, h, batch, shadow)
|
33
|
+
new_cc = Cairo::Context.new(Cairo::ImageSurface.new(w, h))
|
32
34
|
trim_radius = batch.trim_radius
|
33
35
|
if batch.rotate != false
|
34
|
-
new_cc.translate
|
35
|
-
new_cc.rotate
|
36
|
-
new_cc.translate
|
37
|
-
new_cc.rounded_rectangle(0, 0,
|
36
|
+
new_cc.translate w * 0.5, h * 0.5
|
37
|
+
new_cc.rotate batch.angle
|
38
|
+
new_cc.translate h * -0.5, w * -0.5
|
39
|
+
new_cc.rounded_rectangle(0, 0, h, w, trim_radius, trim_radius)
|
38
40
|
else
|
39
|
-
new_cc.rounded_rectangle(0, 0,
|
41
|
+
new_cc.rounded_rectangle(0, 0, w, h, trim_radius, trim_radius)
|
40
42
|
end
|
41
43
|
new_cc.clip
|
42
44
|
new_cc.set_source(@cairo_surface, -batch.trim, -batch.trim)
|
43
45
|
new_cc.paint
|
46
|
+
new_cc.reset_clip
|
47
|
+
new_cc = drop_shadow(new_cc, shadow, batch) unless shadow.shadow_radius.nil?
|
44
48
|
return new_cc.target
|
45
49
|
end
|
46
50
|
|
51
|
+
# pseudo-blur behave weirdly with a radius of 0 - wrapping
|
52
|
+
def blur(cc, r, &block)
|
53
|
+
if r == 0
|
54
|
+
yield(block)
|
55
|
+
else
|
56
|
+
cc.pseudo_blur(r, &block)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def drop_shadow(cc, s, batch)
|
61
|
+
off_x = s.shadow_offset_x
|
62
|
+
off_y = s.shadow_offset_y
|
63
|
+
s_trim = s.shadow_trim
|
64
|
+
s_rad = s.shadow_radius
|
65
|
+
new_w = cc.target.width + off_x + 3 * s_rad - (2 * s_trim)
|
66
|
+
new_h = cc.target.height + off_y + 3 * s_rad - (2 * s_trim)
|
67
|
+
new_cc = Squib::Graphics::CairoContextWrapper.new(
|
68
|
+
Cairo::Context.new(Cairo::ImageSurface.new(new_w, new_h)))
|
69
|
+
blur(new_cc, s_rad) do
|
70
|
+
# fill in with shadow color
|
71
|
+
new_cc.set_source_squibcolor s.shadow_color
|
72
|
+
new_cc.rectangle 0, 0, new_cc.target.width, new_cc.target.height
|
73
|
+
new_cc.fill
|
74
|
+
# then, paint but blend with :dest_in to get a shadow-shaped drawing
|
75
|
+
new_cc.set_source cc.target, s_rad + off_x, s_rad + off_y
|
76
|
+
new_cc.operator = :dest_in # see https://www.cairographics.org/operators/
|
77
|
+
new_cc.paint
|
78
|
+
end
|
79
|
+
new_cc.set_source cc.target, s_rad, s_rad
|
80
|
+
new_cc.operator = :over
|
81
|
+
new_cc.paint
|
82
|
+
return new_cc
|
83
|
+
end
|
84
|
+
|
47
85
|
def write_png(surface, i, b)
|
48
|
-
|
86
|
+
filename = "#{b.dir}/#{b.prefix}#{b.count_format % i}#{b.suffix}.png"
|
87
|
+
surface.write_to_png filename
|
49
88
|
end
|
50
89
|
|
51
90
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Squib
|
2
2
|
module Sprues
|
3
3
|
UNIT_REGEX = /^(\d*[.])?\d+(in|cm|mm)$/
|
4
|
-
|
4
|
+
COORD_REGEX = /^\-?(\d*[.])?\d+(in|cm|mm)$/
|
5
|
+
ROTATE_REGEX = /^\-?(\d*[.])?\d+(deg|rad)?$/
|
5
6
|
SCHEMA = {
|
6
7
|
'sheet_width' => UNIT_REGEX,
|
7
8
|
'sheet_height' => UNIT_REGEX,
|
@@ -35,8 +36,8 @@ module Squib
|
|
35
36
|
}]]
|
36
37
|
},
|
37
38
|
'cards' => [[{
|
38
|
-
'x' =>
|
39
|
-
'y' =>
|
39
|
+
'x' => COORD_REGEX,
|
40
|
+
'y' => COORD_REGEX,
|
40
41
|
'rotate' => [
|
41
42
|
:optional, Numeric,
|
42
43
|
ClassyHash::G.enum(:clockwise, :counterclockwise, :turnaround),
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pango'
|
2
|
+
module Squib
|
3
|
+
|
4
|
+
# List all system fonts that Cairo/Pango can see
|
5
|
+
# Wow this call was convoluted...
|
6
|
+
# Returns array of strings with the names of fonts
|
7
|
+
module_function def system_fonts
|
8
|
+
cc = Cairo::Context.new(Cairo::ImageSurface.new(0,0)) # empty image
|
9
|
+
cc.create_pango_layout.context.families.map {|f| f.name }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Prints out the system fonts in sorted order
|
13
|
+
module_function def print_system_fonts
|
14
|
+
puts "== DEBUG: Squib knows about these fonts =="
|
15
|
+
puts system_fonts.sort
|
16
|
+
end
|
17
|
+
end
|
data/lib/squib/version.rb
CHANGED
data/samples/saves/_saves.rb
CHANGED
@@ -50,3 +50,13 @@ Squib::Deck.new(width: 825, height: 1125, cards: 16) do
|
|
50
50
|
columns: 2, rows: 1,
|
51
51
|
margin: 75, gap: 5, trim: 37
|
52
52
|
end
|
53
|
+
|
54
|
+
Squib::Deck.new(width: 100, height: 100, cards: 3) do
|
55
|
+
background color: :grey
|
56
|
+
text str: 'Hi', font: 'Arial 18'
|
57
|
+
|
58
|
+
# Test bug 332.
|
59
|
+
# When we only have 3 cards but want a 2x4 grid with lots of empty spaces.
|
60
|
+
# Buggy behavior was to revert to 1 row and not respect the rows arg.
|
61
|
+
save_sheet prefix: 'save_sheet_bug332_', rows: 2, columns: 4
|
62
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'squib'
|
2
|
+
# The save_png method supports drop shadows on the final save
|
3
|
+
# This is useful for when you want to generate images for your rulebook
|
4
|
+
|
5
|
+
Squib::Deck.new(width: 100, height: 150) do
|
6
|
+
background color: '#abc'
|
7
|
+
svg file: '../spanner.svg',
|
8
|
+
x: 'middle - 25', y: 'middle - 25',
|
9
|
+
width: 50, height: 50
|
10
|
+
|
11
|
+
# Shadows off by default, i.e. shadow_radius is nil
|
12
|
+
# So our final dimensions are 100 - 2*15 and 150-2*15
|
13
|
+
save_png prefix: 'no_shadow_', trim: 15, trim_radius: 15
|
14
|
+
|
15
|
+
# Here's a nice-looking drop shadow
|
16
|
+
# Defaults are designed to be generally good, so I recommend just
|
17
|
+
# trying out a shadow_radius of 3 to 10 and see how it looks first
|
18
|
+
save_png prefix: 'with_shadow_', trim: 15, trim_radius: 15,
|
19
|
+
shadow_radius: 8,
|
20
|
+
shadow_offset_x: 3, shadow_offset_y: 3, # about r / 2.5 looks good
|
21
|
+
shadow_trim: 2.5, # about r/ 3 looks good
|
22
|
+
shadow_color: '#101010aa' #tip: start the shadow color kinda transparent
|
23
|
+
|
24
|
+
# Don't want a blur? Use a radius of 0
|
25
|
+
save_png prefix: 'no_blur_', trim: 15, trim_radius: 15,
|
26
|
+
shadow_radius: 0
|
27
|
+
|
28
|
+
# Ok this next stop is crazytown, but it does give you ultimate control
|
29
|
+
# Remember that all Squib colors can also be gradients.
|
30
|
+
# They can be clunky but they do work here.
|
31
|
+
# - x,y's are centered in the card itself
|
32
|
+
# - stops go from fully empty to fully black
|
33
|
+
# - we need to still turn on radius to get the effect
|
34
|
+
# - but, this makes the upper-left corner not have a glowing effect and
|
35
|
+
# have a harder edge, which (to my eye at least) feels more realistic
|
36
|
+
# since the card would obscure the upper-left shadow at that angle
|
37
|
+
# - this also allows you have a larger, softer blur without making it look
|
38
|
+
# like it's glowing
|
39
|
+
#
|
40
|
+
# Oh just because it's easier to write we can use a ruby heredoc
|
41
|
+
save_png prefix: 'gradient_blur_', trim: 15, trim_radius: 15,
|
42
|
+
shadow_radius: 10,
|
43
|
+
shadow_color: <<~EOS
|
44
|
+
(25,25)
|
45
|
+
(175,175)
|
46
|
+
#0000@0.0
|
47
|
+
#000f@1.0
|
48
|
+
EOS
|
49
|
+
|
50
|
+
# This one looks weird I know but it's for regression testing
|
51
|
+
save_png prefix: 'with_shadow_test_',
|
52
|
+
trim: 15, trim_radius: 15, rotate: :clockwise,
|
53
|
+
shadow_offset_x: 5, shadow_offset_y: 25, shadow_radius: 10,
|
54
|
+
shadow_trim: 10,
|
55
|
+
shadow_color: '#123'
|
56
|
+
end
|
57
|
+
|
58
|
+
Squib::Deck.new(width:50, height: 50) do
|
59
|
+
|
60
|
+
# What if we had a transparent card but just some shapes?
|
61
|
+
# Like chits or something
|
62
|
+
|
63
|
+
# background defaults to fully transparent here
|
64
|
+
|
65
|
+
png file: 'doodle.png'
|
66
|
+
|
67
|
+
save_png prefix: 'transparent_bg_shadow_',
|
68
|
+
shadow_radius: 2,
|
69
|
+
shadow_offset_x: 2, shadow_offset_y: 2,
|
70
|
+
shadow_color: :black
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# require 'squib'
|
2
|
+
require_relative '../../lib/squib'
|
3
|
+
|
4
|
+
# Per issue #334, sometimes Pango doesn't find the font file you want
|
5
|
+
# Pango requires fonts to be installed on the system, but sometimes the
|
6
|
+
# font name is not obvious. e.g. "Foo Regular" might be actually named "Foo"
|
7
|
+
# Use these methods to debug this problem
|
8
|
+
|
9
|
+
# Usually you would just run this method to see what fonts are installed
|
10
|
+
# This is commented out to make our test cases
|
11
|
+
# Squib.print_system_fonts
|
12
|
+
|
13
|
+
Squib.system_fonts.include? 'Open Sans' # checks if we have Open Sans installed
|
14
|
+
# Note: does nothing since it's just a check
|
data/samples/units/_cells.rb
CHANGED
@@ -19,7 +19,7 @@ Squib::Deck.new(width: '1.5in', height: '1.5in') do
|
|
19
19
|
# Technically, the "cell" is actually a "unit", so you can even combine
|
20
20
|
# with xywh shorhands!!
|
21
21
|
rect fill_color: :red,
|
22
|
-
x: 'middle + 0.5c', y: '
|
22
|
+
x: 'middle + 0.5c', y: 'deck - 1.5c',
|
23
23
|
width: '1c', height: '1c'
|
24
24
|
|
25
25
|
# And, unlike xywh shorthands, this applies basically everywhere we support
|
@@ -20,14 +20,13 @@ Squib::Deck.new(width: '0.5in', height: '0.25in') do
|
|
20
20
|
|
21
21
|
# We can also do width-, height-, width/, height/
|
22
22
|
rect x: 20, y: 5, stroke_color: :green,
|
23
|
-
width: '
|
23
|
+
width: 'deck - 0.1in', height: 10
|
24
24
|
|
25
|
-
rect x: 10, y: 50, width: 10, height: '
|
25
|
+
rect x: 10, y: 50, width: 10, height: 'deck / 3',
|
26
26
|
stroke_color: :purple
|
27
27
|
|
28
28
|
# And middle+/-
|
29
|
-
|
30
|
-
rect x: 'middle + 0.1in', y: 'middle - 0.1in',
|
29
|
+
rect x: 'middle + 0.1in', y: 'center - 0.1in',
|
31
30
|
width: '0.1in', height: '0.1in', fill_color: :blue
|
32
31
|
|
33
32
|
# Layouts apply this too.
|
data/squib.gemspec
CHANGED
@@ -31,18 +31,18 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.test_files = spec.files.grep(/^(spec|samples|docs|benchmarks)\//)
|
32
32
|
spec.require_paths = ['lib']
|
33
33
|
|
34
|
-
spec.add_runtime_dependency 'cairo', '~> 1.
|
35
|
-
spec.add_runtime_dependency 'classy_hash', '0.
|
34
|
+
spec.add_runtime_dependency 'cairo', '~> 1.17'
|
35
|
+
spec.add_runtime_dependency 'classy_hash', '1.0.0'
|
36
36
|
spec.add_runtime_dependency 'gio2', '~> 3.4'
|
37
37
|
spec.add_runtime_dependency 'gobject-introspection', '~> 3.4'
|
38
38
|
spec.add_runtime_dependency 'highline', '2.0.3'
|
39
39
|
spec.add_runtime_dependency 'mercenary', '0.4.0'
|
40
|
-
spec.add_runtime_dependency 'nokogiri', '~> 1.
|
40
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.11'
|
41
41
|
spec.add_runtime_dependency 'pango', '~> 3.4'
|
42
42
|
spec.add_runtime_dependency 'rainbow', '~> 3.0'
|
43
43
|
spec.add_runtime_dependency 'roo', '~> 2.8'
|
44
44
|
spec.add_runtime_dependency 'rsvg2', '~> 3.4'
|
45
|
-
spec.add_runtime_dependency 'ruby-progressbar', '~> 1.
|
45
|
+
spec.add_runtime_dependency 'ruby-progressbar', '~> 1.11'
|
46
46
|
|
47
47
|
spec.add_development_dependency 'activesupport'
|
48
48
|
spec.add_development_dependency 'bundler'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Meneely
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cairo
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.17'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.17'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: classy_hash
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 1.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 1.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gio2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.11'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
110
|
+
version: '1.11'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pango
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '1.
|
173
|
+
version: '1.11'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '1.
|
180
|
+
version: '1.11'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: activesupport
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -358,6 +358,7 @@ extra_rdoc_files:
|
|
358
358
|
- samples/saves/_save_filenames.rb
|
359
359
|
- samples/saves/_save_pdf.rb
|
360
360
|
- samples/saves/_showcase.rb
|
361
|
+
- samples/shadows/_shadow.rb
|
361
362
|
- samples/shapes/_draw_shapes.rb
|
362
363
|
- samples/shapes/_proofs.rb
|
363
364
|
- samples/sprues/_advanced_sprues.rb
|
@@ -365,7 +366,9 @@ extra_rdoc_files:
|
|
365
366
|
- samples/sprues/_fold_sheet.rb
|
366
367
|
- samples/sprues/_hex_tiles.rb
|
367
368
|
- samples/sprues/_mints.rb
|
369
|
+
- samples/sprues/_negative_coords.rb
|
368
370
|
- samples/sprues/_sprue_example.rb
|
371
|
+
- samples/system_font_debug/_list_fonts.rb
|
369
372
|
- samples/text/bug134.rb
|
370
373
|
- samples/text/_embed_text.rb
|
371
374
|
- samples/text/_text.rb
|
@@ -396,6 +399,7 @@ files:
|
|
396
399
|
- lib/squib/args/csv_opts.rb
|
397
400
|
- lib/squib/args/dir_validator.rb
|
398
401
|
- lib/squib/args/draw.rb
|
402
|
+
- lib/squib/args/drop_shadow.rb
|
399
403
|
- lib/squib/args/embed_adjust.rb
|
400
404
|
- lib/squib/args/embed_key.rb
|
401
405
|
- lib/squib/args/hand_special.rb
|
@@ -517,6 +521,7 @@ files:
|
|
517
521
|
- lib/squib/sprues/invalid_sprue_definition.rb
|
518
522
|
- lib/squib/sprues/sprue.rb
|
519
523
|
- lib/squib/sprues/sprue_schema.rb
|
524
|
+
- lib/squib/system_fonts.rb
|
520
525
|
- lib/squib/version.rb
|
521
526
|
- samples/autoscale_font/_autoscale_font.rb
|
522
527
|
- samples/backend/_backend.rb
|
@@ -551,6 +556,7 @@ files:
|
|
551
556
|
- samples/saves/_save_pdf.rb
|
552
557
|
- samples/saves/_saves.rb
|
553
558
|
- samples/saves/_showcase.rb
|
559
|
+
- samples/shadows/_shadow.rb
|
554
560
|
- samples/shapes/_draw_shapes.rb
|
555
561
|
- samples/shapes/_proofs.rb
|
556
562
|
- samples/sprues/_advanced_sprues.rb
|
@@ -558,7 +564,9 @@ files:
|
|
558
564
|
- samples/sprues/_fold_sheet.rb
|
559
565
|
- samples/sprues/_hex_tiles.rb
|
560
566
|
- samples/sprues/_mints.rb
|
567
|
+
- samples/sprues/_negative_coords.rb
|
561
568
|
- samples/sprues/_sprue_example.rb
|
569
|
+
- samples/system_font_debug/_list_fonts.rb
|
562
570
|
- samples/text/_embed_text.rb
|
563
571
|
- samples/text/_text.rb
|
564
572
|
- samples/text/_text_options.rb
|
@@ -583,13 +591,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
583
591
|
version: 2.5.0
|
584
592
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
585
593
|
requirements:
|
586
|
-
- - "
|
594
|
+
- - ">="
|
587
595
|
- !ruby/object:Gem::Version
|
588
|
-
version:
|
596
|
+
version: '0'
|
589
597
|
requirements:
|
590
598
|
- On Windows, you need the Ruby+DevKit. See https://rubyinstaller.org/downloads
|
591
|
-
rubygems_version: 3.
|
592
|
-
signing_key:
|
599
|
+
rubygems_version: 3.0.3
|
600
|
+
signing_key:
|
593
601
|
specification_version: 2
|
594
602
|
summary: A Ruby DSL for prototyping card games
|
595
603
|
test_files:
|
@@ -626,6 +634,7 @@ test_files:
|
|
626
634
|
- samples/saves/_save_pdf.rb
|
627
635
|
- samples/saves/_saves.rb
|
628
636
|
- samples/saves/_showcase.rb
|
637
|
+
- samples/shadows/_shadow.rb
|
629
638
|
- samples/shapes/_draw_shapes.rb
|
630
639
|
- samples/shapes/_proofs.rb
|
631
640
|
- samples/sprues/_advanced_sprues.rb
|
@@ -633,7 +642,9 @@ test_files:
|
|
633
642
|
- samples/sprues/_fold_sheet.rb
|
634
643
|
- samples/sprues/_hex_tiles.rb
|
635
644
|
- samples/sprues/_mints.rb
|
645
|
+
- samples/sprues/_negative_coords.rb
|
636
646
|
- samples/sprues/_sprue_example.rb
|
647
|
+
- samples/system_font_debug/_list_fonts.rb
|
637
648
|
- samples/text/_embed_text.rb
|
638
649
|
- samples/text/_text.rb
|
639
650
|
- samples/text/_text_options.rb
|