squib 0.6.0 → 0.7.0

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.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +162 -133
  3. data/Gemfile +4 -4
  4. data/README.md +630 -550
  5. data/RELEASE TODO.md +18 -18
  6. data/Rakefile +99 -99
  7. data/lib/squib.rb +32 -32
  8. data/lib/squib/api/background.rb +20 -19
  9. data/lib/squib/api/data.rb +100 -99
  10. data/lib/squib/api/image.rb +90 -76
  11. data/lib/squib/api/save.rb +149 -103
  12. data/lib/squib/api/settings.rb +35 -37
  13. data/lib/squib/api/shapes.rb +230 -228
  14. data/lib/squib/api/text.rb +65 -66
  15. data/lib/squib/api/text_embed.rb +96 -66
  16. data/lib/squib/args/arg_loader.rb +138 -0
  17. data/lib/squib/args/box.rb +55 -0
  18. data/lib/squib/args/card_range.rb +32 -0
  19. data/lib/squib/args/color_validator.rb +12 -0
  20. data/lib/squib/args/coords.rb +33 -0
  21. data/lib/squib/args/dir_validator.rb +16 -0
  22. data/lib/squib/args/draw.rb +92 -0
  23. data/lib/squib/args/embed_adjust.rb +25 -0
  24. data/lib/squib/args/embed_key.rb +17 -0
  25. data/lib/squib/args/hand_special.rb +37 -0
  26. data/lib/squib/args/input_file.rb +37 -0
  27. data/lib/squib/args/paint.rb +44 -0
  28. data/lib/squib/args/paragraph.rb +115 -0
  29. data/lib/squib/args/save_batch.rb +60 -0
  30. data/lib/squib/args/scale_box.rb +53 -0
  31. data/lib/squib/args/sheet.rb +72 -0
  32. data/lib/squib/args/showcase_special.rb +38 -0
  33. data/lib/squib/args/svg_special.rb +37 -0
  34. data/lib/squib/args/transform.rb +25 -0
  35. data/lib/squib/args/typographer.rb +117 -117
  36. data/lib/squib/card.rb +67 -67
  37. data/lib/squib/conf.rb +117 -111
  38. data/lib/squib/constants.rb +178 -178
  39. data/lib/squib/deck.rb +113 -111
  40. data/lib/squib/graphics/cairo_context_wrapper.rb +99 -53
  41. data/lib/squib/graphics/gradient_regex.rb +46 -46
  42. data/lib/squib/graphics/hand.rb +42 -43
  43. data/lib/squib/graphics/image.rb +76 -73
  44. data/lib/squib/graphics/save_doc.rb +103 -137
  45. data/lib/squib/graphics/save_images.rb +33 -33
  46. data/lib/squib/graphics/shapes.rb +119 -152
  47. data/lib/squib/graphics/showcase.rb +85 -88
  48. data/lib/squib/graphics/text.rb +176 -216
  49. data/lib/squib/layout_parser.rb +91 -89
  50. data/lib/squib/layouts/economy.yml +85 -0
  51. data/lib/squib/layouts/fantasy.yml +101 -0
  52. data/lib/squib/layouts/hand.yml +62 -46
  53. data/lib/squib/layouts/playing-card.yml +35 -18
  54. data/lib/squib/project_template/config.yml +45 -40
  55. data/lib/squib/version.rb +10 -10
  56. data/samples/color_shortcuts.rb +6 -0
  57. data/samples/csv_import.rb +18 -18
  58. data/samples/custom-config.yml +5 -5
  59. data/samples/custom_config.rb +18 -18
  60. data/samples/draw_shapes.rb +45 -35
  61. data/samples/embed_text.rb +88 -90
  62. data/samples/hand.rb +24 -24
  63. data/samples/layouts.rb +62 -61
  64. data/samples/layouts_builtin.rb +51 -0
  65. data/samples/load_images.rb +78 -64
  66. data/samples/ranges.rb +64 -53
  67. data/samples/sample.csv +2 -2
  68. data/samples/text_options.rb +102 -94
  69. data/spec/api/api_data_spec.rb +57 -50
  70. data/spec/api/api_settings_spec.rb +37 -17
  71. data/spec/args/box_spec.rb +127 -0
  72. data/spec/args/draw_spec.rb +95 -0
  73. data/spec/args/embed_key_spec.rb +13 -0
  74. data/spec/args/input_file_spec.rb +21 -0
  75. data/spec/args/paint_spec.rb +22 -0
  76. data/spec/args/paragraph_spec.rb +153 -0
  77. data/spec/args/range_spec.rb +36 -0
  78. data/spec/args/save_batch_spec.rb +51 -0
  79. data/spec/args/scale_box_spec.rb +71 -0
  80. data/spec/args/sheet_spec.rb +58 -0
  81. data/spec/args/showcase_special_spec.rb +15 -0
  82. data/spec/data/samples/autoscale_font.rb.txt +84 -87
  83. data/spec/data/samples/basic.rb.txt +209 -203
  84. data/spec/data/samples/cairo_access.rb.txt +2 -2
  85. data/spec/data/samples/config_text_markup.rb.txt +72 -75
  86. data/spec/data/samples/csv_import.rb.txt +76 -80
  87. data/spec/data/samples/custom_config.rb.txt +48 -49
  88. data/spec/data/samples/draw_shapes.rb.txt +100 -42
  89. data/spec/data/samples/embed_text.rb.txt +283 -295
  90. data/spec/data/samples/excel.rb.txt +162 -171
  91. data/spec/data/samples/gradients.rb.txt +79 -67
  92. data/spec/data/samples/hand.rb.txt +538 -514
  93. data/spec/data/samples/hello_world.rb.txt +36 -38
  94. data/spec/data/samples/load_images.rb.txt +41 -5
  95. data/spec/data/samples/portrait-landscape.rb.txt +49 -51
  96. data/spec/data/samples/ranges.rb.txt +460 -429
  97. data/spec/data/samples/saves.rb.txt +801 -785
  98. data/spec/data/samples/showcase.rb.txt +5910 -5906
  99. data/spec/data/samples/text_options.rb.txt +1125 -981
  100. data/spec/data/samples/tgc_proofs.rb.txt +81 -79
  101. data/spec/data/samples/units.rb.txt +18 -12
  102. data/spec/data/xlsx/with_macros.xlsm +0 -0
  103. data/spec/graphics/cairo_context_wrapper_spec.rb +84 -75
  104. data/spec/graphics/graphics_images_spec.rb +94 -85
  105. data/spec/graphics/graphics_save_doc_spec.rb +67 -65
  106. data/spec/samples/expected/hand.png +0 -0
  107. data/spec/samples/expected/hand_pretty.png +0 -0
  108. data/spec/samples/expected/layout_00.png +0 -0
  109. data/spec/samples/expected/load_images_00.png +0 -0
  110. data/spec/samples/expected/ranges_00.png +0 -0
  111. data/spec/samples/expected/shape_00.png +0 -0
  112. data/spec/samples/expected/showcase.png +0 -0
  113. data/spec/samples/expected/showcase2.png +0 -0
  114. data/spec/samples/expected/showcase_individual_00.png +0 -0
  115. data/spec/samples/expected/showcase_individual_01.png +0 -0
  116. data/spec/samples/expected/showcase_individual_02.png +0 -0
  117. data/spec/samples/expected/showcase_individual_03.png +0 -0
  118. data/spec/samples/expected/text_00.png +0 -0
  119. data/spec/samples/expected/text_01.png +0 -0
  120. data/spec/samples/expected/text_02.png +0 -0
  121. data/spec/samples/samples_regression_spec.rb +82 -82
  122. data/spec/spec_helper.rb +3 -2
  123. data/squib.gemspec +48 -48
  124. data/squib.sublime-project +42 -36
  125. metadata +61 -33
  126. data/lib/squib/input_helpers.rb +0 -238
  127. data/spec/api/api_image_spec.rb +0 -38
  128. data/spec/api/api_text_spec.rb +0 -37
  129. data/spec/graphics/graphics_shapes_spec.rb +0 -85
  130. data/spec/graphics/graphics_text_spec.rb +0 -164
  131. data/spec/input_helpers_spec.rb +0 -238
  132. data/spec/samples/expected/embed_multi_00.png +0 -0
  133. data/spec/samples/expected/embed_multi_01.png +0 -0
  134. data/spec/samples/expected/embed_multi_02.png +0 -0
  135. data/spec/samples/expected/ranges_01.png +0 -0
  136. data/spec/samples/expected/ranges_02.png +0 -0
@@ -1,111 +1,113 @@
1
- require 'yaml'
2
- require 'pp'
3
- require 'forwardable'
4
- require 'squib'
5
- require 'squib/card'
6
- require 'squib/progress'
7
- require 'squib/input_helpers'
8
- require 'squib/constants'
9
- require 'squib/layout_parser'
10
- require 'squib/args/unit_conversion'
11
- require 'squib/conf'
12
- require 'squib/graphics/showcase'
13
- require 'squib/graphics/hand'
14
-
15
- # The project module
16
- #
17
- # @api public
18
- module Squib
19
-
20
- # The main interface to Squib. Provides a front-end porcelain whereas the Card class interacts with the graphics plumbing.
21
- #
22
- # @api public
23
- class Deck
24
- include Enumerable
25
- include Squib::InputHelpers
26
- extend Forwardable
27
-
28
- # Attributes for the width, height (in pixels) and number of cards
29
- # These are expected to be immuatble for the life of Deck
30
- # @api private
31
- attr_reader :width, :height, :cards
32
-
33
- # Delegate these configuration options to the Squib::Conf object
34
- def_delegators :conf, :antialias, :backend, :count_format, :custom_colors, :dir,
35
- :img_dir, :prefix, :text_hint, :typographer
36
- # :nodoc:
37
- # @api private
38
- attr_reader :layout, :conf
39
-
40
- # Squib's constructor that sets the immutable properties.
41
- #
42
- # This is the starting point for Squib. In providing a block to the constructor, you have access to all of Deck's instance methods.
43
- # The documented methods in Deck are the ones intended for use by most users.
44
- # 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.
45
- # @example
46
- # require 'squib'
47
- # Squib::Deck.new do
48
- # text str: 'Hello, World!"
49
- # end
50
- #
51
- # @param width [Integer] the width of each card in pixels. Supports unit conversion (e.g. '2.5in').
52
- # @param height [Integer] the height of each card in pixels. Supports unit conversion (e.g. '3.5in').
53
- # @param cards [Integer] the number of cards in the deck
54
- # @param dpi [Integer] the pixels per inch when rendering out to PDF or calculating using inches.
55
- # @param config [String] the file used for global settings of this deck
56
- # @param layout [String, Array] load a YML file of custom layouts. Multiple files are merged sequentially, redefining collisons. See README and sample for details.
57
- # @param block [Block] the main body of the script.
58
- # @api public
59
- def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block)
60
- @dpi = dpi
61
- @font = SYSTEM_DEFAULTS[:default_font]
62
- @cards = []
63
- @conf = Conf.load(config)
64
- @progress_bar = Progress.new(@conf.progress_bars) # FIXME this is evil. Using something different with @ and non-@
65
- show_info(config, layout)
66
- @width = Args::UnitConversion.parse width, dpi
67
- @height = Args::UnitConversion.parse height, dpi
68
- cards.times{ |i| @cards << Squib::Card.new(self, @width, @height, i) }
69
- @layout = LayoutParser.load_layout(layout)
70
- if block_given?
71
- instance_eval(&block) # here we go. wheeeee!
72
- end
73
- end
74
-
75
- # Directly accesses the array of cards in the deck
76
- #
77
- # @api private
78
- def [](key)
79
- @cards[key]
80
- end
81
-
82
- # Iterates over each card in the deck
83
- #
84
- # @api private
85
- def each(&block)
86
- @cards.each { |card| block.call(card) }
87
- end
88
-
89
- # Use Logger to show more detail on the run
90
- # :nodoc:
91
- # @api private
92
- def show_info(config, layout)
93
- Squib::logger.info "Squib v#{Squib::VERSION}"
94
- Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
95
- Squib::logger.info " using #{@backend}"
96
- end
97
-
98
- ##################
99
- ### PUBLIC API ###
100
- ##################
101
- require 'squib/api/background'
102
- require 'squib/api/data'
103
- require 'squib/api/image'
104
- require 'squib/api/save'
105
- require 'squib/api/settings'
106
- require 'squib/api/shapes'
107
- require 'squib/api/text'
108
- require 'squib/api/units'
109
-
110
- end
111
- end
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
- # :nodoc:
30
- # @api private
31
- def set_source_squibcolor(arg)
32
- if match = arg.match(LINEAR_GRADIENT)
33
- x1, y1, x2, y2 = match.captures
34
- linear = Cairo::LinearPattern.new(x1.to_f, y1.to_f, x2.to_f, y2.to_f)
35
- arg.scan(STOPS).each do |color, offset|
36
- linear.add_color_stop(offset.to_f, color)
37
- end
38
- @cairo_cxt.set_source(linear)
39
- elsif match = arg.match(RADIAL_GRADIENT)
40
- x1, y1, r1, x2, y2, r2 = match.captures
41
- linear = Cairo::RadialPattern.new(x1.to_f, y1.to_f, r1.to_f,
42
- x2.to_f, y2.to_f, r2.to_f)
43
- arg.scan(STOPS).each do |color, offset|
44
- linear.add_color_stop(offset.to_f, color)
45
- end
46
- @cairo_cxt.set_source(linear)
47
- else
48
- @cairo_cxt.set_source_color(arg)
49
- end
50
- end
51
- end
52
- end
53
- end
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