squib 0.0.1 → 0.0.2
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/.gitignore +29 -26
- data/.travis.yml +6 -4
- data/.yardopts +6 -0
- data/API.md +59 -0
- data/Gemfile +2 -2
- data/LICENSE.txt +22 -22
- data/README.md +92 -55
- data/Rakefile +11 -6
- data/bin/squib +19 -2
- data/lib/squib/api/background.rb +16 -11
- data/lib/squib/api/data.rb +52 -29
- data/lib/squib/api/image.rb +48 -10
- data/lib/squib/api/save.rb +36 -15
- data/lib/squib/api/settings.rb +35 -0
- data/lib/squib/api/shapes.rb +106 -12
- data/lib/squib/api/text.rb +45 -25
- data/lib/squib/api/units.rb +17 -0
- data/lib/squib/card.rb +36 -27
- data/lib/squib/commands/new.rb +40 -0
- data/lib/squib/constants.rb +40 -0
- data/lib/squib/deck.rb +113 -48
- data/lib/squib/graphics/background.rb +12 -10
- data/lib/squib/graphics/image.rb +28 -12
- data/lib/squib/graphics/save_doc.rb +50 -21
- data/lib/squib/graphics/save_images.rb +10 -8
- data/lib/squib/graphics/shapes.rb +55 -11
- data/lib/squib/graphics/text.rb +107 -27
- data/lib/squib/input_helpers.rb +140 -0
- data/lib/squib/project_template/.gitignore +3 -0
- data/lib/squib/project_template/ABOUT.md +19 -0
- data/lib/squib/project_template/Gemfile +3 -0
- data/lib/squib/project_template/PNP NOTES.md +4 -0
- data/lib/squib/project_template/_output/gitkeep.txt +1 -0
- data/lib/squib/project_template/config.yml +2 -0
- data/lib/squib/project_template/deck.rb +6 -0
- data/lib/squib/project_template/layout.yml +0 -0
- data/lib/squib/version.rb +6 -3
- data/lib/squib.rb +19 -2
- data/samples/_output/gitkeep.txt +0 -0
- data/samples/basic.rb +20 -22
- data/samples/colors.rb +17 -0
- data/samples/custom-config.yml +1 -0
- data/samples/custom-layout.yml +34 -0
- data/samples/custom_config.rb +6 -0
- data/samples/draw_shapes.rb +19 -0
- data/samples/excel.rb +19 -16
- data/samples/hello_world.rb +7 -0
- data/samples/load_images.rb +19 -0
- data/samples/pokercard.png +0 -0
- data/samples/ranges.rb +47 -0
- data/samples/sample.xlsx +0 -0
- data/samples/save_pdf.rb +14 -0
- data/samples/spanner.svg +91 -0
- data/samples/text_options.rb +58 -0
- data/samples/tgc_proofs.rb +20 -0
- data/samples/units.rb +12 -0
- data/samples/use_layout.rb +29 -0
- data/spec/api/api_text_spec.rb +37 -0
- data/spec/commands/new_spec.rb +48 -0
- data/spec/deck_spec.rb +49 -48
- data/spec/samples_run_spec.rb +15 -0
- data/spec/spec_helper.rb +9 -0
- data/squib.gemspec +42 -27
- metadata +109 -11
- data/samples/_output/watch.html +0 -25
@@ -1,22 +1,51 @@
|
|
1
|
-
module Squib
|
2
|
-
class Deck
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
module Squib
|
2
|
+
class Deck
|
3
|
+
|
4
|
+
# Lays out the cards in range and renders a PDF
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
# save_pdf file: 'deck.pdf', margin: 75, gap: 5, trim: 37
|
8
|
+
#
|
9
|
+
# @option opts file [String] the name of the PDF file to save.
|
10
|
+
# @option opts dir [String] (_output) the directory to save to. Created if it doesn't exist.
|
11
|
+
# @option opts margin [Integer] (75) the margin around the outside of the page
|
12
|
+
# @option opts gap [Integer] (0) the space in pixels between the cards
|
13
|
+
# @option opts trim [Integer] (0) the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play)
|
14
|
+
# @return [nil]
|
15
|
+
# @api public
|
16
|
+
def save_pdf(opts = {})
|
17
|
+
p = needs(opts, [:file_to_save, :creatable_dir, :margin, :gap, :trim])
|
18
|
+
width = 11 * @dpi ; height = 8.5 * @dpi #TODO: allow this to be specified too
|
19
|
+
cc = Cairo::Context.new(Cairo::PDFSurface.new("#{p[:dir]}/#{p[:file]}", width, height))
|
20
|
+
x = p[:margin] ; y = p[:margin]
|
21
|
+
@cards.each_with_index do |card, i|
|
22
|
+
surface = trim(card.cairo_surface, p[:trim], @width, @height)
|
23
|
+
cc.set_source(surface, x, y)
|
24
|
+
cc.paint
|
25
|
+
x += surface.width + p[:gap]
|
26
|
+
if x > (width - surface.width - p[:margin])
|
27
|
+
x = p[:margin]
|
28
|
+
y += surface.height + p[:gap]
|
29
|
+
if y > (height - surface.height - p[:margin])
|
30
|
+
x = p[:margin] ; y = p[:margin]
|
31
|
+
cc.show_page #next page
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# :nodoc:
|
38
|
+
# @api private
|
39
|
+
def trim(surface, trim, width, height)
|
40
|
+
if trim > 0
|
41
|
+
tmp = Cairo::ImageSurface.new(width-2*trim, height-2*trim)
|
42
|
+
cc = Cairo::Context.new(tmp)
|
43
|
+
cc.set_source(surface,-1*trim, -1*trim)
|
44
|
+
cc.paint
|
45
|
+
surface = tmp
|
46
|
+
end
|
47
|
+
surface
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
22
51
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
-
module Squib
|
2
|
-
class Card
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
module Squib
|
2
|
+
class Card
|
3
|
+
|
4
|
+
# :nodoc:
|
5
|
+
# @api private
|
6
|
+
def save_png(i, dir, prefix)
|
7
|
+
cairo_context.target.write_to_png("#{dir}/#{prefix}#{i}.png")
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
9
11
|
end
|
@@ -1,12 +1,56 @@
|
|
1
|
-
module Squib
|
2
|
-
class Card
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
cc
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
module Squib
|
2
|
+
class Card
|
3
|
+
|
4
|
+
# :nodoc:
|
5
|
+
# @api private
|
6
|
+
def rect(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width)
|
7
|
+
width=@width if width==:native; height=@height if height==:native
|
8
|
+
cc = cairo_context
|
9
|
+
cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
|
10
|
+
cc.set_source_color(stroke_color)
|
11
|
+
cc.set_line_width(stroke_width)
|
12
|
+
cc.stroke
|
13
|
+
cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
|
14
|
+
cc.set_source_color(fill_color)
|
15
|
+
cc.fill
|
16
|
+
end
|
17
|
+
|
18
|
+
# :nodoc:
|
19
|
+
# @api private
|
20
|
+
def circle(x, y, radius, fill_color, stroke_color, stroke_width)
|
21
|
+
cc = cairo_context
|
22
|
+
cc.circle(x, y, radius)
|
23
|
+
cc.set_source_color(stroke_color)
|
24
|
+
cc.set_line_width(stroke_width)
|
25
|
+
cc.stroke
|
26
|
+
cc.circle(x, y, radius)
|
27
|
+
cc.set_source_color(fill_color)
|
28
|
+
cc.fill
|
29
|
+
end
|
30
|
+
|
31
|
+
# :nodoc:
|
32
|
+
# @api private
|
33
|
+
def triangle(x1, y1, x2, y2, x3, y3, fill_color, stroke_color, stroke_width)
|
34
|
+
cc = cairo_context
|
35
|
+
cc.triangle(x1, y1, x2, y2, x3, y3)
|
36
|
+
cc.set_source_color(stroke_color)
|
37
|
+
cc.set_line_width(stroke_width)
|
38
|
+
cc.stroke
|
39
|
+
cc.triangle(x1, y1, x2, y2, x3, y3)
|
40
|
+
cc.set_source_color(fill_color)
|
41
|
+
cc.fill
|
42
|
+
end
|
43
|
+
|
44
|
+
# :nodoc:
|
45
|
+
# @api private
|
46
|
+
def line(x1, y1, x2, y2, stroke_color, stroke_width)
|
47
|
+
cc = cairo_context
|
48
|
+
cc.move_to(x1, y1)
|
49
|
+
cc.line_to(x2, y2)
|
50
|
+
cc.set_source_color(stroke_color)
|
51
|
+
cc.set_line_width(stroke_width)
|
52
|
+
cc.stroke
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
12
56
|
end
|
data/lib/squib/graphics/text.rb
CHANGED
@@ -1,28 +1,108 @@
|
|
1
|
-
require 'pango'
|
2
|
-
|
3
|
-
module Squib
|
4
|
-
class Card
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
w =
|
13
|
-
w
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
require 'pango'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
class Card
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
# @api private
|
8
|
+
def draw_text_hint(x,y,layout, color)
|
9
|
+
return if color.nil? && @deck.text_hint.nil?
|
10
|
+
color ||= @deck.text_hint
|
11
|
+
# when w,h < 0, it was never set. extents[0] are ink extents
|
12
|
+
w = layout.width / Pango::SCALE
|
13
|
+
w = layout.extents[1].width / Pango::SCALE if w < 0
|
14
|
+
h = layout.height / Pango::SCALE
|
15
|
+
h = layout.extents[1].height / Pango::SCALE if h < 0
|
16
|
+
rect(x,y,w,h,0,0,'#0000',color, 2.0)
|
17
|
+
end
|
18
|
+
|
19
|
+
# :nodoc:
|
20
|
+
# @api private
|
21
|
+
def ellipsize(layout, options)
|
22
|
+
unless options[:ellipsize].nil?
|
23
|
+
h = { :none => Pango::Layout::ELLIPSIZE_NONE,
|
24
|
+
:start => Pango::Layout::ELLIPSIZE_START,
|
25
|
+
:middle => Pango::Layout::ELLIPSIZE_MIDDLE,
|
26
|
+
:end => Pango::Layout::ELLIPSIZE_END,
|
27
|
+
true => Pango::Layout::ELLIPSIZE_END,
|
28
|
+
false => Pango::Layout::ELLIPSIZE_NONE
|
29
|
+
}
|
30
|
+
layout.ellipsize = h[options[:ellipsize]]
|
31
|
+
end
|
32
|
+
layout
|
33
|
+
end
|
34
|
+
|
35
|
+
# :nodoc:
|
36
|
+
# @api private
|
37
|
+
def wrap(layout, options)
|
38
|
+
unless options[:wrap].nil?
|
39
|
+
h = { :word => Pango::Layout::WRAP_WORD,
|
40
|
+
:char => Pango::Layout::WRAP_CHAR,
|
41
|
+
:word_char => Pango::Layout::WRAP_WORD_CHAR,
|
42
|
+
true => Pango::Layout::WRAP_WORD_CHAR,
|
43
|
+
false => nil,
|
44
|
+
:none => nil
|
45
|
+
}
|
46
|
+
layout.wrap = h[options[:wrap]]
|
47
|
+
end
|
48
|
+
layout
|
49
|
+
end
|
50
|
+
|
51
|
+
# :nodoc:
|
52
|
+
# @api private
|
53
|
+
def align(layout, options)
|
54
|
+
unless options[:align].nil?
|
55
|
+
h = { :left => Pango::ALIGN_LEFT,
|
56
|
+
:right => Pango::ALIGN_RIGHT,
|
57
|
+
:center => Pango::ALIGN_CENTER
|
58
|
+
}
|
59
|
+
layout.alignment = h[options[:align]]
|
60
|
+
end
|
61
|
+
layout
|
62
|
+
end
|
63
|
+
|
64
|
+
# :nodoc:
|
65
|
+
# @api private
|
66
|
+
def valign(cc, layout, x, y, valign)
|
67
|
+
if layout.height > 0
|
68
|
+
ink_extents = layout.extents[1]
|
69
|
+
case valign
|
70
|
+
when :middle
|
71
|
+
cc.move_to(x, y + (layout.height - ink_extents.height) / (2 * Pango::SCALE))
|
72
|
+
when :bottom
|
73
|
+
cc.move_to(x, y + (layout.height - ink_extents.height) / Pango::SCALE)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# :nodoc:
|
79
|
+
# @api private
|
80
|
+
def setwh(layout, options)
|
81
|
+
layout.width = options[:width] * Pango::SCALE unless options[:width].nil? || options[:width] == :native
|
82
|
+
layout.height = options[:height] * Pango::SCALE unless options[:height].nil? || options[:height] == :native
|
83
|
+
layout
|
84
|
+
end
|
85
|
+
|
86
|
+
# :nodoc:
|
87
|
+
# @api private
|
88
|
+
def text(str, font, x, y, color, options)
|
89
|
+
cc = cairo_context
|
90
|
+
cc.set_source_color(color)
|
91
|
+
cc.move_to(x,y)
|
92
|
+
layout = cc.create_pango_layout
|
93
|
+
layout.font_description = Pango::FontDescription.new(font)
|
94
|
+
layout.text = str.to_s
|
95
|
+
layout.markup = str.to_s if options[:markup]
|
96
|
+
layout = setwh(layout, options)
|
97
|
+
layout = wrap(layout, options)
|
98
|
+
layout = ellipsize(layout, options)
|
99
|
+
layout = align(layout, options)
|
100
|
+
layout.justify = options[:justify] unless options[:justify].nil?
|
101
|
+
cc.update_pango_layout(layout)
|
102
|
+
valign(cc, layout, x,y, options[:valign])
|
103
|
+
cc.update_pango_layout(layout) ; cc.show_pango_layout(layout)
|
104
|
+
draw_text_hint(x,y,layout,options[:hint])
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
28
108
|
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'squib/constants'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
# :nodoc:
|
5
|
+
# @api private
|
6
|
+
module InputHelpers
|
7
|
+
|
8
|
+
# :nodoc:
|
9
|
+
# @api private
|
10
|
+
def needs(opts, params)
|
11
|
+
opts = layoutify(opts) if params.include? :layout
|
12
|
+
opts = Squib::SYSTEM_DEFAULTS.merge(opts)
|
13
|
+
opts = rangeify(opts) if params.include? :range
|
14
|
+
opts = fileify(opts) if params.include? :file
|
15
|
+
opts = fileify(opts, false, true) if params.include? :file_to_save
|
16
|
+
opts = fileify(opts, true) if params.include? :files
|
17
|
+
opts = colorify(opts) if params.include? :color
|
18
|
+
opts = colorify(opts, true) if params.include? :nillable_color
|
19
|
+
opts = dirify(opts) if params.include? :dir
|
20
|
+
opts = dirify(opts, true) if params.include? :creatable_dir
|
21
|
+
opts = fontify(opts) if params.include? :font
|
22
|
+
opts = radiusify(opts) if params.include? :radius
|
23
|
+
opts = svgidify(opts) if params.include? :svgid
|
24
|
+
opts = formatify(opts) if params.include? :formats
|
25
|
+
opts
|
26
|
+
end
|
27
|
+
module_function :needs
|
28
|
+
|
29
|
+
# :nodoc:
|
30
|
+
# @api private
|
31
|
+
def layoutify(opts)
|
32
|
+
unless opts[:layout].nil?
|
33
|
+
entry = @layout[opts[:layout].to_s]
|
34
|
+
unless entry.nil?
|
35
|
+
entry.each do |key, value|
|
36
|
+
opts[key.to_sym] ||= entry[key]
|
37
|
+
end
|
38
|
+
else
|
39
|
+
logger.warn "Layout entry #{opts[:layout]} does not exist."
|
40
|
+
end
|
41
|
+
end
|
42
|
+
opts
|
43
|
+
end
|
44
|
+
module_function :layoutify
|
45
|
+
|
46
|
+
# :nodoc:
|
47
|
+
# @api private
|
48
|
+
def formatify(opts)
|
49
|
+
opts[:format] = [opts[:format]].flatten
|
50
|
+
opts
|
51
|
+
end
|
52
|
+
module_function :formatify
|
53
|
+
|
54
|
+
# :nodoc:
|
55
|
+
# @api private
|
56
|
+
def rangeify (opts)
|
57
|
+
range = opts[:range]
|
58
|
+
raise 'Range cannot be nil' if range.nil?
|
59
|
+
range = 0..(@cards.size-1) if range == :all
|
60
|
+
range = range..range if range.is_a? Integer
|
61
|
+
if range.max > (@cards.size-1)
|
62
|
+
raise "#{range} is outside of deck range of 0..#{@cards.size-1}"
|
63
|
+
end
|
64
|
+
opts[:range] = range
|
65
|
+
opts
|
66
|
+
end
|
67
|
+
module_function :rangeify
|
68
|
+
|
69
|
+
# :nodoc:
|
70
|
+
# @api private
|
71
|
+
def fileify(opts, expand_singletons=false, allow_non_exist=false)
|
72
|
+
opts[:file] = [opts[:file]] * @cards.size if expand_singletons
|
73
|
+
files = [opts[:file]].flatten
|
74
|
+
files.each do |file|
|
75
|
+
unless File.exists?(file) || allow_non_exist
|
76
|
+
raise "File #{File.expand_path(file)} does not exist!"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
opts
|
80
|
+
end
|
81
|
+
module_function :fileify
|
82
|
+
|
83
|
+
# :nodoc:
|
84
|
+
# @api private
|
85
|
+
def dirify(opts, allow_create=false)
|
86
|
+
return opts if Dir.exists?(opts[:dir])
|
87
|
+
if allow_create
|
88
|
+
Squib.logger.warn "Dir #{opts[:dir]} does not exist, creating it."
|
89
|
+
Dir.mkdir opts[:dir]
|
90
|
+
return opts
|
91
|
+
else
|
92
|
+
raise "#{opts[:dir]} does not exist!"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
module_function :dirify
|
96
|
+
|
97
|
+
# :nodoc:
|
98
|
+
# @api private
|
99
|
+
def colorify(opts, nillable=false)
|
100
|
+
if nillable # for optional color arguments like text hints
|
101
|
+
opts[:color] = Cairo::Color.parse(opts[:color]) unless opts[:color].nil?
|
102
|
+
else
|
103
|
+
opts[:color] = Cairo::Color.parse(opts[:color])
|
104
|
+
end
|
105
|
+
opts
|
106
|
+
end
|
107
|
+
module_function :colorify
|
108
|
+
|
109
|
+
# :nodoc:
|
110
|
+
# @api private
|
111
|
+
def fontify (opts)
|
112
|
+
opts[:font] = @font if opts[:font]==:use_set
|
113
|
+
opts[:font] = Squib::SYSTEM_DEFAULTS[:default_font] if opts[:font] == :default
|
114
|
+
opts
|
115
|
+
end
|
116
|
+
module_function :fontify
|
117
|
+
|
118
|
+
# :nodoc:
|
119
|
+
# @api private
|
120
|
+
def radiusify(opts)
|
121
|
+
unless opts[:radius].nil?
|
122
|
+
opts[:x_radius] = opts[:radius]
|
123
|
+
opts[:y_radius] = opts[:radius]
|
124
|
+
end
|
125
|
+
opts
|
126
|
+
end
|
127
|
+
module_function :radiusify
|
128
|
+
|
129
|
+
# :nodoc:
|
130
|
+
# @api private
|
131
|
+
def svgidify(opts)
|
132
|
+
unless opts[:id].nil?
|
133
|
+
opts[:id] = '#' << opts[:id] unless opts[:id].start_with? '#'
|
134
|
+
end
|
135
|
+
opts
|
136
|
+
end
|
137
|
+
module_function :svgidify
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Keep this here so that Git knows to keep the _output directory on a fresh clone
|
File without changes
|
data/lib/squib/version.rb
CHANGED
data/lib/squib.rb
CHANGED
@@ -1,2 +1,19 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'logger'
|
2
|
+
require 'cairo'
|
3
|
+
require 'pango'
|
4
|
+
require 'rsvg2'
|
5
|
+
require 'squib/version'
|
6
|
+
require 'squib/commands/new'
|
7
|
+
require 'squib/deck'
|
8
|
+
require 'squib/card'
|
9
|
+
|
10
|
+
module Squib
|
11
|
+
|
12
|
+
# :nodoc:
|
13
|
+
# @api private
|
14
|
+
def logger
|
15
|
+
@logger ||= Logger.new(STDOUT)
|
16
|
+
end
|
17
|
+
module_function :logger
|
18
|
+
|
19
|
+
end
|
File without changes
|
data/samples/basic.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'squib'
|
3
|
-
|
4
|
-
data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
|
5
|
-
'level' => [1,2,3]}
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
rect x:
|
11
|
-
|
12
|
-
|
13
|
-
text str: data['
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
save format: :png
|
20
|
-
end
|
21
|
-
|
22
|
-
puts "Done!"
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'squib'
|
3
|
+
|
4
|
+
data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
|
5
|
+
'level' => [1,2,3]}
|
6
|
+
|
7
|
+
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
8
|
+
background color: :white
|
9
|
+
rect x: 38, y: 38, width: 750, height: 1050, radius: 38
|
10
|
+
rect x: 75, y: 75, width: 128, height: 128, radius: 25
|
11
|
+
|
12
|
+
text str: data['name'], x: 220, y: 78, font: 'Arial 54'
|
13
|
+
text str: data['level'], x: 75, y: 85, width: 128,
|
14
|
+
font: 'Arial 72', align: :center
|
15
|
+
|
16
|
+
png range: [0,2], file: 'shiny-purse.png', x: 620, y: 75
|
17
|
+
svg range: 1..2, file: 'spanner.svg', x: 620, y: 218
|
18
|
+
|
19
|
+
save prefix: 'basic_', format: :png
|
20
|
+
end
|
data/samples/colors.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
Squib::Deck.new(width: 825, height: 1125, cards: 1) do
|
4
|
+
background color: :white
|
5
|
+
|
6
|
+
y = 0
|
7
|
+
text color: '#f00', str: '3-hex', x: 50, y: y+=50
|
8
|
+
text color: '#f00', str: '3-hex (alpha)', x: 50, y: y+=50
|
9
|
+
text color: '#ff0000', str: '6-hex', x: 50, y: y+=50
|
10
|
+
text color: '#ff000099', str: '8-hex(alpha) *', x: 50, y: y+=50
|
11
|
+
text color: '#ffff00000000', str: '12-hex', x: 50, y: y+=50
|
12
|
+
text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y+=50
|
13
|
+
text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y+=50
|
14
|
+
text color: [1.0, 0.0, 0.0], str: 'Array of percentages', x: 50, y: y+=50
|
15
|
+
|
16
|
+
save_png prefix: "colors_"
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
dpi: 300
|
@@ -0,0 +1,34 @@
|
|
1
|
+
frame:
|
2
|
+
x: 38
|
3
|
+
y: 38
|
4
|
+
width: 750
|
5
|
+
height: 1050
|
6
|
+
radius: 25
|
7
|
+
title:
|
8
|
+
x: 125
|
9
|
+
y: 50
|
10
|
+
width: 625
|
11
|
+
height: 100
|
12
|
+
align: !ruby/symbol center #see http://www.yaml.org/YAML_for_ruby.html#symbols
|
13
|
+
valign: !ruby/symbol middle
|
14
|
+
subtitle:
|
15
|
+
x: 150
|
16
|
+
y: 150
|
17
|
+
width: 575
|
18
|
+
height: 60
|
19
|
+
align: !ruby/symbol center
|
20
|
+
valign: !ruby/symbol middle
|
21
|
+
icon:
|
22
|
+
width: 125
|
23
|
+
height: 125
|
24
|
+
y: 250
|
25
|
+
icon_left:
|
26
|
+
extends: icon
|
27
|
+
x: 150
|
28
|
+
icon_middle:
|
29
|
+
extends: icon
|
30
|
+
x: 350
|
31
|
+
y: 400 #overrides the y inherited from icon
|
32
|
+
icon_right:
|
33
|
+
extends: icon
|
34
|
+
x: 550
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
Squib::Deck.new do
|
4
|
+
rect x: 300, y: 300, width: 400, height: 400,
|
5
|
+
fill_color: :blue, stroke_color: :red, stroke_width: 50.0
|
6
|
+
|
7
|
+
circle x: 600, y: 600, radius: 75,
|
8
|
+
fill_color: :gray, stroke_color: :green, stroke_width: 8.0
|
9
|
+
|
10
|
+
triangle x1: 50, y1: 50,
|
11
|
+
x2: 150, y2: 150,
|
12
|
+
x3: 75, y3: 250
|
13
|
+
|
14
|
+
line x1: 50, y1: 550,
|
15
|
+
x2: 150, y2: 650,
|
16
|
+
stroke_width: 25.0
|
17
|
+
|
18
|
+
save_png prefix: 'shape_'
|
19
|
+
end
|