usps_flags 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fdff1aa8bd6137e6cf924483f5e56febb4cb5cc
4
- data.tar.gz: 9a497de8ac453be04f0b4ca8620b67048f68a922
3
+ metadata.gz: 2a60a3e26bbd93155f9878c9104c847ed3105eae
4
+ data.tar.gz: c4be9514e8ee71ad53ced1a75c5d09bf17912f62
5
5
  SHA512:
6
- metadata.gz: 8c7cff7cdd70760dae34da50fc1b217a721da2bf02dce238863641303f3c40a5e26601fdcb60e213fff2237ed1b1b9aafcb8db5cbadd88542bda7ab6ef4d3119
7
- data.tar.gz: 4bfa4672d65cbb79f1c1042c205e0af15dd901856aabd1f7067782c47be356894766f73dca6f72258c7d800182cab624a15542c84416a82ca175b1d75241f59b
6
+ metadata.gz: 8f99ce4d839b26ab46949df7099895231f975047cbb4cd24bc26e88f9992b1a1a184e3f3a0459e9e5e1fe0edd0c6ed9042fe417aee6e12d05e9d0172c38f0abe
7
+ data.tar.gz: 8bbb461aa04d65254d5ed582a3117b4dd1c4c3cbe9d45e388ec272cc00d7534ef50c984dcf0343908705995face90f9a15e9c388f1d19b3257b1476ffd4d64e8
checksums.yaml.gz.sig CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps_flags (0.2.6)
4
+ usps_flags (0.3.0)
5
5
  file_utils (~> 1.1, >= 1.1.2)
6
6
  mini_magick (~> 4.8, >= 4.8.0)
7
7
  rubyzip (~> 1.2, >= 1.2.1)
@@ -97,26 +97,26 @@ class USPSFlags::Core::TridentSpec
97
97
  <rect x="#{box_left}" y="#{box_top}" width="#{box_right-box_left}" height="#{USPSFlags::Config::BASE_HOIST/2}" stroke="#666666" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" stroke-dasharray="15, 15" fill="none" />
98
98
 
99
99
  <!-- Right -->
100
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top, box_top+@trident_config[:bar_width], box_right, box_right, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Side spike top gap -->
101
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*2+@trident_config[:point_height]+@trident_config[:side_spike_height], nil, box_right, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Top gap to hash gap -->
102
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*2+@trident_config[:point_height]+@trident_config[:side_spike_height], box_top+@trident_config[:bar_width]*3+@trident_config[:point_height]+@trident_config[:side_spike_height], nil, @trident_config[:center_point]+@trident_config[:hash_width]/2, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Crossbar to hash gap -->
100
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top, box_top+@trident_config[:bar_width], box_right, box_right)} <!-- Side spike top gap -->
101
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*2+@trident_config[:point_height]+@trident_config[:side_spike_height], nil, box_right)} <!-- Top gap to hash gap -->
102
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*2+@trident_config[:point_height]+@trident_config[:side_spike_height], box_top+@trident_config[:bar_width]*3+@trident_config[:point_height]+@trident_config[:side_spike_height], nil, @trident_config[:center_point]+@trident_config[:hash_width]/2)} <!-- Crossbar to hash gap -->
103
103
 
104
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*3+@trident_config[:point_height]+@trident_config[:side_spike_height], box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height], nil, @trident_config[:center_point]+@trident_config[:hash_width]/2, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Hash -->
105
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height], box_bottom, nil, box_right, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Hash to bottom -->
104
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*3+@trident_config[:point_height]+@trident_config[:side_spike_height], box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height], nil, @trident_config[:center_point]+@trident_config[:hash_width]/2)} <!-- Hash -->
105
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height], box_bottom, nil, box_right)} <!-- Hash to bottom -->
106
106
 
107
107
  <!-- Left -->
108
- #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*5.25, box_top, box_bottom, box_left, box_left, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Boundary height -->
109
- #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*0.75, box_top, box_top+@trident_config[:point_height], nil, @trident_config[:center_point]-@trident_config[:bar_width], fly: @fly, unit: @unit, label_offset: -USPSFlags::Config::BASE_FLY/26, label_offset_y: -USPSFlags::Config::BASE_FLY/100, font_size: @label_font_size, label_align: "middle")} <!-- Main point height -->
110
- #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*1.5, box_top+@trident_config[:bar_width], box_top+@trident_config[:bar_width]+@trident_config[:point_height], box_left, box_left+@trident_config[:bar_width], fly: @fly, unit: @unit, label_offset: -USPSFlags::Config::BASE_FLY/24, font_size: @label_font_size, label_align: "middle")} <!-- Side point height -->
108
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*5.25, box_top, box_bottom, box_left, box_left)} <!-- Boundary height -->
109
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*0.75, box_top, box_top+@trident_config[:point_height], nil, @trident_config[:center_point]-@trident_config[:bar_width], label_offset: -USPSFlags::Config::BASE_FLY/26, label_offset_y: -USPSFlags::Config::BASE_FLY/100, label_align: "middle")} <!-- Main point height -->
110
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*1.5, box_top+@trident_config[:bar_width], box_top+@trident_config[:bar_width]+@trident_config[:point_height], box_left, box_left+@trident_config[:bar_width], label_offset: -USPSFlags::Config::BASE_FLY/24, label_align: "middle")} <!-- Side point height -->
111
111
 
112
112
  <!-- Bottom -->
113
- #{USPSFlags::Helpers::SpecArrows.horizontal(box_bottom+@trident_config[:bar_width], @trident_config[:center_point]-@trident_config[:bar_width]/2, @trident_config[:center_point]+@trident_config[:bar_width]/2, box_bottom, box_bottom, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Bar width -->
114
- #{USPSFlags::Helpers::SpecArrows.horizontal(box_bottom+@trident_config[:bar_width]*2.5, @trident_config[:center_point]-@trident_config[:hash_width]/2, @trident_config[:center_point]+@trident_config[:hash_width]/2, box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height], box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height], fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Hash width -->
115
- #{USPSFlags::Helpers::SpecArrows.horizontal(box_bottom+@trident_config[:bar_width]*4, box_left, box_right, box_bottom, box_bottom, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Boundary width -->
113
+ #{USPSFlags::Helpers::SpecArrows.horizontal(box_bottom+@trident_config[:bar_width], @trident_config[:center_point]-@trident_config[:bar_width]/2, @trident_config[:center_point]+@trident_config[:bar_width]/2, box_bottom, box_bottom)} <!-- Bar width -->
114
+ #{USPSFlags::Helpers::SpecArrows.horizontal(box_bottom+@trident_config[:bar_width]*2.5, @trident_config[:center_point]-@trident_config[:hash_width]/2, @trident_config[:center_point]+@trident_config[:hash_width]/2, box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height], box_top+@trident_config[:bar_width]*4+@trident_config[:point_height]+@trident_config[:side_spike_height])} <!-- Hash width -->
115
+ #{USPSFlags::Helpers::SpecArrows.horizontal(box_bottom+@trident_config[:bar_width]*4, box_left, box_right, box_bottom, box_bottom)} <!-- Boundary width -->
116
116
 
117
117
  <!-- Top -->
118
- #{USPSFlags::Helpers::SpecArrows.horizontal(box_top-@trident_config[:bar_width], box_left, box_left+@trident_config[:bar_width]*3/2, box_top, box_top+@trident_config[:bar_width]+@trident_config[:point_height], fly: @fly, unit: @unit, label_offset: -USPSFlags::Config::BASE_FLY/60, font_size: @label_font_size)} <!-- Side point width -->
119
- #{USPSFlags::Helpers::SpecArrows.horizontal(box_top-@trident_config[:bar_width]*2.5, @trident_config[:center_point]-@trident_config[:bar_width], @trident_config[:center_point]+@trident_config[:bar_width], box_top+@trident_config[:point_height], box_top+@trident_config[:point_height], fly: @fly, unit: @unit, label_offset: -USPSFlags::Config::BASE_FLY/60, font_size: @label_font_size)} <!-- Main point width -->
118
+ #{USPSFlags::Helpers::SpecArrows.horizontal(box_top-@trident_config[:bar_width], box_left, box_left+@trident_config[:bar_width]*3/2, box_top, box_top+@trident_config[:bar_width]+@trident_config[:point_height], label_offset: -USPSFlags::Config::BASE_FLY/60)} <!-- Side point width -->
119
+ #{USPSFlags::Helpers::SpecArrows.horizontal(box_top-@trident_config[:bar_width]*2.5, @trident_config[:center_point]-@trident_config[:bar_width], @trident_config[:center_point]+@trident_config[:bar_width], box_top+@trident_config[:point_height], box_top+@trident_config[:point_height], label_offset: -USPSFlags::Config::BASE_FLY/60)} <!-- Main point width -->
120
120
 
121
121
  <!-- Overlay -->
122
122
  <!-- Main point barb -->
@@ -139,12 +139,12 @@ class USPSFlags::Core::TridentSpec
139
139
  <rect x="#{box_left}" y="#{box_top}" width="#{box_right-box_left}" height="#{USPSFlags::Config::BASE_HOIST*5/8}" stroke="#666666" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" stroke-dasharray="15, 15" fill="none" />
140
140
 
141
141
  <!-- Right -->
142
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom]-@trident_config[:bar_width]-@trident_config[:delta_gap_height], box_bottom-@trident_config[:delta_from_bottom]-@trident_config[:bar_width], @trident_config[:center_point], @trident_config[:center_point]+@trident_config[:delta_gap_width], fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Delta gap height -->
143
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom]-@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom], nil, box_right, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Delta width -->
144
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom], box_bottom, nil, box_right, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Delta to bottom -->
142
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom]-@trident_config[:bar_width]-@trident_config[:delta_gap_height], box_bottom-@trident_config[:delta_from_bottom]-@trident_config[:bar_width], @trident_config[:center_point], @trident_config[:center_point]+@trident_config[:delta_gap_width])} <!-- Delta gap height -->
143
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom]-@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom], nil, box_right)} <!-- Delta width -->
144
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_bottom-@trident_config[:delta_from_bottom], box_bottom, nil, box_right)} <!-- Delta to bottom -->
145
145
 
146
146
  <!-- Left -->
147
- #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*1.5, box_top, box_bottom, box_left, box_left, fly: @fly, unit: @unit, label_offset: -USPSFlags::Config::BASE_FLY/30, label_offset_y: -USPSFlags::Config::BASE_FLY*2/11, font_size: @label_font_size, label_align: "middle")} <!-- Boundary height -->
147
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*1.5, box_top, box_bottom, box_left, box_left, label_offset: -USPSFlags::Config::BASE_FLY/30, label_offset_y: -USPSFlags::Config::BASE_FLY*2/11, label_align: "middle")} <!-- Boundary height -->
148
148
  </g></g>
149
149
  SVG
150
150
  end
@@ -160,9 +160,9 @@ class USPSFlags::Core::TridentSpec
160
160
  #{long_trident_boundary_box(box_top, box_left, box_right)}
161
161
 
162
162
  <!-- Right -->
163
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]*2, box_top+@trident_config[:crossbar_from_top]+@trident_config[:width], @trident_config[:center_point], @trident_config[:center_point], fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Inner circle diameter -->
164
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]+@trident_config[:width], nil, @trident_config[:center_point]+@trident_config[:bar_width]/2, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Outer circle diameter -->
165
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]+@trident_config[:width], box_bottom, nil, box_right, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Circle to bottom -->
163
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]*2, box_top+@trident_config[:crossbar_from_top]+@trident_config[:width], @trident_config[:center_point], @trident_config[:center_point])} <!-- Inner circle diameter -->
164
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]+@trident_config[:width], nil, @trident_config[:center_point]+@trident_config[:bar_width]/2)} <!-- Outer circle diameter -->
165
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]+@trident_config[:width], box_bottom, nil, box_right)} <!-- Circle to bottom -->
166
166
 
167
167
  #{long_trident_left_arrow(box_top, box_bottom, box_left, box_right)}
168
168
  </g></g>
@@ -180,7 +180,7 @@ class USPSFlags::Core::TridentSpec
180
180
  #{long_trident_boundary_box(box_top, box_left, box_right)}
181
181
 
182
182
  <!-- Right -->
183
- #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]*3, box_bottom, @trident_config[:center_point]+@trident_config[:hash_width]/2, box_right, fly: @fly, unit: @unit, font_size: @label_font_size)} <!-- Hash to bottom -->
183
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_right+@trident_config[:bar_width], box_top+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]*3, box_bottom, @trident_config[:center_point]+@trident_config[:hash_width]/2, box_right)} <!-- Hash to bottom -->
184
184
 
185
185
  #{long_trident_left_arrow(box_top, box_bottom, box_left, box_right)}
186
186
  </g></g>
@@ -214,7 +214,7 @@ class USPSFlags::Core::TridentSpec
214
214
  def long_trident_left_arrow(box_top, box_bottom, box_left, box_right)
215
215
  <<~SVG
216
216
  <!-- Left -->
217
- #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*1.5, box_top, box_bottom, box_left, box_left, fly: @fly, unit: @unit, label_offset: -USPSFlags::Config::BASE_FLY/30, label_offset_y: -USPSFlags::Config::BASE_FLY/4.5, font_size: @label_font_size, label_align: "middle")} <!-- Boundary height -->
217
+ #{USPSFlags::Helpers::SpecArrows.vertical(box_left-@trident_config[:bar_width]*1.5, box_top, box_bottom, box_left, box_left, label_offset: -USPSFlags::Config::BASE_FLY/30, label_offset_y: -USPSFlags::Config::BASE_FLY/4.5, label_align: "middle")} <!-- Boundary height -->
218
218
  SVG
219
219
  end
220
220
  end
@@ -8,18 +8,19 @@ class USPSFlags::Helpers::SpecArrows
8
8
  #
9
9
  # This is used USPSFlags::Core.trident_spec, and should never need to be called directly.
10
10
  # @private
11
- def vertical(x, top, bottom, pointer_top = nil, pointer_bottom = nil, label: nil, label_offset: (USPSFlags::Config::BASE_FLY/120), label_offset_y: 0, label_align: "left", color: "#CCCCCC", stroke_width: (USPSFlags::Config::BASE_FLY/600), stroke_dash: "10, 10", font_size: (USPSFlags::Config::BASE_FLY/60), arrow_size: (USPSFlags::Config::BASE_FLY/120), fly: USPSFlags::Config::BASE_FLY, unit: nil)
12
- label, label_fraction = get_labels(bottom, top, fly, label: label)
11
+ def vertical(x, top, bottom, pointer_top = nil, pointer_bottom = nil, label: nil, unit: nil, label_offset: (USPSFlags::Config::BASE_FLY/120), label_offset_y: 0, label_align: "left")
12
+ load_common_config
13
+ label, label_fraction = get_labels(bottom, top, label: label)
13
14
  svg = ""
14
15
 
15
- svg << arrow_pointer(x, pointer_top, top, top, color, stroke_width, stroke_dash) unless pointer_top.nil?
16
- svg << arrow_pointer(x, pointer_bottom, bottom, bottom, color, stroke_width, stroke_dash) unless pointer_bottom.nil?
16
+ svg << arrow_pointer(x, pointer_top, top, top) unless pointer_top.nil?
17
+ svg << arrow_pointer(x, pointer_bottom, bottom, bottom) unless pointer_bottom.nil?
17
18
 
18
19
  svg << <<~SVG
19
- <path d="M#{x} #{top} l #{arrow_size} #{arrow_size} M#{x} #{top} l -#{arrow_size} #{arrow_size} M#{x} #{top} l 0 #{bottom - top} l #{arrow_size} -#{arrow_size} M#{x} #{bottom} l -#{arrow_size} -#{arrow_size}" stroke="#{color}" stroke-width="#{stroke_width}" fill="none" />
20
+ <path d="M#{x} #{top} l #{@arrow_size} #{@arrow_size} M#{x} #{top} l -#{@arrow_size} #{@arrow_size} M#{x} #{top} l 0 #{bottom - top} l #{@arrow_size} -#{@arrow_size} M#{x} #{bottom} l -#{@arrow_size} -#{@arrow_size}" stroke="#{@color}" stroke-width="#{@stroke_width}" fill="none" />
20
21
  <g>
21
22
  <style><![CDATA[tspan{font-size: #{USPSFlags::Config::FRACTION_SCALE}%;}]]></style>
22
- <text x="#{x + label_offset}" y="#{(top+bottom)/2+(USPSFlags::Config::BASE_HOIST/150)+label_offset_y}" font-family="sans-serif" font-size="#{font_size}px" fill="#041E42" text-anchor="#{label_align}">#{label} <tspan>#{label_fraction}</tspan> #{unit}</text>
23
+ <text x="#{x + label_offset}" y="#{(top+bottom)/2+(USPSFlags::Config::BASE_HOIST/150)+label_offset_y}" font-family="sans-serif" font-size="#{@font_size}px" fill="#041E42" text-anchor="#{label_align}">#{label} <tspan>#{label_fraction}</tspan> #{unit}</text>
23
24
  </g>
24
25
  SVG
25
26
 
@@ -30,18 +31,19 @@ class USPSFlags::Helpers::SpecArrows
30
31
  #
31
32
  # This is used USPSFlags::Core.trident_spec, and should never need to be called directly.
32
33
  # @private
33
- def horizontal(y, left, right, pointer_left = nil, pointer_right = nil, label: nil, label_offset: (USPSFlags::Config::BASE_FLY/45), label_offset_x: 0, label_align: "middle", color: "#CCCCCC", stroke_width: (USPSFlags::Config::BASE_FLY/600), stroke_dash: "10, 10", font_size: (USPSFlags::Config::BASE_FLY/60), arrow_size: (USPSFlags::Config::BASE_FLY/120), fly: USPSFlags::Config::BASE_FLY, unit: nil)
34
- label, label_fraction = get_labels(right, left, fly, label: label)
34
+ def horizontal(y, left, right, pointer_left = nil, pointer_right = nil, label: nil, unit: nil, label_offset: (USPSFlags::Config::BASE_FLY/45), label_offset_x: 0, label_align: "middle")
35
+ load_common_config
36
+ label, label_fraction = get_labels(right, left, label: label)
35
37
  svg = ""
36
38
 
37
- svg << arrow_pointer(left, left, pointer_left, y, color, stroke_width, stroke_dash) unless pointer_left.nil?
38
- svg << arrow_pointer(right, right, y, pointer_right, color, stroke_width, stroke_dash) unless pointer_right.nil?
39
+ svg << arrow_pointer(left, left, pointer_left, y) unless pointer_left.nil?
40
+ svg << arrow_pointer(right, right, y, pointer_right) unless pointer_right.nil?
39
41
 
40
42
  svg << <<~SVG
41
- <path d="M#{left} #{y} l #{arrow_size} #{arrow_size} M#{left} #{y} l #{arrow_size} -#{arrow_size} M#{left} #{y} l #{right - left} 0 l -#{arrow_size} -#{arrow_size} M#{right} #{y} l -#{arrow_size} #{arrow_size}" stroke="#{color}" stroke-width="#{stroke_width}" fill="none" />
43
+ <path d="M#{left} #{y} l #{@arrow_size} #{@arrow_size} M#{left} #{y} l #{@arrow_size} -#{@arrow_size} M#{left} #{y} l #{right - left} 0 l -#{@arrow_size} -#{@arrow_size} M#{right} #{y} l -#{@arrow_size} #{@arrow_size}" stroke="#{@color}" stroke-width="#{@stroke_width}" fill="none" />
42
44
  <g>
43
45
  <style><![CDATA[tspan{font-size: #{USPSFlags::Config::FRACTION_SCALE}%;}]]></style>
44
- <text x="#{(left+right)/2+label_offset_x}" y="#{y + label_offset}" font-family="sans-serif" font-size="#{font_size}px" fill="#041E42" text-anchor="#{label_align}">#{label} <tspan>#{label_fraction}</tspan> #{unit}</text>
46
+ <text x="#{(left+right)/2+label_offset_x}" y="#{y + label_offset}" font-family="sans-serif" font-size="#{@font_size}px" fill="#041E42" text-anchor="#{label_align}">#{label} <tspan>#{label_fraction}</tspan> #{unit}</text>
45
47
  </g>
46
48
  SVG
47
49
 
@@ -49,16 +51,25 @@ class USPSFlags::Helpers::SpecArrows
49
51
  end
50
52
 
51
53
  private
52
- def arrow_pointer(x1, x2, y1, y2, color, stroke_width, stroke_dash)
54
+ def load_common_config
55
+ @color = "#CCCCCC"
56
+ @stroke_width = (USPSFlags::Config::BASE_FLY/600)
57
+ @stroke_dash = "10, 10"
58
+ @font_size = (USPSFlags::Config::BASE_FLY/60)
59
+ @arrow_size = (USPSFlags::Config::BASE_FLY/120)
60
+ @fly = USPSFlags::Config::BASE_FLY
61
+ end
62
+
63
+ def arrow_pointer(x1, x2, y1, y2)
53
64
  <<~SVG
54
- <line x1="#{x1}" y1="#{y1}" x2="#{x2}" y2="#{y2}" stroke="#{color}" stroke-width="#{stroke_width}" stroke-dasharray="#{stroke_dash}" />
65
+ <line x1="#{x1}" y1="#{y1}" x2="#{x2}" y2="#{y2}" stroke="#{@color}" stroke-width="#{@stroke_width}" stroke-dasharray="#{@stroke_dash}" />
55
66
  SVG
56
67
  end
57
68
 
58
- def get_labels(a, b, fly, label: nil)
69
+ def get_labels(a, b, label: nil)
59
70
  label = a - b if label.nil?
60
71
  label = label.to_i if label - label.to_i == 0
61
- label = Rational(label) * fly / USPSFlags::Config::BASE_FLY
72
+ label = Rational(label) * @fly / USPSFlags::Config::BASE_FLY
62
73
  if label == label.to_i
63
74
  label = label.to_i
64
75
  label_fraction = ""
data/usps_flags.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'usps_flags'
3
- s.version = '0.3.0'
3
+ s.version = '0.3.1'
4
4
  s.date = '2017-11-06'
5
5
  s.summary = 'Flag generator for United States Power Squadrons'
6
6
  s.description = 'A flag image (PNG, SVG) generator for United States Power Squadrons.'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps_flags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
metadata.gz.sig CHANGED
Binary file