usps_flags 0.4.1 → 0.5.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.
@@ -5,59 +5,75 @@
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
7
  class USPSFlags::Core::Icons::Trident
8
+ require 'usps_flags/core/icons/trident_parts/hashes'
9
+ include USPSFlags::Core::Icons::TridentParts::Hashes
10
+
8
11
  def initialize(type, color: :blue, field_color: nil)
9
12
  valid_types = [:s, :d, :stf, :n]
10
- raise "Error: Invalid trident type. Options are #{valid_types}." unless valid_types.include? type
13
+ raise "Error: Invalid trident type. Options are #{valid_types}." unless valid_types.include?(type)
11
14
 
12
15
  @type = type
13
16
 
14
- load_config
17
+ @trident_config = USPSFlags.configuration.trident
18
+ load_measures
19
+ load_measures_from_top
20
+ load_main_length
15
21
  configure_trident_segments
16
22
  configure_colors(color, field_color)
17
23
  end
18
24
 
19
25
  def svg
20
- svg = ''
26
+ svg = +''
21
27
  svg << '<g mask="url(#delta-mask)">' if @type == :d
22
28
  svg << '<g mask="url(#circle-mask-for-main-spike)">' if @type == :stf
23
-
24
- @trident_segments.each do |segment|
25
- start = segment.keys.first
26
- points = segment.values.first
27
- svg << "<path d=\"M #{start[0]} #{start[1]}\n"
28
- points.each { |x, y| svg << "l #{x} #{y}\n" }
29
- svg << "\" fill=\"#{@color_code}\" />\n"
30
- end
29
+ @trident_segments.each { |seg| svg << add_trident_segment(seg) }
31
30
  svg << '</g>' if [:d, :stf].include?(@type)
32
-
33
- case @type
34
- when :d
35
- svg << delta_hash
36
- when :stf
37
- svg << circle_hash
38
- else
39
- svg << standard_hash
40
- end
31
+ svg << add_hash
41
32
 
42
33
  svg
43
34
  end
44
35
 
45
36
  private
46
37
 
47
- def load_config
48
- @trident_config = USPSFlags.configuration.trident
38
+ def add_trident_segment(segment)
39
+ svg = +''
40
+ start = segment.keys.first
41
+ points = segment.values.first
42
+ svg << "<path d=\"M #{start[0]} #{start[1]}\n"
43
+ points.each { |x, y| svg << "l #{x} #{y}\n" }
44
+ svg << "\" fill=\"#{@color_code}\" />\n"
45
+ svg
46
+ end
47
+
48
+ def add_hash
49
+ return delta_hash if @type == :d
50
+ return circle_hash if @type == :stf
51
+
52
+ standard_hash
53
+ end
54
+
55
+ def load_measures
49
56
  @main_spike_overhang = @trident_config[:bar_width] / 2
50
57
  @side_spike_overhang = @trident_config[:bar_width] / 2
51
58
  @top_point = ((USPSFlags::Config::BASE_HOIST - @trident_config[:height][@type]) / 2)
59
+ end
60
+
61
+ def load_measures_from_top
52
62
  @crossbar_top = @top_point + @trident_config[:crossbar_from_top]
53
63
  @hash_from_top = @trident_config[:crossbar_from_top] + (@trident_config[:bar_width] * 2)
54
64
  @circle_from_top = @trident_config[:crossbar_from_top] + @trident_config[:bar_width] * 123 / 128 + @trident_config[:width] / 2
65
+ end
66
+
67
+ def load_main_length
55
68
  @main_length = @trident_config[:height][@type] - (@trident_config[:center_point_height] - @trident_config[:main_point_barb])
56
69
  end
57
70
 
58
71
  def configure_trident_segments
59
72
  @trident_segments = [main_spike, crossbar, left_spike, right_spike]
60
- @lower_hash = lower_hash
73
+ @lower_hash = [
74
+ [@trident_config[:hash_width], 0], [0, @trident_config[:bar_width]],
75
+ [-@trident_config[:hash_width], 0], [0, -@trident_config[:bar_width]]
76
+ ]
61
77
  end
62
78
 
63
79
  def main_spike
@@ -66,9 +82,7 @@ private
66
82
  [
67
83
  [@trident_config[:bar_width], @trident_config[:center_point_height]],
68
84
  [-@main_spike_overhang, -@trident_config[:main_point_barb]],
69
- [0, @main_length],
70
- [-(@trident_config[:bar_width]), 0],
71
- [0, -@main_length],
85
+ [0, @main_length], [-(@trident_config[:bar_width]), 0], [0, -@main_length],
72
86
  [-@main_spike_overhang, @trident_config[:main_point_barb]],
73
87
  [@trident_config[:bar_width], -@trident_config[:center_point_height]]
74
88
  ]
@@ -79,10 +93,8 @@ private
79
93
  {
80
94
  [(@trident_config[:center_point] - @trident_config[:width] / 2), (@crossbar_top)] =>
81
95
  [
82
- [@trident_config[:width], 0],
83
- [0, @trident_config[:bar_width]],
84
- [-@trident_config[:width], 0],
85
- [0, -@trident_config[:bar_width]]
96
+ [@trident_config[:width], 0], [0, @trident_config[:bar_width]],
97
+ [-@trident_config[:width], 0], [0, -@trident_config[:bar_width]]
86
98
  ]
87
99
  }
88
100
  end
@@ -93,8 +105,7 @@ private
93
105
  [
94
106
  [0, -(@trident_config[:side_spike_height] + @trident_config[:side_point_height])],
95
107
  [(@trident_config[:bar_width] + @side_spike_overhang), @trident_config[:side_point_height]],
96
- [-@side_spike_overhang, 0],
97
- [0, @trident_config[:side_spike_height]]
108
+ [-@side_spike_overhang, 0], [0, @trident_config[:side_spike_height]]
98
109
  ]
99
110
  }
100
111
  end
@@ -105,79 +116,21 @@ private
105
116
  [
106
117
  [0, -(@trident_config[:side_spike_height] + @trident_config[:side_point_height])],
107
118
  [-(@trident_config[:bar_width] + @side_spike_overhang), @trident_config[:side_point_height]],
108
- [@side_spike_overhang, 0],
109
- [0, @trident_config[:side_spike_height]]
119
+ [@side_spike_overhang, 0], [0, @trident_config[:side_spike_height]]
110
120
  ]
111
121
  }
112
122
  end
113
123
 
114
- def lower_hash
115
- [
116
- [@trident_config[:hash_width], 0],
117
- [0, @trident_config[:bar_width]],
118
- [-@trident_config[:hash_width], 0],
119
- [0, -@trident_config[:bar_width]]
120
- ]
121
- end
122
-
123
124
  def configure_colors(color, field_color)
124
125
  @color_code = '#FFFFFF'
125
126
  if color == :red
126
- @color_code = USPSFlags::Config::RED
127
- @field_color_code = '#FFFFFF'
127
+ @color_code, @field_color_code = [USPSFlags::Config::RED, '#FFFFFF']
128
128
  elsif color == :blue
129
- @color_code = USPSFlags::Config::BLUE
130
- @field_color_code = '#FFFFFF'
129
+ @color_code, @field_color_code = [USPSFlags::Config::BLUE, '#FFFFFF']
131
130
  elsif field_color == :red
132
131
  @field_color_code = USPSFlags::Config::RED
133
132
  elsif field_color == :blue
134
133
  @field_color_code = USPSFlags::Config::BLUE
135
134
  end
136
135
  end
137
-
138
- def delta_hash
139
- <<~SVG
140
- <polyline mask="url(#delta-mask)" fill="#{@color_code}" points="
141
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}
142
- #{@trident_config[:center_point] + @trident_config[:width] / 2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
143
- #{@trident_config[:center_point] - @trident_config[:width] / 2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
144
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}" />
145
- <mask id="delta-mask">
146
- <g>
147
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
148
- <polyline transform="scale(#{@trident_config[:delta_gap_scale]}) translate(#{@trident_config[:delta_gap_x]},#{@trident_config[:delta_gap_y]})" fill="#000000" points="
149
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}
150
- #{@trident_config[:center_point] + @trident_config[:width] / 2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] * 17 / 20}
151
- #{@trident_config[:center_point] - @trident_config[:width] / 2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] * 17 / 20}
152
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}" />
153
- </g>
154
- </mask>
155
- SVG
156
- end
157
-
158
- def circle_hash
159
- <<~SVG
160
- <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2}" fill="#{@color_code}" mask="url(#circle-mask)" />
161
- <mask id="circle-mask">
162
- <g>
163
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
164
- <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2 - @trident_config[:bar_width]}" fill="#000000" />
165
- </g>
166
- </mask>
167
- <mask id="circle-mask-for-main-spike">
168
- <g transform="scale(1.05) translate(-@trident_config[:br_width], -@trident_config[:br_width]/2)">
169
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
170
- <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2 - @trident_config[:bar_width]}" fill="#000000" />
171
- </g>
172
- </mask>
173
- SVG
174
- end
175
-
176
- def standard_hash
177
- svg = "<path d=\"M #{(@trident_config[:center_point] - @trident_config[:hash_width] / 2)} #{(@top_point + @hash_from_top)}\n"
178
- @lower_hash.each { |x, y| svg << "l #{x} #{y}\n" }
179
- svg << "\" fill=\"#{@color_code}\" />\n"
180
-
181
- svg
182
- end
183
136
  end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: false
2
+
3
+ # Trident hash configurations.
4
+ #
5
+ # These methods should never need to be called directly.
6
+ # @private
7
+ module USPSFlags::Core::Icons::TridentParts
8
+ module Hashes
9
+ def delta_hash
10
+ <<~SVG
11
+ <polyline mask="url(#delta-mask)" fill="#{@color_code}" points="#{delta_mask_points(@trident_config[:center_point], @trident_config[:height][:d], @trident_config[:delta_from_bottom])}" />
12
+ <mask id="delta-mask">
13
+ <g>
14
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
15
+ <polyline transform="scale(#{@trident_config[:delta_gap_scale]}) translate(#{@trident_config[:delta_gap_x]},#{@trident_config[:delta_gap_y]})" fill="#000000" points="#{delta_points(@trident_config[:center_point], @trident_config[:height][:d], @trident_config[:delta_from_bottom])}" />
16
+ </g>
17
+ </mask>
18
+ SVG
19
+ end
20
+
21
+ def delta_mask_points(center, height, bottom)
22
+ top = @top_point + height - bottom
23
+ <<~SVG
24
+ #{center}, #{top - @trident_config[:delta_height]}
25
+ #{center + @trident_config[:width] / 2}, #{top}
26
+ #{center - @trident_config[:width] / 2}, #{top}
27
+ #{center}, #{top - @trident_config[:delta_height]}
28
+ SVG
29
+ end
30
+
31
+ def delta_points(center, height, bottom)
32
+ top = @top_point + height - bottom - @trident_config[:delta_height]
33
+ mid = @top_point + height - bottom * 17 / 20
34
+ <<~SVG
35
+ #{center}, #{top}
36
+ #{center + @trident_config[:width] / 2}, #{mid}
37
+ #{center - @trident_config[:width] / 2}, #{mid}
38
+ #{center}, #{top}
39
+ SVG
40
+ end
41
+
42
+ def circle_hash
43
+ center = @trident_config[:center_point]
44
+ <<~SVG
45
+ <circle cx="#{center}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2}" fill="#{@color_code}" mask="url(#circle-mask)" />
46
+ <mask id="circle-mask">
47
+ <g>
48
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
49
+ <circle cx="#{center}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2 - @trident_config[:bar_width]}" fill="#000000" />
50
+ </g>
51
+ </mask>
52
+ <mask id="circle-mask-for-main-spike">
53
+ <g transform="scale(1.05) translate(-@trident_config[:br_width], -@trident_config[:br_width]/2)">
54
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
55
+ <circle cx="#{center}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2 - @trident_config[:bar_width]}" fill="#000000" />
56
+ </g>
57
+ </mask>
58
+ SVG
59
+ end
60
+
61
+ def standard_hash
62
+ svg = "<path d=\"M #{(@trident_config[:center_point] - @trident_config[:hash_width] / 2)} #{(@top_point + @hash_from_top)}\n"
63
+ @lower_hash.each { |x, y| svg << "l #{x} #{y}\n" }
64
+ svg << "\" fill=\"#{@color_code}\" />\n"
65
+
66
+ svg
67
+ end
68
+ end
69
+ end
@@ -11,7 +11,20 @@ class USPSFlags::Core::Icons::Trumpet
11
11
  end
12
12
 
13
13
  def svg
14
- trumpet = <<~SVG
14
+ if @count == 2
15
+ <<~SVG
16
+ <g transform="translate(1100,-600)"><g transform="rotate(45)">#{trumpet}</g></g>
17
+ <g transform="translate(-300,1100)"><g transform="rotate(-45)">#{trumpet}</g></g>
18
+ SVG
19
+ else
20
+ trumpet
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def trumpet
27
+ <<~SVG
15
28
  <path d="M1139.9999958974363,480.00000000000006
16
29
  c-44.15476410256406,-6.5910035897434796,-116.84910635897381,-20.41065056410247,-114.87185282051291,-47.179479230769175
17
30
  c4.028547230769618,-65.74318056410249,367.85434817948703,-61.23149248717954,369.23087128205134,-2.051282051282101
@@ -22,14 +35,5 @@ class USPSFlags::Core::Icons::Trumpet
22
35
  c106.18124384615362,-96.7690410256414,99.88082358974339,-91.1716969230772,229.74356769230792,-141.53843102564088"
23
36
  fill="#{@color}" />
24
37
  SVG
25
-
26
- if @count == 2
27
- <<~SVG
28
- <g transform="translate(1100,-600)"><g transform="rotate(45)">#{trumpet}</g></g>
29
- <g transform="translate(-300,1100)"><g transform="rotate(-45)">#{trumpet}</g></g>
30
- SVG
31
- else
32
- trumpet
33
- end
34
38
  end
35
39
  end
@@ -12,16 +12,8 @@ class USPSFlags::Core::Pennant
12
12
  end
13
13
 
14
14
  def svg
15
- if @type == 'OIC'
16
- oic
17
- elsif @type == 'CRUISE'
18
- <<~SVG
19
- #{cruise}
20
- <g transform=\"translate(385, 340)\">
21
- #{USPSFlags::Core.star}
22
- </g>"
23
- SVG
24
- end
15
+ return oic if @type == 'OIC'
16
+ return cruise if @type == 'CRUISE'
25
17
  end
26
18
 
27
19
  private
@@ -34,24 +26,29 @@ private
34
26
 
35
27
  def cruise
36
28
  <<~SVG
37
- <path d="M 0 0
38
- l #{@fly * 10 / 36} #{@hoist * 5 / 36}
39
- l 0 #{@hoist * 26 / 36}
40
- l -#{@fly * 10 / 36} #{@hoist * 5 / 36}
41
- " fill="#{USPSFlags::Config::RED}" />
42
- <path d="M #{@fly * 10 / 36} #{@hoist * 5 / 36}
43
- l #{@fly * 11 / 36} #{@hoist * 5.5 / 36}
44
- l 0 #{@hoist * 15 / 36}
45
- l -#{@fly * 11 / 36} #{@hoist * 5.5 / 36}
46
- " fill="#FFFFFF" />
47
- <path d="M #{@fly * 21 / 36} #{@hoist * 10.5 / 36}
48
- l #{@fly * 15 / 36} #{@hoist * 7.5 / 36}
49
- l -#{@fly * 15 / 36} #{@hoist * 7.5 / 36}
50
- " fill="#{USPSFlags::Config::BLUE}" />
51
- <path d="M 0 0
52
- l #{@fly} #{@hoist / 2}
53
- l -#{@fly} #{@hoist / 2}
54
- " fill="none" stroke="#000000" stroke-width="2" />
29
+ #{cruise_red}#{cruise_white}#{cruise_blue}
30
+ <path d="M 0 0 l #{@fly} #{@hoist / 2} l -#{@fly} #{@hoist / 2}" fill="none" stroke="#000000" stroke-width="2" />
31
+ <g transform=\"translate(385, 340)\">
32
+ #{USPSFlags::Core.star}
33
+ </g>"
34
+ SVG
35
+ end
36
+
37
+ def cruise_red
38
+ <<~SVG
39
+ <path d="M 0 0 l #{@fly * 10 / 36} #{@hoist * 5 / 36} l 0 #{@hoist * 26 / 36} l -#{@fly * 10 / 36} #{@hoist * 5 / 36}" fill="#{USPSFlags::Config::RED}" />
40
+ SVG
41
+ end
42
+
43
+ def cruise_white
44
+ <<~SVG
45
+ <path d="M #{@fly * 10 / 36} #{@hoist * 5 / 36} l #{@fly * 11 / 36} #{@hoist * 5.5 / 36} l 0 #{@hoist * 15 / 36} l -#{@fly * 11 / 36} #{@hoist * 5.5 / 36}" fill="#FFFFFF" />
46
+ SVG
47
+ end
48
+
49
+ def cruise_blue
50
+ <<~SVG
51
+ <path d="M #{@fly * 21 / 36} #{@hoist * 10.5 / 36} l #{@fly * 15 / 36} #{@hoist * 7.5 / 36} l -#{@fly * 15 / 36} #{@hoist * 7.5 / 36}" fill="#{USPSFlags::Config::BLUE}" />
55
52
  SVG
56
53
  end
57
54
  end
@@ -22,13 +22,13 @@ private
22
22
 
23
23
  def inner_diameter
24
24
  <<~SVG
25
- #{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] * 2, @box_top + @config[:crossbar_from_top] + @config[:width], @config[:center_point], @config[:center_point], fly: @fly, unit: @unit)} <!-- Inner circle diameter -->
25
+ #{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] * 2, @box_top + @config[:crossbar_from_top] + @config[:width], pointer_top: @config[:center_point], pointer_bottom: @config[:center_point], fly: @fly, unit: @unit)} <!-- Inner circle diameter -->
26
26
  SVG
27
27
  end
28
28
 
29
29
  def outer_diameter
30
30
  <<~SVG
31
- #{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] + @config[:width], nil, outer_box_right, fly: @fly, unit: @unit)} <!-- Outer circle diameter -->
31
+ #{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] + @config[:width], pointer_bottom: outer_box_right, fly: @fly, unit: @unit)} <!-- Outer circle diameter -->
32
32
  SVG
33
33
  end
34
34
 
@@ -38,7 +38,7 @@ private
38
38
 
39
39
  def circle_to_bottom
40
40
  <<~SVG
41
- #{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] + @config[:width], @box_bottom, nil, @box_right, fly: @fly, unit: @unit)} <!-- Circle to bottom -->
41
+ #{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] + @config[:width], @box_bottom, pointer_bottom: @box_right, fly: @fly, unit: @unit)} <!-- Circle to bottom -->
42
42
  SVG
43
43
  end
44
44
  end
@@ -22,13 +22,13 @@ private
22
22
  <<~SVG
23
23
  <!-- Right -->
24
24
  #{gap_height} <!-- Delta gap height -->
25
- #{SA.vertical(@box_right + @config[:bar_width], @box_bottom - @config[:delta_from_bottom] - @config[:bar_width], @box_bottom - @config[:delta_from_bottom], nil, @box_right, fly: @fly, unit: @unit)} <!-- Delta width -->
26
- #{SA.vertical(@box_right + @config[:bar_width], @box_bottom - @config[:delta_from_bottom], @box_bottom, nil, @box_right, fly: @fly, unit: @unit)} <!-- Delta to bottom -->
25
+ #{SA.vertical(@box_right + @config[:bar_width], @box_bottom - @config[:delta_from_bottom] - @config[:bar_width], @box_bottom - @config[:delta_from_bottom], pointer_bottom: @box_right, fly: @fly, unit: @unit)} <!-- Delta width -->
26
+ #{SA.vertical(@box_right + @config[:bar_width], @box_bottom - @config[:delta_from_bottom], @box_bottom, pointer_bottom: @box_right, fly: @fly, unit: @unit)} <!-- Delta to bottom -->
27
27
  SVG
28
28
  end
29
29
 
30
30
  def gap_height
31
- SA.vertical(@box_right + @config[:bar_width], gap_height_top, @box_bottom - @config[:delta_from_bottom] - @config[:bar_width], @config[:center_point], @config[:center_point] + @config[:delta_gap_width], fly: @fly, unit: @unit)
31
+ SA.vertical(@box_right + @config[:bar_width], gap_height_top, @box_bottom - @config[:delta_from_bottom] - @config[:bar_width], pointer_top: @config[:center_point], pointer_bottom: @config[:center_point] + @config[:delta_gap_width], fly: @fly, unit: @unit)
32
32
  end
33
33
 
34
34
  def gap_height_top
@@ -38,7 +38,7 @@ private
38
38
  def left
39
39
  <<~SVG
40
40
  <!-- Left -->
41
- #{SA.vertical(@box_left - @config[:bar_width] * 1.5, @box_top, @box_bottom, @box_left, @box_left, label_offset: -BF / 30, label_offset_y: -BF * 2 / 11, label_align: "middle", fly: @fly, unit: @unit)} <!-- Boundary height -->
41
+ #{SA.vertical(@box_left - @config[:bar_width] * 1.5, @box_top, @box_bottom, pointer_top: @box_left, pointer_bottom: @box_left, label_offset: -BF / 30, label_offset_y: -BF * 2 / 11, label_align: "middle", fly: @fly, unit: @unit)} <!-- Boundary height -->
42
42
  SVG
43
43
  end
44
44
  end
@@ -28,11 +28,11 @@ private
28
28
  def left
29
29
  <<~SVG
30
30
  <!-- Left -->
31
- #{SA.vertical(@box_left - @config[:bar_width] * 1.5, @box_top, @box_bottom, @box_left, @box_left, label_offset: -BF / 30, label_offset_y: -BF / 4.5, label_align: "middle", fly: @fly, unit: @unit)} <!-- Boundary height -->
31
+ #{SA.vertical(@box_left - @config[:bar_width] * 1.5, @box_top, @box_bottom, pointer_top: @box_left, pointer_bottom: @box_left, label_offset: -BF / 30, label_offset_y: -BF / 4.5, label_align: "middle", fly: @fly, unit: @unit)} <!-- Boundary height -->
32
32
  SVG
33
33
  end
34
34
 
35
35
  def hash_to_bottom
36
- SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] * 3, @box_bottom, @config[:center_point] + @config[:hash_width] / 2, @box_right, fly: @fly, unit: @unit)
36
+ SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] * 3, @box_bottom, pointer_top: @config[:center_point] + @config[:hash_width] / 2, pointer_bottom: @box_right, fly: @fly, unit: @unit)
37
37
  end
38
38
  end
@@ -30,7 +30,7 @@ private
30
30
  def right
31
31
  <<~SVG
32
32
  <!-- Right -->
33
- #{SA.vertical(@box_right + @config[:bar_width], @box_top, @box_top + @config[:bar_width] * 4 / 5, @box_right, @box_right, fly: @fly, unit: @unit)} <!-- Side spike top gap -->
33
+ #{SA.vertical(@box_right + @config[:bar_width], @box_top, @box_top + @config[:bar_width] * 4 / 5, pointer_top: @box_right, pointer_bottom: @box_right, fly: @fly, unit: @unit)} <!-- Side spike top gap -->
34
34
  #{right_top_gap_to_hash_gap} <!-- Top gap to hash gap -->
35
35
  #{right_crossbar_to_hash_gap} <!-- Crossbar to hash gap -->
36
36
 
@@ -40,7 +40,7 @@ private
40
40
  end
41
41
 
42
42
  def right_top_gap_to_hash_gap
43
- SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:bar_width] * 4 / 5, right_top_gap_bottom, nil, @box_right, fly: @fly, unit: @unit)
43
+ SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:bar_width] * 4 / 5, right_top_gap_bottom, pointer_bottom: @box_right, fly: @fly, unit: @unit)
44
44
  end
45
45
 
46
46
  def right_top_gap_bottom
@@ -48,7 +48,7 @@ private
48
48
  end
49
49
 
50
50
  def right_crossbar_to_hash_gap
51
- SA.vertical(@box_right + @config[:bar_width], right_crossbar_top, right_crossbar_bottom, nil, @config[:center_point] + @config[:hash_width] / 2, fly: @fly, unit: @unit)
51
+ SA.vertical(@box_right + @config[:bar_width], right_crossbar_top, right_crossbar_bottom, pointer_bottom: @config[:center_point] + @config[:hash_width] / 2, fly: @fly, unit: @unit)
52
52
  end
53
53
 
54
54
  def right_crossbar_top
@@ -60,7 +60,7 @@ private
60
60
  end
61
61
 
62
62
  def right_hash
63
- SA.vertical(@box_right + @config[:bar_width], right_hash_top, right_hash_bottom, nil, @config[:center_point] + @config[:hash_width] / 2, fly: @fly, unit: @unit)
63
+ SA.vertical(@box_right + @config[:bar_width], right_hash_top, right_hash_bottom, pointer_bottom: @config[:center_point] + @config[:hash_width] / 2, fly: @fly, unit: @unit)
64
64
  end
65
65
 
66
66
  def right_hash_top
@@ -72,24 +72,24 @@ private
72
72
  end
73
73
 
74
74
  def right_hash_to_bottom
75
- SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:bar_width] * 38 / 10 + @config[:side_point_height] + @config[:side_spike_height], @box_bottom, nil, @box_right, fly: @fly, unit: @unit)
75
+ SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:bar_width] * 38 / 10 + @config[:side_point_height] + @config[:side_spike_height], @box_bottom, pointer_bottom: @box_right, fly: @fly, unit: @unit)
76
76
  end
77
77
 
78
78
  def left
79
79
  <<~SVG
80
80
  <!-- Left -->
81
- #{SA.vertical(@box_left - @config[:bar_width] * 5.25, @box_top, @box_bottom, @box_left, @box_left, fly: @fly, unit: @unit)} <!-- Boundary height -->
81
+ #{SA.vertical(@box_left - @config[:bar_width] * 5.25, @box_top, @box_bottom, pointer_top: @box_left, pointer_top: @box_left, fly: @fly, unit: @unit)} <!-- Boundary height -->
82
82
  #{left_main_point_height} <!-- Main point height -->
83
83
  #{left_side_point_height} <!-- Side point height -->
84
84
  SVG
85
85
  end
86
86
 
87
87
  def left_main_point_height
88
- SA.vertical(@box_left - @config[:bar_width] * 0.75, @box_top, @box_top + @config[:center_point_height], nil, @config[:center_point] - @config[:bar_width], label_offset: -BF / 24, label_offset_y: -BF / 60, label_align: 'middle', fly: @fly, unit: @unit)
88
+ SA.vertical(@box_left - @config[:bar_width] * 0.75, @box_top, @box_top + @config[:center_point_height], pointer_bottom: @config[:center_point] - @config[:bar_width], label_offset: -BF / 24, label_offset_y: -BF / 60, label_align: 'middle', fly: @fly, unit: @unit)
89
89
  end
90
90
 
91
91
  def left_side_point_height
92
- SA.vertical(@box_left - @config[:bar_width] * 1.5, @box_top + @config[:bar_width] * 4 / 5, left_side_point_bottom, @box_left, @box_left + @config[:bar_width], label_offset: -BF / 24, label_align: 'middle', fly: @fly, unit: @unit)
92
+ SA.vertical(@box_left - @config[:bar_width] * 1.5, @box_top + @config[:bar_width] * 4 / 5, left_side_point_bottom, pointer_top: @box_left, pointer_bottom: @box_left + @config[:bar_width], label_offset: -BF / 24, label_align: 'middle', fly: @fly, unit: @unit)
93
93
  end
94
94
 
95
95
  def left_side_point_bottom
@@ -101,16 +101,16 @@ private
101
101
  <!-- Bottom -->
102
102
  #{bottom_bar_width} <!-- Bar width -->
103
103
  #{bottom_hash_width} <!-- Hash width -->
104
- #{SA.horizontal(@box_bottom + @config[:bar_width] * 4, @box_left, @box_right, @box_bottom, @box_bottom, fly: @fly, unit: @unit)} <!-- Boundary width -->
104
+ #{SA.horizontal(@box_bottom + @config[:bar_width] * 4, @box_left, @box_right, pointer_left: @box_bottom, pointer_right: @box_bottom, fly: @fly, unit: @unit)} <!-- Boundary width -->
105
105
  SVG
106
106
  end
107
107
 
108
108
  def bottom_bar_width
109
- SA.horizontal(@box_bottom + @config[:bar_width], @config[:center_point] - @config[:bar_width] / 2, @config[:center_point] + @config[:bar_width] / 2, @box_bottom, @box_bottom, fly: @fly, unit: @unit)
109
+ SA.horizontal(@box_bottom + @config[:bar_width], @config[:center_point] - @config[:bar_width] / 2, @config[:center_point] + @config[:bar_width] / 2, pointer_left: @box_bottom, pointer_right: @box_bottom, fly: @fly, unit: @unit)
110
110
  end
111
111
 
112
112
  def bottom_hash_width
113
- SA.horizontal(@box_bottom + @config[:bar_width] * 2.5, @config[:center_point] - @config[:hash_width] / 2, @config[:center_point] + @config[:hash_width] / 2, bottom_hash_width_pointer_left, bottom_hash_width_pointer_right, fly: @fly, unit: @unit)
113
+ SA.horizontal(@box_bottom + @config[:bar_width] * 2.5, @config[:center_point] - @config[:hash_width] / 2, @config[:center_point] + @config[:hash_width] / 2, pointer_left: bottom_hash_width_pointer_left, pointer_right: bottom_hash_width_pointer_right, fly: @fly, unit: @unit)
114
114
  end
115
115
 
116
116
  def bottom_hash_width_pointer_left
@@ -130,11 +130,11 @@ private
130
130
  end
131
131
 
132
132
  def top_side_point_width
133
- SA.horizontal(@box_top - @config[:bar_width], @box_left, @box_left + @config[:bar_width] * 3 / 2, @box_top, @box_top + @config[:bar_width] * 4 / 5 + @config[:side_point_height], label_offset: -BF / 60, fly: @fly, unit: @unit)
133
+ SA.horizontal(@box_top - @config[:bar_width], @box_left, @box_left + @config[:bar_width] * 3 / 2, pointer_left: @box_top, pointer_right: @box_top + @config[:bar_width] * 4 / 5 + @config[:side_point_height], label_offset: -BF / 60, fly: @fly, unit: @unit)
134
134
  end
135
135
 
136
136
  def top_main_point_width
137
- SA.horizontal(@box_top - @config[:bar_width] * 2.5, top_main_point_top, @config[:center_point] + @config[:bar_width], @box_top + @config[:center_point_height], @box_top + @config[:center_point_height], label_offset: -BF / 60, fly: @fly, unit: @unit)
137
+ SA.horizontal(@box_top - @config[:bar_width] * 2.5, top_main_point_top, @config[:center_point] + @config[:bar_width], pointer_left: @box_top + @config[:center_point_height], pointer_right: @box_top + @config[:center_point_height], label_offset: -BF / 60, fly: @fly, unit: @unit)
138
138
  end
139
139
 
140
140
  def top_main_point_top
@@ -53,7 +53,7 @@ class USPSFlags::Core::Tridents
53
53
  def offset(type, field_color:, field: true)
54
54
  # Swallowtail tridents need to move towards the hoist due to the tails
55
55
  x_distance = USPSFlags::Config::BASE_FLY / 10 if field
56
- svg = ''
56
+ svg = +''
57
57
  svg << "<g transform=\"translate(-#{x_distance})\">" if field
58
58
  svg << USPSFlags::Core.trident(type, field_color: field_color, color: :red)
59
59
  svg << '</g>' if field
@@ -33,23 +33,21 @@ private
33
33
  end
34
34
 
35
35
  def stars
36
- rows = {
37
- odd: (1..9).step(2).to_a,
38
- even: (2..8).step(2).to_a
39
- }
40
- columns = {
41
- odd: (1..11).step(2).to_a,
42
- even: (2..10).step(2).to_a
43
- }
36
+ rows = { odd: (1..9).step(2).to_a, even: (2..8).step(2).to_a }
37
+ columns = { odd: (1..11).step(2).to_a, even: (2..10).step(2).to_a }
44
38
 
45
- svg = ''
46
- %i[odd even].each do |type|
47
- rows[type].each do |r|
48
- columns[type].each do |c|
49
- svg << <<~SVG
50
- <g transform="translate(#{@canton_fly * c / 12}, #{@star_offset + @canton_hoist * r / 10})"><g><use href="#star" /></g></g>
51
- SVG
52
- end
39
+ svg = +''
40
+ %i[odd even].each { |type| svg << star_set(rows, columns, type) }
41
+ svg
42
+ end
43
+
44
+ def star_set(rows, columns, type)
45
+ svg = +''
46
+ rows[type].each do |r|
47
+ columns[type].each do |c|
48
+ svg << <<~SVG
49
+ <g transform="translate(#{@canton_fly * c / 12}, #{@star_offset + @canton_hoist * r / 10})"><g><use href="#star" /></g></g>
50
+ SVG
53
51
  end
54
52
  end
55
53
  svg