usps_flags 0.5.0 → 0.5.1

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +22 -11
  3. data/.travis.yml +1 -1
  4. data/Gemfile.lock +5 -2
  5. data/README.md +6 -0
  6. data/lib/usps_flags.rb +35 -44
  7. data/lib/usps_flags/config.rb +89 -87
  8. data/lib/usps_flags/core.rb +44 -42
  9. data/lib/usps_flags/core/ensign.rb +53 -49
  10. data/lib/usps_flags/core/field.rb +96 -92
  11. data/lib/usps_flags/core/footer.rb +9 -5
  12. data/lib/usps_flags/core/headers.rb +58 -48
  13. data/lib/usps_flags/core/icons.rb +11 -7
  14. data/lib/usps_flags/core/icons/anchor.rb +62 -56
  15. data/lib/usps_flags/core/icons/binoculars.rb +21 -15
  16. data/lib/usps_flags/core/icons/lighthouse.rb +28 -22
  17. data/lib/usps_flags/core/icons/star.rb +21 -15
  18. data/lib/usps_flags/core/icons/trident.rb +136 -127
  19. data/lib/usps_flags/core/icons/trident_parts/hashes.rb +62 -55
  20. data/lib/usps_flags/core/icons/trumpet.rb +34 -28
  21. data/lib/usps_flags/core/pennant.rb +50 -46
  22. data/lib/usps_flags/core/trident_spec.rb +135 -131
  23. data/lib/usps_flags/core/trident_specs.rb +11 -7
  24. data/lib/usps_flags/core/trident_specs/base.rb +36 -26
  25. data/lib/usps_flags/core/trident_specs/circle.rb +36 -30
  26. data/lib/usps_flags/core/trident_specs/delta.rb +41 -30
  27. data/lib/usps_flags/core/trident_specs/header.rb +56 -50
  28. data/lib/usps_flags/core/trident_specs/horizontal.rb +80 -0
  29. data/lib/usps_flags/core/trident_specs/long.rb +41 -25
  30. data/lib/usps_flags/core/trident_specs/overlay.rb +40 -0
  31. data/lib/usps_flags/core/trident_specs/short.rb +30 -156
  32. data/lib/usps_flags/core/trident_specs/vertical.rb +108 -0
  33. data/lib/usps_flags/core/tridents.rb +54 -50
  34. data/lib/usps_flags/core/us.rb +40 -44
  35. data/lib/usps_flags/core/wheel.rb +7 -3
  36. data/lib/usps_flags/errors.rb +25 -23
  37. data/lib/usps_flags/generate.rb +111 -107
  38. data/lib/usps_flags/generate/flag.rb +160 -157
  39. data/lib/usps_flags/generate/generator_methods.rb +139 -0
  40. data/lib/usps_flags/generate/helper_methods.rb +88 -0
  41. data/lib/usps_flags/helpers.rb +163 -165
  42. data/lib/usps_flags/helpers/builders.rb +92 -85
  43. data/lib/usps_flags/helpers/spec_arrows.rb +127 -123
  44. data/lib/usps_flags/helpers/valid_flags.rb +45 -41
  45. data/lib/usps_flags/rational.rb +35 -0
  46. data/spec/usps_flags/config_spec.rb +17 -10
  47. data/spec/usps_flags/core_spec.rb +31 -31
  48. data/spec/usps_flags/generate_spec.rb +76 -73
  49. data/spec/usps_flags/helpers_spec.rb +8 -8
  50. data/spec/usps_flags/rational_spec.rb +17 -0
  51. data/spec/usps_flags_spec.rb +19 -21
  52. data/usps_flags.gemspec +7 -6
  53. metadata +34 -10
  54. data/lib/rational.rb +0 -39
  55. data/lib/usps_flags/generate/private.rb +0 -199
  56. data/spec/rational_spec.rb +0 -19
@@ -4,35 +4,51 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::TridentSpecs::Long < USPSFlags::Core::TridentSpecs::Base
8
- def p
9
- output('Long', 40, :n)
10
- end
7
+ class USPSFlags
8
+ class Core
9
+ module TridentSpecs
10
+ class Long < USPSFlags::Core::TridentSpecs::Base
11
+ def p
12
+ output('Long', 40, :n)
13
+ end
11
14
 
12
- private
15
+ private
13
16
 
14
- def boundary_box
15
- <<~SVG
16
- <!-- Boundary box -->
17
- <rect x="#{@box_left}" y="#{@box_top}" width="#{@box_right - @box_left}" height="#{BH * 3 / 4}" stroke="#666666" stroke-width="#{BF / 600}" stroke-dasharray="15, 15" fill="none" />
18
- SVG
19
- end
17
+ def boundary_box
18
+ <<~SVG
19
+ <!-- Boundary box -->
20
+ <rect x="#{@box_left}" y="#{@box_top}" width="#{@box_right - @box_left}" height="#{BH * 3 / 4}" stroke="#666666" stroke-width="#{BF / 600}" stroke-dasharray="15, 15" fill="none" />
21
+ SVG
22
+ end
20
23
 
21
- def right
22
- <<~SVG
23
- <!-- Right -->
24
- #{hash_to_bottom} <!-- Hash to bottom -->
25
- SVG
26
- end
24
+ def right
25
+ <<~SVG
26
+ <!-- Right -->
27
+ #{hash_to_bottom} <!-- Hash to bottom -->
28
+ SVG
29
+ end
27
30
 
28
- def left
29
- <<~SVG
30
- <!-- Left -->
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
- SVG
33
- end
31
+ def left
32
+ arrow = SA.vertical(
33
+ @box_left - @config[:bar_width] * 1.5, @box_top, @box_bottom,
34
+ pointer_top: @box_left, pointer_bottom: @box_left, label_offset: -BF / 30,
35
+ label_offset_y: -BF / 4.5, label_align: 'middle', fly: @fly, unit: @unit
36
+ )
37
+ <<~SVG
38
+ <!-- Left -->
39
+ #{arrow} <!-- Boundary height -->
40
+ SVG
41
+ end
34
42
 
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, pointer_top: @config[:center_point] + @config[:hash_width] / 2, pointer_bottom: @box_right, fly: @fly, unit: @unit)
43
+ def hash_to_bottom
44
+ SA.vertical(
45
+ @box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] * 3,
46
+ @box_bottom,
47
+ pointer_top: @config[:center_point] + @config[:hash_width] / 2, pointer_bottom: @box_right,
48
+ fly: @fly, unit: @unit
49
+ )
50
+ end
51
+ end
52
+ end
37
53
  end
38
54
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: false
2
+
3
+ # Core SVG data for the trident specification sheet.
4
+ #
5
+ # This class should never need to be called directly.
6
+ # @private
7
+ class USPSFlags
8
+ class Core
9
+ module TridentSpecs
10
+ module Overlay
11
+ # This module defined no public methods
12
+ def _; end
13
+
14
+ private
15
+
16
+ def overlay
17
+ <<~SVG
18
+ <!-- Overlay -->
19
+ <!-- Main point barb -->
20
+ #{overlay_lines}
21
+ <text x="#{@config[:center_point] + @config[:bar_width] * 9 / 8}" y="#{@box_top + @config[:center_point_height] - @config[:main_point_barb]}" font-family="sans-serif" font-size="#{Base::BF / 100}px" fill="#041E42" text-anchor="left">#{@barb_label}</text>
22
+ SVG
23
+ end
24
+
25
+ def overlay_lines
26
+ <<~SVG
27
+ #{overlay_line(@box_top + @config[:center_point_height] - @config[:main_point_barb], @box_top + @config[:center_point_height] - @config[:main_point_barb] * 5)}
28
+ #{overlay_line(@box_top + @config[:center_point_height], @box_top + @config[:center_point_height])}
29
+ SVG
30
+ end
31
+
32
+ def overlay_line(y1, y2)
33
+ <<~SVG
34
+ <line x1="#{@config[:center_point] + @config[:bar_width] / 2}" y1="#{y1}" x2="#{@config[:center_point] + @config[:bar_width] * 3 / 2}" y2="#{y2}" stroke="#666666" stroke-width="2" stroke-dasharray="5, 5" />
35
+ SVG
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -4,162 +4,36 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::TridentSpecs::Short < USPSFlags::Core::TridentSpecs::Base
8
- def p
9
- output('Short', 14, :s) do
10
- <<~SVG
11
- #{boundary_box}
12
- #{right}
13
- #{left}
14
- #{bottom}
15
- #{top}
16
- #{overlay}
17
- SVG
7
+ class USPSFlags
8
+ class Core
9
+ module TridentSpecs
10
+ class Short < USPSFlags::Core::TridentSpecs::Base
11
+ include USPSFlags::Core::TridentSpecs::Vertical
12
+ include USPSFlags::Core::TridentSpecs::Horizontal
13
+ include USPSFlags::Core::TridentSpecs::Overlay
14
+
15
+ def p
16
+ output('Short', 14, :s) do
17
+ <<~SVG
18
+ #{boundary_box}
19
+ #{right}
20
+ #{left}
21
+ #{bottom}
22
+ #{top}
23
+ #{overlay}
24
+ SVG
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def boundary_box
31
+ <<~SVG
32
+ <!-- Boundary box -->
33
+ <rect x="#{@box_left}" y="#{@box_top}" width="#{@box_right - @box_left}" height="#{BH / 2}" stroke="#666666" stroke-width="#{BF / 600}" stroke-dasharray="15, 15" fill="none" />
34
+ SVG
35
+ end
36
+ end
18
37
  end
19
38
  end
20
-
21
- private
22
-
23
- def boundary_box
24
- <<~SVG
25
- <!-- Boundary box -->
26
- <rect x="#{@box_left}" y="#{@box_top}" width="#{@box_right - @box_left}" height="#{BH / 2}" stroke="#666666" stroke-width="#{BF / 600}" stroke-dasharray="15, 15" fill="none" />
27
- SVG
28
- end
29
-
30
- def right
31
- <<~SVG
32
- <!-- Right -->
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
- #{right_top_gap_to_hash_gap} <!-- Top gap to hash gap -->
35
- #{right_crossbar_to_hash_gap} <!-- Crossbar to hash gap -->
36
-
37
- #{right_hash} <!-- Hash -->
38
- #{right_hash_to_bottom} <!-- Hash to bottom -->
39
- SVG
40
- end
41
-
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, pointer_bottom: @box_right, fly: @fly, unit: @unit)
44
- end
45
-
46
- def right_top_gap_bottom
47
- @box_top + @config[:bar_width] * 9 / 10 * 2 + @config[:side_point_height] + @config[:side_spike_height]
48
- end
49
-
50
- def right_crossbar_to_hash_gap
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
- end
53
-
54
- def right_crossbar_top
55
- @box_top + @config[:bar_width] * 18 / 10 + @config[:side_point_height] + @config[:side_spike_height]
56
- end
57
-
58
- def right_crossbar_bottom
59
- @box_top + @config[:bar_width] * 28 / 10 + @config[:side_point_height] + @config[:side_spike_height]
60
- end
61
-
62
- def right_hash
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
- end
65
-
66
- def right_hash_top
67
- @box_top + @config[:bar_width] * 28 / 10 + @config[:side_point_height] + @config[:side_spike_height]
68
- end
69
-
70
- def right_hash_bottom
71
- @box_top + @config[:bar_width] * 38 / 10 + @config[:side_point_height] + @config[:side_spike_height]
72
- end
73
-
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, pointer_bottom: @box_right, fly: @fly, unit: @unit)
76
- end
77
-
78
- def left
79
- <<~SVG
80
- <!-- Left -->
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
- #{left_main_point_height} <!-- Main point height -->
83
- #{left_side_point_height} <!-- Side point height -->
84
- SVG
85
- end
86
-
87
- def left_main_point_height
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
- end
90
-
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, pointer_top: @box_left, pointer_bottom: @box_left + @config[:bar_width], label_offset: -BF / 24, label_align: 'middle', fly: @fly, unit: @unit)
93
- end
94
-
95
- def left_side_point_bottom
96
- @box_top + @config[:bar_width] * 4 / 5 + @config[:side_point_height]
97
- end
98
-
99
- def bottom
100
- <<~SVG
101
- <!-- Bottom -->
102
- #{bottom_bar_width} <!-- Bar width -->
103
- #{bottom_hash_width} <!-- Hash 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
- SVG
106
- end
107
-
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, pointer_left: @box_bottom, pointer_right: @box_bottom, fly: @fly, unit: @unit)
110
- end
111
-
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, pointer_left: bottom_hash_width_pointer_left, pointer_right: bottom_hash_width_pointer_right, fly: @fly, unit: @unit)
114
- end
115
-
116
- def bottom_hash_width_pointer_left
117
- @box_top + @config[:bar_width] * 4 + @config[:center_point_height] + @config[:side_spike_height]
118
- end
119
-
120
- def bottom_hash_width_pointer_right
121
- @box_top + @config[:bar_width] * 4 + @config[:center_point_height] + @config[:side_spike_height]
122
- end
123
-
124
- def top
125
- <<~SVG
126
- <!-- Top -->
127
- #{top_side_point_width} <!-- Side point width -->
128
- #{top_main_point_width} <!-- Main point width -->
129
- SVG
130
- end
131
-
132
- def top_side_point_width
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
- end
135
-
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], 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
- end
139
-
140
- def top_main_point_top
141
- @config[:center_point] - @config[:bar_width]
142
- end
143
-
144
- def overlay
145
- <<~SVG
146
- <!-- Overlay -->
147
- <!-- Main point barb -->
148
- #{overlay_lines}
149
- <text x="#{@config[:center_point] + @config[:bar_width] * 9 / 8}" y="#{@box_top + @config[:center_point_height] - @config[:main_point_barb]}" font-family="sans-serif" font-size="#{BF / 100}px" fill="#041E42" text-anchor="left">#{@barb_label}</text>
150
- SVG
151
- end
152
-
153
- def overlay_lines
154
- <<~SVG
155
- #{overlay_line(@box_top + @config[:center_point_height] - @config[:main_point_barb], @box_top + @config[:center_point_height] - @config[:main_point_barb] * 5)}
156
- #{overlay_line(@box_top + @config[:center_point_height], @box_top + @config[:center_point_height])}
157
- SVG
158
- end
159
-
160
- def overlay_line(y1, y2)
161
- <<~SVG
162
- <line x1="#{@config[:center_point] + @config[:bar_width] / 2}" y1="#{y1}" x2="#{@config[:center_point] + @config[:bar_width] * 3 / 2}" y2="#{y2}" stroke="#666666" stroke-width="2" stroke-dasharray="5, 5" />
163
- SVG
164
- end
165
39
  end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: false
2
+
3
+ # Core SVG data for the trident specification sheet.
4
+ #
5
+ # This class should never need to be called directly.
6
+ # @private
7
+ class USPSFlags
8
+ class Core
9
+ module TridentSpecs
10
+ module Vertical
11
+ # This module defined no public methods
12
+ def _; end
13
+
14
+ private
15
+
16
+ def right
17
+ <<~SVG
18
+ <!-- Right -->
19
+ #{Base::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 -->
20
+ #{right_top_gap_to_hash_gap} <!-- Top gap to hash gap -->
21
+ #{right_crossbar_to_hash_gap} <!-- Crossbar to hash gap -->
22
+
23
+ #{right_hash} <!-- Hash -->
24
+ #{right_hash_to_bottom} <!-- Hash to bottom -->
25
+ SVG
26
+ end
27
+
28
+ def right_top_gap_to_hash_gap
29
+ Base::SA.vertical(
30
+ @box_right + @config[:bar_width], @box_top + @config[:bar_width] * 4 / 5, right_top_gap_bottom,
31
+ pointer_bottom: @box_right, fly: @fly, unit: @unit
32
+ )
33
+ end
34
+
35
+ def right_top_gap_bottom
36
+ @box_top + @config[:bar_width] * 9 / 10 * 2 + @config[:side_point_height] + @config[:side_spike_height]
37
+ end
38
+
39
+ def right_crossbar_to_hash_gap
40
+ Base::SA.vertical(
41
+ @box_right + @config[:bar_width], right_crossbar_top, right_crossbar_bottom,
42
+ pointer_bottom: @config[:center_point] + @config[:hash_width] / 2, fly: @fly, unit: @unit
43
+ )
44
+ end
45
+
46
+ def right_crossbar_top
47
+ @box_top + @config[:bar_width] * 18 / 10 + @config[:side_point_height] + @config[:side_spike_height]
48
+ end
49
+
50
+ def right_crossbar_bottom
51
+ @box_top + @config[:bar_width] * 28 / 10 + @config[:side_point_height] + @config[:side_spike_height]
52
+ end
53
+
54
+ def right_hash
55
+ Base::SA.vertical(
56
+ @box_right + @config[:bar_width], right_hash_top, right_hash_bottom,
57
+ pointer_bottom: @config[:center_point] + @config[:hash_width] / 2, fly: @fly, unit: @unit
58
+ )
59
+ end
60
+
61
+ def right_hash_top
62
+ @box_top + @config[:bar_width] * 28 / 10 + @config[:side_point_height] + @config[:side_spike_height]
63
+ end
64
+
65
+ def right_hash_bottom
66
+ @box_top + @config[:bar_width] * 38 / 10 + @config[:side_point_height] + @config[:side_spike_height]
67
+ end
68
+
69
+ def right_hash_to_bottom
70
+ Base::SA.vertical(
71
+ @box_right + @config[:bar_width],
72
+ @box_top + @config[:bar_width] * 38 / 10 + @config[:side_point_height] + @config[:side_spike_height],
73
+ @box_bottom, pointer_bottom: @box_right, fly: @fly, unit: @unit
74
+ )
75
+ end
76
+
77
+ def left
78
+ <<~SVG
79
+ <!-- Left -->
80
+ #{Base::SA.vertical(@box_left - @config[:bar_width] * 5.25, @box_top, @box_bottom, pointer_top: @box_left, pointer_bottom: @box_left, fly: @fly, unit: @unit)} <!-- Boundary height -->
81
+ #{left_main_point_height} <!-- Main point height -->
82
+ #{left_side_point_height} <!-- Side point height -->
83
+ SVG
84
+ end
85
+
86
+ def left_main_point_height
87
+ Base::SA.vertical(
88
+ @box_left - @config[:bar_width] * 0.75, @box_top, @box_top + @config[:center_point_height],
89
+ pointer_bottom: @config[:center_point] - @config[:bar_width], label_offset: -Base::BF / 24,
90
+ label_offset_y: -Base::BF / 60, label_align: 'middle', fly: @fly, unit: @unit
91
+ )
92
+ end
93
+
94
+ def left_side_point_height
95
+ Base::SA.vertical(
96
+ @box_left - @config[:bar_width] * 1.5, @box_top + @config[:bar_width] * 4 / 5, left_side_point_bottom,
97
+ pointer_top: @box_left, pointer_bottom: @box_left + @config[:bar_width], label_offset: -Base::BF / 24,
98
+ label_align: 'middle', fly: @fly, unit: @unit
99
+ )
100
+ end
101
+
102
+ def left_side_point_bottom
103
+ @box_top + @config[:bar_width] * 4 / 5 + @config[:side_point_height]
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -4,60 +4,64 @@
4
4
  #
5
5
  # These methods should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::Tridents
8
- class << self
9
- def cc(type, trident_color:)
10
- # The side C/C tridents are angled 45 degrees, and intersect the central one at 1/3 up from the bottom
11
- trident = USPSFlags::Core.trident(type, color: trident_color)
12
- x_distance = USPSFlags::Config::BASE_FLY * 4 / 39
13
- y_distance = USPSFlags::Config::BASE_FLY * 5 / 78
14
- <<~SVG
15
- <g transform="translate(-#{x_distance}, #{y_distance})"><g transform="rotate(-45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
16
- \n#{trident}
17
- <g transform="translate(#{x_distance}, #{y_distance})"><g transform="rotate(45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
18
- SVG
19
- end
7
+ class USPSFlags
8
+ class Core
9
+ class Tridents
10
+ class << self
11
+ def cc(type, trident_color:)
12
+ # The side C/C tridents are angled 45 degrees, and intersect the central one at 1/3 up from the bottom
13
+ trident = USPSFlags::Core.trident(type, color: trident_color)
14
+ x_distance = USPSFlags::Config::BASE_FLY * 4 / 39
15
+ y_distance = USPSFlags::Config::BASE_FLY * 5 / 78
16
+ <<~SVG
17
+ <g transform="translate(-#{x_distance}, #{y_distance})"><g transform="rotate(-45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
18
+ \n#{trident}
19
+ <g transform="translate(#{x_distance}, #{y_distance})"><g transform="rotate(45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
20
+ SVG
21
+ end
20
22
 
21
- def vc(type, trident_color:)
22
- # V/C tridents are angled 45 degrees, and intersect at 15/32 up from the bottom
23
- trident = USPSFlags::Core.trident(type, color: trident_color)
24
- x_distance = USPSFlags::Config::BASE_FLY * 4 / 55
25
- <<~SVG
26
- <g transform="translate(-#{x_distance})"><g transform="rotate(-45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
27
- <g transform="translate(#{x_distance})"><g transform="rotate(45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
28
- SVG
29
- end
23
+ def vc(type, trident_color:)
24
+ # V/C tridents are angled 45 degrees, and intersect at 15/32 up from the bottom
25
+ trident = USPSFlags::Core.trident(type, color: trident_color)
26
+ x_distance = USPSFlags::Config::BASE_FLY * 4 / 55
27
+ <<~SVG
28
+ <g transform="translate(-#{x_distance})"><g transform="rotate(-45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
29
+ <g transform="translate(#{x_distance})"><g transform="rotate(45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g></g>
30
+ SVG
31
+ end
30
32
 
31
- def three(type, trident_color:, field_color:)
32
- # Cdr and D/C tridents are spaced 1/2 the fly apart with the central one 1/4 the fly above the sides
33
- trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
34
- x_distance = USPSFlags::Config::BASE_FLY / 4
35
- y_distance = USPSFlags::Config::BASE_FLY / 16
36
- <<~SVG
37
- <g transform="translate(-#{x_distance}, #{y_distance})">\n#{trident}</g>
38
- <g transform="translate(0, -#{y_distance + 1})">\n#{trident}</g>
39
- <g transform="translate(#{x_distance}, #{y_distance})">\n#{trident}</g>
40
- SVG
41
- end
33
+ def three(type, trident_color:, field_color:)
34
+ # Cdr and D/C tridents are spaced 1/2 the fly apart with the central one 1/4 the fly above the sides
35
+ trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
36
+ x_distance = USPSFlags::Config::BASE_FLY / 4
37
+ y_distance = USPSFlags::Config::BASE_FLY / 16
38
+ <<~SVG
39
+ <g transform="translate(-#{x_distance}, #{y_distance})">\n#{trident}</g>
40
+ <g transform="translate(0, -#{y_distance + 1})">\n#{trident}</g>
41
+ <g transform="translate(#{x_distance}, #{y_distance})">\n#{trident}</g>
42
+ SVG
43
+ end
42
44
 
43
- def two(type, trident_color:, field_color:)
44
- # Lt/C and D/Lt/C tridents are spaced 1/3 the fly apart
45
- trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
46
- x_distance = USPSFlags::Config::BASE_FLY / 6
47
- <<~SVG
48
- <g transform="translate(-#{x_distance})">\n#{trident}</g>
49
- <g transform="translate(#{x_distance})">\n#{trident}</g>
50
- SVG
51
- end
45
+ def two(type, trident_color:, field_color:)
46
+ # Lt/C and D/Lt/C tridents are spaced 1/3 the fly apart
47
+ trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
48
+ x_distance = USPSFlags::Config::BASE_FLY / 6
49
+ <<~SVG
50
+ <g transform="translate(-#{x_distance})">\n#{trident}</g>
51
+ <g transform="translate(#{x_distance})">\n#{trident}</g>
52
+ SVG
53
+ end
52
54
 
53
- def offset(type, field_color:, field: true)
54
- # Swallowtail tridents need to move towards the hoist due to the tails
55
- x_distance = USPSFlags::Config::BASE_FLY / 10 if field
56
- svg = +''
57
- svg << "<g transform=\"translate(-#{x_distance})\">" if field
58
- svg << USPSFlags::Core.trident(type, field_color: field_color, color: :red)
59
- svg << '</g>' if field
60
- svg
55
+ def offset(type, field_color:, field: true)
56
+ # Swallowtail tridents need to move towards the hoist due to the tails
57
+ x_distance = USPSFlags::Config::BASE_FLY / 10 if field
58
+ svg = +''
59
+ svg << "<g transform=\"translate(-#{x_distance})\">" if field
60
+ svg << USPSFlags::Core.trident(type, field_color: field_color, color: :red)
61
+ svg << '</g>' if field
62
+ svg
63
+ end
64
+ end
61
65
  end
62
66
  end
63
67
  end