squib 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
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,67 +1,67 @@
1
- require 'cairo'
2
- require 'squib/input_helpers'
3
- require 'squib/graphics/cairo_context_wrapper'
4
-
5
- module Squib
6
- # Back end graphics. Private.
7
- class Card
8
-
9
- # :nodoc:
10
- # @api private
11
- attr_reader :width, :height, :backend, :svgfile
12
-
13
- # :nodoc:
14
- # @api private
15
- attr_accessor :cairo_surface, :cairo_context
16
-
17
- # :nodoc:
18
- # @api private
19
- def initialize(deck, width, height, index=-1)
20
- @deck = deck
21
- @width = width
22
- @height = height
23
- @backend = deck.backend
24
- @svgfile = "#{deck.dir}/#{deck.prefix}#{deck.count_format % index}.svg"
25
- @cairo_surface = make_surface(@svgfile, @backend)
26
- @cairo_context = Squib::Graphics::CairoContextWrapper.new(Cairo::Context.new(@cairo_surface))
27
- @cairo_context.antialias = deck.antialias
28
- end
29
-
30
- # :nodoc:
31
- # @api private
32
- def make_surface(svgfile, backend)
33
- case backend.downcase.to_sym
34
- when :memory
35
- Cairo::ImageSurface.new(@width, @height)
36
- when :svg
37
- Dir.mkdir @deck.dir unless Dir.exists?(@deck.dir)
38
- Cairo::SVGSurface.new(svgfile, @width, @height)
39
- else
40
- Squib.logger.fatal "Back end not recognized: '#{backend}'"
41
- abort
42
- end
43
- end
44
-
45
-
46
- # A save/restore wrapper for using Cairo
47
- # :nodoc:
48
- # @api private
49
- def use_cairo(&block)
50
- @cairo_context.save
51
- block.yield(@cairo_context)
52
- @cairo_context.restore
53
- end
54
-
55
- ########################
56
- ### BACKEND GRAPHICS ###
57
- ########################
58
- require 'squib/graphics/background'
59
- require 'squib/graphics/image'
60
- require 'squib/graphics/save_doc'
61
- require 'squib/graphics/save_images'
62
- require 'squib/graphics/shapes'
63
- require 'squib/graphics/showcase'
64
- require 'squib/graphics/text'
65
-
66
- end
67
- end
1
+ require 'cairo'
2
+ require 'squib/graphics/cairo_context_wrapper'
3
+
4
+ module Squib
5
+ # Back end graphics. Private.
6
+ class Card
7
+
8
+ # :nodoc:
9
+ # @api private
10
+ attr_reader :width, :height, :backend, :svgfile, :index
11
+
12
+ # :nodoc:
13
+ # @api private
14
+ attr_accessor :cairo_surface, :cairo_context
15
+
16
+ # :nodoc:
17
+ # @api private
18
+ def initialize(deck, width, height, index=-1)
19
+ @deck = deck
20
+ @width = width
21
+ @height = height
22
+ @backend = deck.backend
23
+ @index = index
24
+ @svgfile = "#{deck.dir}/#{deck.prefix}#{deck.count_format % index}.svg"
25
+ @cairo_surface = make_surface(@svgfile, @backend)
26
+ @cairo_context = Squib::Graphics::CairoContextWrapper.new(Cairo::Context.new(@cairo_surface))
27
+ @cairo_context.antialias = deck.antialias
28
+ end
29
+
30
+ # :nodoc:
31
+ # @api private
32
+ def make_surface(svgfile, backend)
33
+ case backend.downcase.to_sym
34
+ when :memory
35
+ Cairo::ImageSurface.new(@width, @height)
36
+ when :svg
37
+ Dir.mkdir @deck.dir unless Dir.exists?(@deck.dir)
38
+ Cairo::SVGSurface.new(svgfile, @width, @height)
39
+ else
40
+ Squib.logger.fatal "Back end not recognized: '#{backend}'"
41
+ abort
42
+ end
43
+ end
44
+
45
+
46
+ # A save/restore wrapper for using Cairo
47
+ # :nodoc:
48
+ # @api private
49
+ def use_cairo(&block)
50
+ @cairo_context.save
51
+ block.yield(@cairo_context)
52
+ @cairo_context.restore
53
+ end
54
+
55
+ ########################
56
+ ### BACKEND GRAPHICS ###
57
+ ########################
58
+ require 'squib/graphics/background'
59
+ require 'squib/graphics/image'
60
+ require 'squib/graphics/save_doc'
61
+ require 'squib/graphics/save_images'
62
+ require 'squib/graphics/shapes'
63
+ require 'squib/graphics/showcase'
64
+ require 'squib/graphics/text'
65
+
66
+ end
67
+ end
@@ -1,111 +1,117 @@
1
- require 'squib'
2
- require 'forwardable'
3
- require 'squib/args/typographer'
4
-
5
- module Squib
6
- # @api private
7
- class Conf
8
-
9
- DEFAULTS = {
10
- 'antialias' => 'best',
11
- 'backend' => 'memory',
12
- 'count_format' => SYSTEM_DEFAULTS[:count_format],
13
- 'custom_colors' => {},
14
- 'dir' => SYSTEM_DEFAULTS[:dir],
15
- 'hint' => :none,
16
- 'img_dir' => '.',
17
- 'progress_bars' => false,
18
- 'ldquote' => "\u201C", # UTF8 chars
19
- 'rdquote' => "\u201D",
20
- 'lsquote' => "\u2018",
21
- 'rsquote' => "\u2019",
22
- 'em_dash' => "\u2014",
23
- 'en_dash' => "\u2013",
24
- 'ellipsis' => "\u2026",
25
- 'smart_quotes' => true,
26
- 'text_hint' => 'off',
27
- }
28
-
29
- #Translate the hints to the methods.
30
- ANTIALIAS_OPTS = {
31
- nil => 'subpixel',
32
- 'best' => 'subpixel',
33
- 'good' => 'gray',
34
- 'fast' => 'gray',
35
- 'gray' => 'gray',
36
- 'subpixel' => 'subpixel'
37
- }
38
-
39
- def initialize(config_hash = DEFAULTS)
40
- @config_hash = config_hash
41
- @typographer = Args::Typographer.new(config_hash)
42
- normalize_antialias
43
- end
44
-
45
- # Load the configuration file, if exists, overriding hardcoded defaults
46
- # @api private
47
- def self.load(file)
48
- yaml = {}
49
- if File.exists? file
50
- Squib::logger.info { " using config: #{file}" }
51
- yaml = YAML.load_file(file) || {}
52
- end
53
- Conf.new(DEFAULTS.merge(yaml))
54
- end
55
-
56
- def to_s
57
- "Conf: #{@config_hash.to_s}"
58
- end
59
-
60
- def img_dir
61
- @config_hash['img_dir']
62
- end
63
-
64
- def text_hint
65
- @config_hash['text_hint']
66
- end
67
-
68
- def text_hint=(hint)
69
- @config_hash['text_hint'] = hint
70
- end
71
-
72
- def progress_bars
73
- @config_hash['progress_bars']
74
- end
75
-
76
- def typographer
77
- @typographer
78
- end
79
-
80
- def dir
81
- @config_hash['dir']
82
- end
83
-
84
- def prefix
85
- @config_hash['prefix']
86
- end
87
-
88
- def count_format
89
- @config_hash['count_format']
90
- end
91
-
92
- def antialias
93
- @config_hash['antialias']
94
- end
95
-
96
- def backend
97
- @config_hash['backend']
98
- end
99
-
100
- def custom_colors
101
- @config_hash['custom_colors']
102
- end
103
-
104
- private
105
-
106
- def normalize_antialias
107
- @config_hash['antialias'] = ANTIALIAS_OPTS[@config_hash['antialias'].downcase.strip]
108
- end
109
-
110
- end
111
- end
1
+ require 'forwardable'
2
+ require 'squib'
3
+ require 'squib/args/typographer'
4
+ require 'yaml'
5
+
6
+ module Squib
7
+ # @api private
8
+ class Conf
9
+
10
+ DEFAULTS = {
11
+ 'antialias' => 'best',
12
+ 'backend' => 'memory',
13
+ 'count_format' => SYSTEM_DEFAULTS[:count_format],
14
+ 'custom_colors' => {},
15
+ 'dir' => SYSTEM_DEFAULTS[:dir],
16
+ 'hint' => :none,
17
+ 'img_dir' => '.',
18
+ 'progress_bars' => false,
19
+ 'ldquote' => "\u201C", # UTF8 chars
20
+ 'rdquote' => "\u201D",
21
+ 'lsquote' => "\u2018",
22
+ 'rsquote' => "\u2019",
23
+ 'em_dash' => "\u2014",
24
+ 'en_dash' => "\u2013",
25
+ 'ellipsis' => "\u2026",
26
+ 'smart_quotes' => true,
27
+ 'text_hint' => 'off',
28
+ 'warn_ellipsize'=> true,
29
+ }
30
+
31
+ #Translate the hints to the methods.
32
+ ANTIALIAS_OPTS = {
33
+ nil => 'subpixel',
34
+ 'best' => 'subpixel',
35
+ 'good' => 'gray',
36
+ 'fast' => 'gray',
37
+ 'gray' => 'gray',
38
+ 'subpixel' => 'subpixel'
39
+ }
40
+
41
+ def initialize(config_hash = DEFAULTS)
42
+ @config_hash = config_hash
43
+ @typographer = Args::Typographer.new(config_hash)
44
+ normalize_antialias
45
+ end
46
+
47
+ # Load the configuration file, if exists, overriding hardcoded defaults
48
+ # @api private
49
+ def self.load(file)
50
+ yaml = {}
51
+ if File.exists? file
52
+ Squib::logger.info { " using config: #{file}" }
53
+ yaml = YAML.load_file(file) || {}
54
+ end
55
+ Conf.new(DEFAULTS.merge(yaml))
56
+ end
57
+
58
+ def to_s
59
+ "Conf: #{@config_hash.to_s}"
60
+ end
61
+
62
+ def img_dir
63
+ @config_hash['img_dir']
64
+ end
65
+
66
+ def text_hint
67
+ @config_hash['text_hint']
68
+ end
69
+
70
+ def text_hint=(hint)
71
+ @config_hash['text_hint'] = hint
72
+ end
73
+
74
+ def progress_bars
75
+ @config_hash['progress_bars']
76
+ end
77
+
78
+ def typographer
79
+ @typographer
80
+ end
81
+
82
+ def dir
83
+ @config_hash['dir']
84
+ end
85
+
86
+ def prefix
87
+ @config_hash['prefix']
88
+ end
89
+
90
+ def count_format
91
+ @config_hash['count_format']
92
+ end
93
+
94
+ def antialias
95
+ @config_hash['antialias']
96
+ end
97
+
98
+ def backend
99
+ @config_hash['backend']
100
+ end
101
+
102
+ def custom_colors
103
+ @config_hash['custom_colors']
104
+ end
105
+
106
+ def warn_ellipsize?
107
+ @config_hash['warn_ellipsize']
108
+ end
109
+
110
+ private
111
+
112
+ def normalize_antialias
113
+ @config_hash['antialias'] = ANTIALIAS_OPTS[@config_hash['antialias'].downcase.strip]
114
+ end
115
+
116
+ end
117
+ end
@@ -1,178 +1,178 @@
1
- module Squib
2
- # Squib's defaults for when arguments are not specified in the command nor layouts.
3
- #
4
- # @api public
5
- SYSTEM_DEFAULTS = {
6
- :align => :left,
7
- :alpha => 1.0,
8
- :angle => 0,
9
- :angle_range => (Math::PI / -4.0)..(Math::PI / 4),
10
- :blend => :none,
11
- :color => :black,
12
- :columns => 5,
13
- :count_format => '%02d',
14
- :cx1 => 0,
15
- :cx2 => 0,
16
- :cy1 => 0,
17
- :cy2 => 0,
18
- :data => nil,
19
- :default_font => 'Arial 36',
20
- :dir => '_output',
21
- :dx => 0, # delta
22
- :dy => 0, # delta
23
- :ellipsize => :end,
24
- :face => :left,
25
- :fill_color => '#0000',
26
- :force_id => false,
27
- :font => :use_set,
28
- :font_size => nil,
29
- :format => :png,
30
- :gap => 0,
31
- :height => :native,
32
- :hint => :off,
33
- :inner_radius => 50,
34
- :img_dir => '.',
35
- :justify => false,
36
- :key => '*',
37
- :margin => 75,
38
- :markup => false,
39
- :mask => nil,
40
- :n => 5,
41
- :offset => 1.1,
42
- :outer_radius => 100,
43
- :prefix => 'card_',
44
- :progress_bar => false,
45
- :quotes => :dumb,
46
- :reflect_offset => 15,
47
- :reflect_percent => 0.25,
48
- :reflect_strength => 0.2,
49
- :range => :all,
50
- :rotate => false,
51
- :rows => :infinite,
52
- :scale => 0.85,
53
- :sheet => 0,
54
- :spacing => 0,
55
- :str => '',
56
- :stroke_color => :black,
57
- :stroke_width => 2.0,
58
- :trim => 0,
59
- :trim_radius => 38,
60
- :valign => :top,
61
- :width => :native,
62
- :wrap => true,
63
- :x => 0,
64
- :x1 => 100,
65
- :x2 => 150,
66
- :x3 => 100,
67
- :x_radius => 0,
68
- :y => 0,
69
- :y1 => 100,
70
- :y2 => 150,
71
- :y3 => 150,
72
- :y_radius => 0,
73
- }
74
-
75
- # These are parameters that are intended to be "expanded" across
76
- # range if they are singletons.
77
- #
78
- # For example: using a different font for each card, using one `text` command
79
- #
80
- # key: the internal name of the param (e.g. :files)
81
- # value: the user-facing API key (e.g. file: 'abc.png')
82
- #
83
- # @api private
84
- EXPANDING_PARAMS = {
85
- :align => :align,
86
- :alpha => :alpha,
87
- :angle => :angle,
88
- :blend => :blend,
89
- :circle_radius => :radius,
90
- :color => :color,
91
- :cx1 => :cx1,
92
- :cx2 => :cx2,
93
- :cy1 => :cy1,
94
- :cy2 => :cy2,
95
- :dx => :dx,
96
- :dy => :dy,
97
- :ellipsize => :ellipsize,
98
- :files => :file,
99
- :fill_color => :fill_color,
100
- :force_svgid => :force_id,
101
- :font => :font,
102
- :font_size => :font_size,
103
- :height => :height,
104
- :hint => :hint,
105
- :inner_radius => :inner_radius,
106
- :justify => :justify,
107
- :layout => :layout,
108
- :markup => :markup,
109
- :mask => :mask,
110
- :n => :n,
111
- :outer_radius => :outer_radius,
112
- :quotes => :quotes,
113
- :rect_radius => :radius,
114
- :spacing => :spacing,
115
- :str => :str,
116
- :stroke_color => :stroke_color,
117
- :stroke_width => :stroke_width,
118
- :svgdata => :data,
119
- :svgid => :id,
120
- :valign => :valign,
121
- :width => :width,
122
- :wrap => :wrap,
123
- :x => :x,
124
- :x1 => :x1,
125
- :x2 => :x2,
126
- :x3 => :x3,
127
- :x_radius => :x_radius,
128
- :y => :y,
129
- :y1 => :y1,
130
- :y2 => :y2,
131
- :y3 => :y3,
132
- :y_radius => :y_radius,
133
- }
134
-
135
- # These parameters are considered for unit conversion
136
- #
137
- # For example
138
- # text str: 'Hello, World', x: '1in'
139
- #
140
- # key: the internal name of the param (e.g. :circle_radius)
141
- # value: the user-facing API key (e.g. radius: '1in')
142
- UNIT_CONVERSION_PARAMS = {
143
- :circle_radius => :radius,
144
- :cx1 => :cx1,
145
- :cx2 => :cx2,
146
- :cy1 => :cy1,
147
- :cy2 => :cy2,
148
- :dx => :dx, # delta
149
- :dy => :dx, # delta
150
- :gap => :gap,
151
- :height => :height,
152
- :inner_radius => :inner_radius,
153
- :margin => :margin,
154
- :outer_radius => :outer_radius,
155
- :paper_width => :width,
156
- :paper_height => :height,
157
- :rect_radius => :radius,
158
- :spacing => :spacing,
159
- :stroke_width => :stroke_width,
160
- :trim => :trim,
161
- :width => :width,
162
- :x => :x,
163
- :x1 => :x1,
164
- :x2 => :x2,
165
- :x3 => :x3,
166
- :x_radius => :x_radius,
167
- :y => :y,
168
- :y1 => :y1,
169
- :y2 => :y2,
170
- :y3 => :y3,
171
- :y_radius => :y_radius,
172
- }
173
-
174
- # Used for inch-cm conversion
175
- # :nodoc:
176
- # @api private
177
- INCHES_IN_CM = 0.393700787
178
- end
1
+ module Squib
2
+ # Squib's defaults for when arguments are not specified in the command nor layouts.
3
+ #
4
+ # @api public
5
+ SYSTEM_DEFAULTS = {
6
+ :align => :left,
7
+ :alpha => 1.0,
8
+ :angle => 0,
9
+ :angle_range => (Math::PI / -4.0)..(Math::PI / 4),
10
+ :blend => :none,
11
+ :color => :black,
12
+ :columns => 5,
13
+ :count_format => '%02d',
14
+ :cx1 => 0,
15
+ :cx2 => 0,
16
+ :cy1 => 0,
17
+ :cy2 => 0,
18
+ :data => nil,
19
+ :default_font => 'Arial 36',
20
+ :dir => '_output',
21
+ :dx => 0, # delta
22
+ :dy => 0, # delta
23
+ :ellipsize => :end,
24
+ :face => :left,
25
+ :fill_color => '#0000',
26
+ :force_id => false,
27
+ :font => :use_set,
28
+ :font_size => nil,
29
+ :format => :png,
30
+ :gap => 0,
31
+ :height => :native,
32
+ :hint => :off,
33
+ :inner_radius => 50,
34
+ :img_dir => '.',
35
+ :justify => false,
36
+ :key => '*',
37
+ :margin => 75,
38
+ :markup => false,
39
+ :mask => nil,
40
+ :n => 5,
41
+ :offset => 1.1,
42
+ :outer_radius => 100,
43
+ :prefix => 'card_',
44
+ :progress_bar => false,
45
+ :quotes => :dumb,
46
+ :reflect_offset => 15,
47
+ :reflect_percent => 0.25,
48
+ :reflect_strength => 0.2,
49
+ :range => :all,
50
+ :rotate => false,
51
+ :rows => :infinite,
52
+ :scale => 0.85,
53
+ :sheet => 0,
54
+ :spacing => 0,
55
+ :str => '',
56
+ :stroke_color => :black,
57
+ :stroke_width => 2.0,
58
+ :trim => 0,
59
+ :trim_radius => 38,
60
+ :valign => :top,
61
+ :width => :native,
62
+ :wrap => true,
63
+ :x => 0,
64
+ :x1 => 100,
65
+ :x2 => 150,
66
+ :x3 => 100,
67
+ :x_radius => 0,
68
+ :y => 0,
69
+ :y1 => 100,
70
+ :y2 => 150,
71
+ :y3 => 150,
72
+ :y_radius => 0,
73
+ }
74
+
75
+ # These are parameters that are intended to be "expanded" across
76
+ # range if they are singletons.
77
+ #
78
+ # For example: using a different font for each card, using one `text` command
79
+ #
80
+ # key: the internal name of the param (e.g. :files)
81
+ # value: the user-facing API key (e.g. file: 'abc.png')
82
+ #
83
+ # @api private
84
+ EXPANDING_PARAMS = {
85
+ :align => :align,
86
+ :alpha => :alpha,
87
+ :angle => :angle,
88
+ :blend => :blend,
89
+ :circle_radius => :radius,
90
+ :color => :color,
91
+ :cx1 => :cx1,
92
+ :cx2 => :cx2,
93
+ :cy1 => :cy1,
94
+ :cy2 => :cy2,
95
+ :dx => :dx,
96
+ :dy => :dy,
97
+ :ellipsize => :ellipsize,
98
+ :files => :file,
99
+ :fill_color => :fill_color,
100
+ :force_svgid => :force_id,
101
+ :font => :font,
102
+ :font_size => :font_size,
103
+ :height => :height,
104
+ :hint => :hint,
105
+ :inner_radius => :inner_radius,
106
+ :justify => :justify,
107
+ :layout => :layout,
108
+ :markup => :markup,
109
+ :mask => :mask,
110
+ :n => :n,
111
+ :outer_radius => :outer_radius,
112
+ :quotes => :quotes,
113
+ :rect_radius => :radius,
114
+ :spacing => :spacing,
115
+ :str => :str,
116
+ :stroke_color => :stroke_color,
117
+ :stroke_width => :stroke_width,
118
+ :svgdata => :data,
119
+ :svgid => :id,
120
+ :valign => :valign,
121
+ :width => :width,
122
+ :wrap => :wrap,
123
+ :x => :x,
124
+ :x1 => :x1,
125
+ :x2 => :x2,
126
+ :x3 => :x3,
127
+ :x_radius => :x_radius,
128
+ :y => :y,
129
+ :y1 => :y1,
130
+ :y2 => :y2,
131
+ :y3 => :y3,
132
+ :y_radius => :y_radius,
133
+ }
134
+
135
+ # These parameters are considered for unit conversion
136
+ #
137
+ # For example
138
+ # text str: 'Hello, World', x: '1in'
139
+ #
140
+ # key: the internal name of the param (e.g. :circle_radius)
141
+ # value: the user-facing API key (e.g. radius: '1in')
142
+ UNIT_CONVERSION_PARAMS = {
143
+ :circle_radius => :radius,
144
+ :cx1 => :cx1,
145
+ :cx2 => :cx2,
146
+ :cy1 => :cy1,
147
+ :cy2 => :cy2,
148
+ :dx => :dx, # delta
149
+ :dy => :dx, # delta
150
+ :gap => :gap,
151
+ :height => :height,
152
+ :inner_radius => :inner_radius,
153
+ :margin => :margin,
154
+ :outer_radius => :outer_radius,
155
+ :paper_width => :width,
156
+ :paper_height => :height,
157
+ :rect_radius => :radius,
158
+ :spacing => :spacing,
159
+ :stroke_width => :stroke_width,
160
+ :trim => :trim,
161
+ :width => :width,
162
+ :x => :x,
163
+ :x1 => :x1,
164
+ :x2 => :x2,
165
+ :x3 => :x3,
166
+ :x_radius => :x_radius,
167
+ :y => :y,
168
+ :y1 => :y1,
169
+ :y2 => :y2,
170
+ :y3 => :y3,
171
+ :y_radius => :y_radius,
172
+ }
173
+
174
+ # Used for inch-cm conversion
175
+ # :nodoc:
176
+ # @api private
177
+ INCHES_IN_CM = 0.393700787
178
+ end