squib 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +162 -133
- data/Gemfile +4 -4
- data/README.md +630 -550
- data/RELEASE TODO.md +18 -18
- data/Rakefile +99 -99
- data/lib/squib.rb +32 -32
- data/lib/squib/api/background.rb +20 -19
- data/lib/squib/api/data.rb +100 -99
- data/lib/squib/api/image.rb +90 -76
- data/lib/squib/api/save.rb +149 -103
- data/lib/squib/api/settings.rb +35 -37
- data/lib/squib/api/shapes.rb +230 -228
- data/lib/squib/api/text.rb +65 -66
- data/lib/squib/api/text_embed.rb +96 -66
- data/lib/squib/args/arg_loader.rb +138 -0
- data/lib/squib/args/box.rb +55 -0
- data/lib/squib/args/card_range.rb +32 -0
- data/lib/squib/args/color_validator.rb +12 -0
- data/lib/squib/args/coords.rb +33 -0
- data/lib/squib/args/dir_validator.rb +16 -0
- data/lib/squib/args/draw.rb +92 -0
- data/lib/squib/args/embed_adjust.rb +25 -0
- data/lib/squib/args/embed_key.rb +17 -0
- data/lib/squib/args/hand_special.rb +37 -0
- data/lib/squib/args/input_file.rb +37 -0
- data/lib/squib/args/paint.rb +44 -0
- data/lib/squib/args/paragraph.rb +115 -0
- data/lib/squib/args/save_batch.rb +60 -0
- data/lib/squib/args/scale_box.rb +53 -0
- data/lib/squib/args/sheet.rb +72 -0
- data/lib/squib/args/showcase_special.rb +38 -0
- data/lib/squib/args/svg_special.rb +37 -0
- data/lib/squib/args/transform.rb +25 -0
- data/lib/squib/args/typographer.rb +117 -117
- data/lib/squib/card.rb +67 -67
- data/lib/squib/conf.rb +117 -111
- data/lib/squib/constants.rb +178 -178
- data/lib/squib/deck.rb +113 -111
- data/lib/squib/graphics/cairo_context_wrapper.rb +99 -53
- data/lib/squib/graphics/gradient_regex.rb +46 -46
- data/lib/squib/graphics/hand.rb +42 -43
- data/lib/squib/graphics/image.rb +76 -73
- data/lib/squib/graphics/save_doc.rb +103 -137
- data/lib/squib/graphics/save_images.rb +33 -33
- data/lib/squib/graphics/shapes.rb +119 -152
- data/lib/squib/graphics/showcase.rb +85 -88
- data/lib/squib/graphics/text.rb +176 -216
- data/lib/squib/layout_parser.rb +91 -89
- data/lib/squib/layouts/economy.yml +85 -0
- data/lib/squib/layouts/fantasy.yml +101 -0
- data/lib/squib/layouts/hand.yml +62 -46
- data/lib/squib/layouts/playing-card.yml +35 -18
- data/lib/squib/project_template/config.yml +45 -40
- data/lib/squib/version.rb +10 -10
- data/samples/color_shortcuts.rb +6 -0
- data/samples/csv_import.rb +18 -18
- data/samples/custom-config.yml +5 -5
- data/samples/custom_config.rb +18 -18
- data/samples/draw_shapes.rb +45 -35
- data/samples/embed_text.rb +88 -90
- data/samples/hand.rb +24 -24
- data/samples/layouts.rb +62 -61
- data/samples/layouts_builtin.rb +51 -0
- data/samples/load_images.rb +78 -64
- data/samples/ranges.rb +64 -53
- data/samples/sample.csv +2 -2
- data/samples/text_options.rb +102 -94
- data/spec/api/api_data_spec.rb +57 -50
- data/spec/api/api_settings_spec.rb +37 -17
- data/spec/args/box_spec.rb +127 -0
- data/spec/args/draw_spec.rb +95 -0
- data/spec/args/embed_key_spec.rb +13 -0
- data/spec/args/input_file_spec.rb +21 -0
- data/spec/args/paint_spec.rb +22 -0
- data/spec/args/paragraph_spec.rb +153 -0
- data/spec/args/range_spec.rb +36 -0
- data/spec/args/save_batch_spec.rb +51 -0
- data/spec/args/scale_box_spec.rb +71 -0
- data/spec/args/sheet_spec.rb +58 -0
- data/spec/args/showcase_special_spec.rb +15 -0
- data/spec/data/samples/autoscale_font.rb.txt +84 -87
- data/spec/data/samples/basic.rb.txt +209 -203
- data/spec/data/samples/cairo_access.rb.txt +2 -2
- data/spec/data/samples/config_text_markup.rb.txt +72 -75
- data/spec/data/samples/csv_import.rb.txt +76 -80
- data/spec/data/samples/custom_config.rb.txt +48 -49
- data/spec/data/samples/draw_shapes.rb.txt +100 -42
- data/spec/data/samples/embed_text.rb.txt +283 -295
- data/spec/data/samples/excel.rb.txt +162 -171
- data/spec/data/samples/gradients.rb.txt +79 -67
- data/spec/data/samples/hand.rb.txt +538 -514
- data/spec/data/samples/hello_world.rb.txt +36 -38
- data/spec/data/samples/load_images.rb.txt +41 -5
- data/spec/data/samples/portrait-landscape.rb.txt +49 -51
- data/spec/data/samples/ranges.rb.txt +460 -429
- data/spec/data/samples/saves.rb.txt +801 -785
- data/spec/data/samples/showcase.rb.txt +5910 -5906
- data/spec/data/samples/text_options.rb.txt +1125 -981
- data/spec/data/samples/tgc_proofs.rb.txt +81 -79
- data/spec/data/samples/units.rb.txt +18 -12
- data/spec/data/xlsx/with_macros.xlsm +0 -0
- data/spec/graphics/cairo_context_wrapper_spec.rb +84 -75
- data/spec/graphics/graphics_images_spec.rb +94 -85
- data/spec/graphics/graphics_save_doc_spec.rb +67 -65
- data/spec/samples/expected/hand.png +0 -0
- data/spec/samples/expected/hand_pretty.png +0 -0
- data/spec/samples/expected/layout_00.png +0 -0
- data/spec/samples/expected/load_images_00.png +0 -0
- data/spec/samples/expected/ranges_00.png +0 -0
- data/spec/samples/expected/shape_00.png +0 -0
- data/spec/samples/expected/showcase.png +0 -0
- data/spec/samples/expected/showcase2.png +0 -0
- data/spec/samples/expected/showcase_individual_00.png +0 -0
- data/spec/samples/expected/showcase_individual_01.png +0 -0
- data/spec/samples/expected/showcase_individual_02.png +0 -0
- data/spec/samples/expected/showcase_individual_03.png +0 -0
- data/spec/samples/expected/text_00.png +0 -0
- data/spec/samples/expected/text_01.png +0 -0
- data/spec/samples/expected/text_02.png +0 -0
- data/spec/samples/samples_regression_spec.rb +82 -82
- data/spec/spec_helper.rb +3 -2
- data/squib.gemspec +48 -48
- data/squib.sublime-project +42 -36
- metadata +61 -33
- data/lib/squib/input_helpers.rb +0 -238
- data/spec/api/api_image_spec.rb +0 -38
- data/spec/api/api_text_spec.rb +0 -37
- data/spec/graphics/graphics_shapes_spec.rb +0 -85
- data/spec/graphics/graphics_text_spec.rb +0 -164
- data/spec/input_helpers_spec.rb +0 -238
- data/spec/samples/expected/embed_multi_00.png +0 -0
- data/spec/samples/expected/embed_multi_01.png +0 -0
- data/spec/samples/expected/embed_multi_02.png +0 -0
- data/spec/samples/expected/ranges_01.png +0 -0
- data/spec/samples/expected/ranges_02.png +0 -0
data/lib/squib/deck.rb
CHANGED
@@ -1,111 +1,113 @@
|
|
1
|
-
require '
|
2
|
-
require 'pp'
|
3
|
-
require '
|
4
|
-
require 'squib'
|
5
|
-
require 'squib/card'
|
6
|
-
require 'squib/
|
7
|
-
require 'squib/
|
8
|
-
require 'squib/
|
9
|
-
require 'squib/
|
10
|
-
require 'squib/
|
11
|
-
require 'squib/
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# @param
|
54
|
-
# @param
|
55
|
-
# @param
|
56
|
-
# @param
|
57
|
-
# @param
|
58
|
-
# @
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@
|
63
|
-
@
|
64
|
-
@
|
65
|
-
|
66
|
-
@
|
67
|
-
|
68
|
-
|
69
|
-
@
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
Squib::logger.info "
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
##################
|
101
|
-
|
102
|
-
|
103
|
-
require 'squib/api/
|
104
|
-
require 'squib/api/
|
105
|
-
require 'squib/api/
|
106
|
-
require 'squib/api/
|
107
|
-
require 'squib/api/
|
108
|
-
require 'squib/api/
|
109
|
-
|
110
|
-
|
111
|
-
|
1
|
+
require 'forwardable'
|
2
|
+
require 'pp'
|
3
|
+
require 'squib'
|
4
|
+
require 'squib/args/unit_conversion'
|
5
|
+
require 'squib/card'
|
6
|
+
require 'squib/conf'
|
7
|
+
require 'squib/constants'
|
8
|
+
require 'squib/graphics/hand'
|
9
|
+
require 'squib/graphics/showcase'
|
10
|
+
require 'squib/layout_parser'
|
11
|
+
require 'squib/progress'
|
12
|
+
|
13
|
+
|
14
|
+
# The project module
|
15
|
+
#
|
16
|
+
# @api public
|
17
|
+
module Squib
|
18
|
+
|
19
|
+
# The main interface to Squib. Provides a front-end porcelain whereas the Card class interacts with the graphics plumbing.
|
20
|
+
#
|
21
|
+
# @api public
|
22
|
+
class Deck
|
23
|
+
include Enumerable
|
24
|
+
extend Forwardable
|
25
|
+
|
26
|
+
# Attributes for the width, height (in pixels) and number of cards
|
27
|
+
# These are expected to be immuatble for the life of Deck
|
28
|
+
# @api private
|
29
|
+
attr_reader :width, :height, :cards
|
30
|
+
|
31
|
+
# Delegate these configuration options to the Squib::Conf object
|
32
|
+
def_delegators :conf, :antialias, :backend, :count_format, :custom_colors, :dir,
|
33
|
+
:img_dir, :prefix, :text_hint, :typographer
|
34
|
+
# :nodoc:
|
35
|
+
# @api private
|
36
|
+
attr_reader :layout, :conf, :dpi, :font
|
37
|
+
|
38
|
+
#
|
39
|
+
# deck.size is really just @cards.size
|
40
|
+
def_delegators :cards, :size
|
41
|
+
|
42
|
+
# Squib's constructor that sets the immutable properties.
|
43
|
+
#
|
44
|
+
# This is the starting point for Squib. In providing a block to the constructor, you have access to all of Deck's instance methods.
|
45
|
+
# The documented methods in Deck are the ones intended for use by most users.
|
46
|
+
# If your game requires multiple different sizes or orientations, I recommend using multiple `Squib::Deck`s in your `deck.rb`. You can modify the internals of `Squib::Deck` (e.g. `@cards`), but that's not recommended.
|
47
|
+
# @example
|
48
|
+
# require 'squib'
|
49
|
+
# Squib::Deck.new do
|
50
|
+
# text str: 'Hello, World!"
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @param width [Integer] the width of each card in pixels. Supports unit conversion (e.g. '2.5in').
|
54
|
+
# @param height [Integer] the height of each card in pixels. Supports unit conversion (e.g. '3.5in').
|
55
|
+
# @param cards [Integer] the number of cards in the deck
|
56
|
+
# @param dpi [Integer] the pixels per inch when rendering out to PDF or calculating using inches.
|
57
|
+
# @param config [String] the file used for global settings of this deck
|
58
|
+
# @param layout [String, Array] load a YML file of custom layouts. Multiple files are merged sequentially, redefining collisons. See README and sample for details.
|
59
|
+
# @param block [Block] the main body of the script.
|
60
|
+
# @api public
|
61
|
+
def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block)
|
62
|
+
@dpi = dpi
|
63
|
+
@font = SYSTEM_DEFAULTS[:default_font]
|
64
|
+
@cards = []
|
65
|
+
@conf = Conf.load(config)
|
66
|
+
@progress_bar = Progress.new(@conf.progress_bars) # FIXME this is evil. Using something different with @ and non-@
|
67
|
+
show_info(config, layout)
|
68
|
+
@width = Args::UnitConversion.parse width, dpi
|
69
|
+
@height = Args::UnitConversion.parse height, dpi
|
70
|
+
cards.times{ |i| @cards << Squib::Card.new(self, @width, @height, i) }
|
71
|
+
@layout = LayoutParser.load_layout(layout)
|
72
|
+
if block_given?
|
73
|
+
instance_eval(&block) # here we go. wheeeee!
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Directly accesses the array of cards in the deck
|
78
|
+
#
|
79
|
+
# @api private
|
80
|
+
def [](key)
|
81
|
+
@cards[key]
|
82
|
+
end
|
83
|
+
|
84
|
+
# Iterates over each card in the deck
|
85
|
+
#
|
86
|
+
# @api private
|
87
|
+
def each(&block)
|
88
|
+
@cards.each { |card| block.call(card) }
|
89
|
+
end
|
90
|
+
|
91
|
+
# Use Logger to show more detail on the run
|
92
|
+
# :nodoc:
|
93
|
+
# @api private
|
94
|
+
def show_info(config, layout)
|
95
|
+
Squib::logger.info "Squib v#{Squib::VERSION}"
|
96
|
+
Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
|
97
|
+
Squib::logger.info " using #{@backend}"
|
98
|
+
end
|
99
|
+
|
100
|
+
##################
|
101
|
+
### PUBLIC API ###
|
102
|
+
##################
|
103
|
+
require 'squib/api/background'
|
104
|
+
require 'squib/api/data'
|
105
|
+
require 'squib/api/image'
|
106
|
+
require 'squib/api/save'
|
107
|
+
require 'squib/api/settings'
|
108
|
+
require 'squib/api/shapes'
|
109
|
+
require 'squib/api/text'
|
110
|
+
require 'squib/api/units'
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -1,53 +1,99 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
require 'squib/graphics/gradient_regex'
|
3
|
-
|
4
|
-
module Squib
|
5
|
-
module Graphics
|
6
|
-
# Wrapper class for the Cairo context. Private.
|
7
|
-
# @api private
|
8
|
-
class CairoContextWrapper
|
9
|
-
extend Forwardable
|
10
|
-
|
11
|
-
# :nodoc:
|
12
|
-
# @api private
|
13
|
-
attr_accessor :cairo_cxt
|
14
|
-
|
15
|
-
# :nodoc:
|
16
|
-
# @api private
|
17
|
-
def initialize(cairo_cxt)
|
18
|
-
@cairo_cxt = cairo_cxt
|
19
|
-
end
|
20
|
-
|
21
|
-
def_delegators :cairo_cxt, :save, :set_source_color, :paint, :restore,
|
22
|
-
:translate, :rotate, :move_to, :update_pango_layout, :width, :height,
|
23
|
-
:show_pango_layout, :rounded_rectangle, :set_line_width, :stroke, :fill,
|
24
|
-
:set_source, :scale, :render_rsvg_handle, :circle, :triangle, :line_to,
|
25
|
-
:operator=, :show_page, :clip, :transform, :mask, :create_pango_layout,
|
26
|
-
:antialias=, :curve_to, :matrix, :matrix=, :identity_matrix, :pango_layout_path,
|
27
|
-
:stroke_preserve, :target, :new_path, :fill_preserve, :close_path
|
28
|
-
|
29
|
-
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@cairo_cxt.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
1
|
+
require 'forwardable'
|
2
|
+
require 'squib/graphics/gradient_regex'
|
3
|
+
|
4
|
+
module Squib
|
5
|
+
module Graphics
|
6
|
+
# Wrapper class for the Cairo context. Private.
|
7
|
+
# @api private
|
8
|
+
class CairoContextWrapper
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
# :nodoc:
|
12
|
+
# @api private
|
13
|
+
attr_accessor :cairo_cxt
|
14
|
+
|
15
|
+
# :nodoc:
|
16
|
+
# @api private
|
17
|
+
def initialize(cairo_cxt)
|
18
|
+
@cairo_cxt = cairo_cxt
|
19
|
+
end
|
20
|
+
|
21
|
+
def_delegators :cairo_cxt, :save, :set_source_color, :paint, :restore,
|
22
|
+
:translate, :rotate, :move_to, :update_pango_layout, :width, :height,
|
23
|
+
:show_pango_layout, :rounded_rectangle, :set_line_width, :stroke, :fill,
|
24
|
+
:set_source, :scale, :render_rsvg_handle, :circle, :triangle, :line_to,
|
25
|
+
:operator=, :show_page, :clip, :transform, :mask, :create_pango_layout,
|
26
|
+
:antialias=, :curve_to, :matrix, :matrix=, :identity_matrix, :pango_layout_path,
|
27
|
+
:stroke_preserve, :target, :new_path, :fill_preserve, :close_path,
|
28
|
+
:set_line_join, :set_line_cap, :set_dash
|
29
|
+
|
30
|
+
# :nodoc:
|
31
|
+
# @api private
|
32
|
+
def set_source_squibcolor(arg)
|
33
|
+
raise 'nil is not a valid color' if arg.nil?
|
34
|
+
if match = arg.match(LINEAR_GRADIENT)
|
35
|
+
x1, y1, x2, y2 = match.captures
|
36
|
+
linear = Cairo::LinearPattern.new(x1.to_f, y1.to_f, x2.to_f, y2.to_f)
|
37
|
+
arg.scan(STOPS).each do |color, offset|
|
38
|
+
linear.add_color_stop(offset.to_f, color)
|
39
|
+
end
|
40
|
+
@cairo_cxt.set_source(linear)
|
41
|
+
elsif match = arg.match(RADIAL_GRADIENT)
|
42
|
+
x1, y1, r1, x2, y2, r2 = match.captures
|
43
|
+
linear = Cairo::RadialPattern.new(x1.to_f, y1.to_f, r1.to_f,
|
44
|
+
x2.to_f, y2.to_f, r2.to_f)
|
45
|
+
arg.scan(STOPS).each do |color, offset|
|
46
|
+
linear.add_color_stop(offset.to_f, color)
|
47
|
+
end
|
48
|
+
@cairo_cxt.set_source(linear)
|
49
|
+
else
|
50
|
+
@cairo_cxt.set_source_color(arg)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Convenience method for a common task
|
55
|
+
# @api private
|
56
|
+
def fill_n_stroke(draw)
|
57
|
+
return stroke_n_fill(draw) if draw.stroke_strategy == :stroke_first
|
58
|
+
set_source_squibcolor draw.fill_color
|
59
|
+
fill_preserve
|
60
|
+
set_source_squibcolor draw.stroke_color
|
61
|
+
set_line_width draw.stroke_width
|
62
|
+
set_line_join draw.join
|
63
|
+
set_line_cap draw.cap
|
64
|
+
set_dash draw.dash
|
65
|
+
stroke
|
66
|
+
end
|
67
|
+
|
68
|
+
def stroke_n_fill(draw)
|
69
|
+
return fill_n_stroke(draw) if draw.stroke_strategy == :fill_first
|
70
|
+
set_source_squibcolor draw.stroke_color
|
71
|
+
set_line_width draw.stroke_width
|
72
|
+
set_line_join draw.join
|
73
|
+
set_line_cap draw.cap
|
74
|
+
set_dash draw.dash
|
75
|
+
stroke_preserve
|
76
|
+
set_source_squibcolor draw.fill_color
|
77
|
+
fill
|
78
|
+
end
|
79
|
+
|
80
|
+
# Convenience method for a common task
|
81
|
+
# @api private
|
82
|
+
def fancy_stroke(draw)
|
83
|
+
set_source_squibcolor draw.stroke_color
|
84
|
+
set_line_width draw.stroke_width
|
85
|
+
set_line_join draw.join
|
86
|
+
set_line_cap draw.cap
|
87
|
+
set_dash draw.dash
|
88
|
+
stroke
|
89
|
+
end
|
90
|
+
|
91
|
+
def rotate_about(x, y, angle)
|
92
|
+
translate(x, y)
|
93
|
+
rotate(angle)
|
94
|
+
translate(-x, -y)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -1,47 +1,47 @@
|
|
1
|
-
module Squib
|
2
|
-
# @api private
|
3
|
-
module Graphics
|
4
|
-
STOPS = / # used to capture the stops
|
5
|
-
\s* # leading whitespace is ok
|
6
|
-
(\#?[\w]+) # color
|
7
|
-
@ # no spaces here
|
8
|
-
(\d+\.?\d*) # offset number
|
9
|
-
/x
|
10
|
-
|
11
|
-
LINEAR_GRADIENT = /
|
12
|
-
\( \s* # coordinate 1
|
13
|
-
(\d+\.?\d*) \s* # x1 number
|
14
|
-
,\s* # whitespace after comma is ok
|
15
|
-
(\d+\.?\d*) \s* # y1 number
|
16
|
-
\)
|
17
|
-
\s* # space between coordinates is ok
|
18
|
-
\( \s* # coordinate 2
|
19
|
-
(\d+\.?\d*) \s* # x2 number
|
20
|
-
,\s* # whitespace after comma is ok
|
21
|
-
(\d+\.?\d*) \s* # y2 number
|
22
|
-
\)
|
23
|
-
(#{STOPS})+ # stops
|
24
|
-
\s* # trailing whitespace is ok
|
25
|
-
/x
|
26
|
-
|
27
|
-
RADIAL_GRADIENT = /
|
28
|
-
\( \s* # coordinate 1
|
29
|
-
(\d+\.?\d*) \s* # x1 number
|
30
|
-
,\s* # whitespace after comma is ok
|
31
|
-
(\d+\.?\d*) \s* # y1 number
|
32
|
-
,\s* # whitespace after comma is ok
|
33
|
-
(\d+\.?\d*) \s* # r1 number
|
34
|
-
\)
|
35
|
-
\s* # space between coordinates is ok
|
36
|
-
\( \s* # coordinate 2
|
37
|
-
(\d+\.?\d*) \s* # x2 number
|
38
|
-
,\s* # whitespace after comma is ok
|
39
|
-
(\d+\.?\d*) \s* # y2 number
|
40
|
-
,\s* # whitespace after comma is ok
|
41
|
-
(\d+\.?\d*) \s* # r2 number
|
42
|
-
\)
|
43
|
-
(#{STOPS})+ # stops
|
44
|
-
\s* # trailing whitespace is ok
|
45
|
-
/x
|
46
|
-
end
|
1
|
+
module Squib
|
2
|
+
# @api private
|
3
|
+
module Graphics
|
4
|
+
STOPS = / # used to capture the stops
|
5
|
+
\s* # leading whitespace is ok
|
6
|
+
(\#?[\w]+) # color
|
7
|
+
@ # no spaces here
|
8
|
+
(\d+\.?\d*) # offset number
|
9
|
+
/x
|
10
|
+
|
11
|
+
LINEAR_GRADIENT = /
|
12
|
+
\( \s* # coordinate 1
|
13
|
+
(\d+\.?\d*) \s* # x1 number
|
14
|
+
,\s* # whitespace after comma is ok
|
15
|
+
(\d+\.?\d*) \s* # y1 number
|
16
|
+
\)
|
17
|
+
\s* # space between coordinates is ok
|
18
|
+
\( \s* # coordinate 2
|
19
|
+
(\d+\.?\d*) \s* # x2 number
|
20
|
+
,\s* # whitespace after comma is ok
|
21
|
+
(\d+\.?\d*) \s* # y2 number
|
22
|
+
\)
|
23
|
+
(#{STOPS})+ # stops
|
24
|
+
\s* # trailing whitespace is ok
|
25
|
+
/x
|
26
|
+
|
27
|
+
RADIAL_GRADIENT = /
|
28
|
+
\( \s* # coordinate 1
|
29
|
+
(\d+\.?\d*) \s* # x1 number
|
30
|
+
,\s* # whitespace after comma is ok
|
31
|
+
(\d+\.?\d*) \s* # y1 number
|
32
|
+
,\s* # whitespace after comma is ok
|
33
|
+
(\d+\.?\d*) \s* # r1 number
|
34
|
+
\)
|
35
|
+
\s* # space between coordinates is ok
|
36
|
+
\( \s* # coordinate 2
|
37
|
+
(\d+\.?\d*) \s* # x2 number
|
38
|
+
,\s* # whitespace after comma is ok
|
39
|
+
(\d+\.?\d*) \s* # y2 number
|
40
|
+
,\s* # whitespace after comma is ok
|
41
|
+
(\d+\.?\d*) \s* # r2 number
|
42
|
+
\)
|
43
|
+
(#{STOPS})+ # stops
|
44
|
+
\s* # trailing whitespace is ok
|
45
|
+
/x
|
46
|
+
end
|
47
47
|
end
|