usps_flags 0.5.6 → 0.6.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
  SHA256:
3
- metadata.gz: cd1924100e63785bd74beb28420e134605b9b1dc65d7cdb2fa4d81f3560e04d7
4
- data.tar.gz: 250334abcb381cde875affe1952e39f8922c02b34d3992410146868155572027
3
+ metadata.gz: 66522ba47851bcb474d636cc17c8dcb62e25d32564893abfb93e9c3408b9b421
4
+ data.tar.gz: d9129013df7517b33e534bb6405ee20a2008e19b3236c04169e45278f46f8fdc
5
5
  SHA512:
6
- metadata.gz: 36950b9153031c3164ecafd3d0154e4d6c9442cd044a8fdca5dce847b6a92924e4df4d59e35d6185cfc8b8517e2d880f14421f3ccb3323b9a10077cd33e75176
7
- data.tar.gz: a243733ed9bc80bb510dd7864abfa9cfe8daae72b3e55bdc954ccd15d49d02c62bea493394da05082ef8d967ea315217ad18e5b7ff74c4007b011b6f907dd4d5
6
+ metadata.gz: 4092e043b877705349f24a2fd0ee3733bb2e7b0e75ddbed6f7bf1f1bb3aa1ac6a147c9ff3f69baf779332f7db1e5fb96f8f2480079231d21df181de605856e62
7
+ data.tar.gz: 4654f83943621648bde190a5bce5e889729ad138fb445017ba20c401bc0f6b2d5790b5b232a3906784f1bfa4fec854334db3351c3a04b680db19f145cf1f226c
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ doc/
2
2
  coverage/
3
3
  lib/output/
4
4
  tmp/
5
+ *.gem
@@ -0,0 +1 @@
1
+ 2.5.1
data/CC.png ADDED
Binary file
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps_flags (0.5.6)
4
+ usps_flags (0.6.1)
5
5
  file_utils (~> 1.1, >= 1.1.2)
6
6
  mini_magick (~> 4.9, >= 4.9.4)
7
7
  rubyzip (~> 1.3, >= 1.3.0)
@@ -13,14 +13,14 @@ GEM
13
13
  diff-lcs (1.3)
14
14
  docile (1.1.5)
15
15
  file_utils (1.1.2)
16
- jaro_winkler (1.5.2)
17
- json (2.1.0)
18
- mini_magick (4.9.5)
19
- parallel (1.17.0)
20
- parser (2.6.3.0)
16
+ jaro_winkler (1.5.4)
17
+ json (2.3.1)
18
+ mini_magick (4.10.1)
19
+ parallel (1.19.1)
20
+ parser (2.6.5.0)
21
21
  ast (~> 2.4.0)
22
22
  rainbow (3.0.0)
23
- rake (12.3.0)
23
+ rake (12.3.3)
24
24
  rspec (3.7.0)
25
25
  rspec-core (~> 3.7.0)
26
26
  rspec-expectations (~> 3.7.0)
@@ -34,7 +34,7 @@ GEM
34
34
  diff-lcs (>= 1.2.0, < 2.0)
35
35
  rspec-support (~> 3.7.0)
36
36
  rspec-support (3.7.0)
37
- rubocop (0.71.0)
37
+ rubocop (0.77.0)
38
38
  jaro_winkler (~> 1.5.1)
39
39
  parallel (~> 1.10)
40
40
  parser (>= 2.6)
@@ -58,7 +58,7 @@ PLATFORMS
58
58
  DEPENDENCIES
59
59
  rake (~> 12.2, >= 12.2.1)
60
60
  rspec (~> 3.7, >= 3.7.0)
61
- rubocop (~> 0.71, >= 0.71.0)
61
+ rubocop (~> 0.77, >= 0.77.0)
62
62
  rubocop-rspec (~> 1.30, >= 1.30.0)
63
63
  simplecov (~> 0.15, >= 0.15.1)
64
64
  usps_flags!
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # United States Power Squadrons® Flag Generator
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/usps_flags.svg)](https://rubygems.org/gems/usps_flags)
4
- [![Build Status](https://travis-ci.org/jfiander/usps-flags.svg)](https://travis-ci.org/jfiander/usps-flags)
4
+ [![Build Status](https://img.shields.io/travis/jfiander/usps-flags/master.svg)](https://travis-ci.org/jfiander/usps-flags)
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/760b824f0edac3316a11/test_coverage)](https://codeclimate.com/github/jfiander/usps-flags/test_coverage)
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/760b824f0edac3316a11/maintainability)](https://codeclimate.com/github/jfiander/usps-flags/maintainability)
7
7
 
@@ -10,6 +10,10 @@ class USPSFlags
10
10
  USPSFlags::Core::TridentSpecs::Build.new(fly: fly, unit: unit, scaled_border: scaled_border).svg
11
11
  end
12
12
 
13
+ def self.intersection_spec(fly: 24, unit: 'in', scaled_border: false)
14
+ USPSFlags::Core::TridentSpecs::Build.new(fly: fly, unit: unit, scaled_border: scaled_border).intersections
15
+ end
16
+
13
17
  def self.headers(width: nil, height: nil, pennant: false, scale: nil, title: 'USPS Flag')
14
18
  USPSFlags::Core::Headers.new(width: width, height: height, pennant: pennant, scale: scale, title: title).svg
15
19
  end
@@ -0,0 +1,125 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
3
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="1024" height="682" viewBox="-3.072 -4.096 3084.288 2058.24" preserveAspectRatio="xMidYMid meet">
4
+ <title>CC</title>
5
+ <metadata>
6
+ <desc id="created-by">Julian Fiander</desc>
7
+ <desc id="generated-at">20200216.1756-0500</desc>
8
+ <desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
9
+ <desc id="trademark-link">https://www.usps.org/images/secretary/itcom/trademark.pdf</desc>
10
+ </metadata><path d="M 0 0
11
+ l 3072 0
12
+ l 0 2048
13
+ l -3072 0
14
+ l 0 -2048 z
15
+ " fill="#012169" />
16
+ <g transform="translate(-354, 236)">
17
+ <g transform="rotate(-45, 1536, 1024)">
18
+ <path d="M 1536 256
19
+ l 80 184
20
+ l -40 -24
21
+ l 0 1376
22
+ l -80 0
23
+ l 0 -1376
24
+ l -40 24
25
+ l 80 -184
26
+ " fill="#FFFFFF" />
27
+ <path d="M 1296 784
28
+ l 480 0
29
+ l 0 80
30
+ l -480 0
31
+ l 0 -80
32
+ " fill="#FFFFFF" />
33
+ <path d="M 1296 785
34
+ l 0 -464
35
+ l 120 168
36
+ l -40 0
37
+ l 0 296
38
+ " fill="#FFFFFF" />
39
+ <path d="M 1776 785
40
+ l 0 -464
41
+ l -120 168
42
+ l 40 0
43
+ l 0 296
44
+ " fill="#FFFFFF" />
45
+ <path d="M 1400 944
46
+ l 273 0
47
+ l 0 80
48
+ l -273 0
49
+ l 0 -80
50
+ " fill="#FFFFFF" />
51
+ </g>
52
+ </g>
53
+
54
+ <path d="M 1536 256
55
+ l 80 184
56
+ l -40 -24
57
+ l 0 1376
58
+ l -80 0
59
+ l 0 -1376
60
+ l -40 24
61
+ l 80 -184
62
+ " fill="#FFFFFF" />
63
+ <path d="M 1296 784
64
+ l 480 0
65
+ l 0 80
66
+ l -480 0
67
+ l 0 -80
68
+ " fill="#FFFFFF" />
69
+ <path d="M 1296 785
70
+ l 0 -464
71
+ l 120 168
72
+ l -40 0
73
+ l 0 296
74
+ " fill="#FFFFFF" />
75
+ <path d="M 1776 785
76
+ l 0 -464
77
+ l -120 168
78
+ l 40 0
79
+ l 0 296
80
+ " fill="#FFFFFF" />
81
+ <path d="M 1400 944
82
+ l 273 0
83
+ l 0 80
84
+ l -273 0
85
+ l 0 -80
86
+ " fill="#FFFFFF" />
87
+
88
+ <g transform="translate(354, 236)">
89
+ <g transform="rotate(45, 1536, 1024)">
90
+ <path d="M 1536 256
91
+ l 80 184
92
+ l -40 -24
93
+ l 0 1376
94
+ l -80 0
95
+ l 0 -1376
96
+ l -40 24
97
+ l 80 -184
98
+ " fill="#FFFFFF" />
99
+ <path d="M 1296 784
100
+ l 480 0
101
+ l 0 80
102
+ l -480 0
103
+ l 0 -80
104
+ " fill="#FFFFFF" />
105
+ <path d="M 1296 785
106
+ l 0 -464
107
+ l 120 168
108
+ l -40 0
109
+ l 0 296
110
+ " fill="#FFFFFF" />
111
+ <path d="M 1776 785
112
+ l 0 -464
113
+ l -120 168
114
+ l 40 0
115
+ l 0 296
116
+ " fill="#FFFFFF" />
117
+ <path d="M 1400 944
118
+ l 273 0
119
+ l 0 80
120
+ l -273 0
121
+ l 0 -80
122
+ " fill="#FFFFFF" />
123
+ </g>
124
+ </g>
125
+ </svg>
@@ -52,7 +52,7 @@ class USPSFlags
52
52
  l #{@fly} 0
53
53
  l 0 #{@hoist}
54
54
  l -#{@fly} 0
55
- l 0 -#{@hoist}
55
+ l 0 -#{@hoist} z
56
56
  " fill="#{@color_code}" #{@border_svg}/>
57
57
  SVG
58
58
  end
@@ -71,7 +71,7 @@ class USPSFlags
71
71
  def past_field
72
72
  <<~SVG
73
73
  <g transform="translate(#{USPSFlags::Config::BASE_FLY / 1200}, #{USPSFlags::Config::BASE_FLY / 1800})">
74
- <path d="M 0 #{USPSFlags::Config::BASE_FLY / 600} #{past_line_one}" fill="#{@color_code}" />
74
+ <path d="M 0 #{USPSFlags::Config::BASE_FLY / 1200} #{past_line_one}" fill="#{@color_code}" />
75
75
  <path d="M #{@fly / 2} #{@hoist / 12} #{past_line_two}" fill="#{@past_mid_color}" />
76
76
  <path d="M #{@fly * 3 / 4} #{@hoist * 3 / 24} #{past_line_three}" fill="#{@past_tail_color}" />
77
77
  <path d="M 0 0 #{past_line_four} z" fill="none" stroke="#000000" stroke-width="#{USPSFlags::Config::BASE_FLY / 600}" />
@@ -54,7 +54,7 @@ class USPSFlags
54
54
  <<~SVG
55
55
  <?xml version="1.0" standalone="no"?>
56
56
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
57
- <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="#{@width}" height="#{@height}" viewBox="0 0 #{@view_width} #{@view_height}" preserveAspectRatio="xMidYMid meet">
57
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="#{@width}" height="#{@height}" viewBox="-#{@view_width * 0.001} -#{@view_height * 0.002} #{@view_width * 1.004} #{@view_height * 1.005}" preserveAspectRatio="xMidYMid meet">
58
58
  <title>#{@title}</title>
59
59
  <metadata>
60
60
  <desc id="created-by">Julian Fiander</desc>
@@ -13,7 +13,7 @@ class USPSFlags
13
13
 
14
14
  def initialize(type, color: :blue, field_color: nil)
15
15
  valid_types = %i[s d stf n]
16
- raise "Error: Invalid trident type. Options are #{valid_types}." unless valid_types.include?(type)
16
+ raise "Error: Invalid trident type: #{type}. Options are #{valid_types}." unless valid_types.include?(type)
17
17
 
18
18
  @type = type
19
19
 
@@ -24,6 +24,17 @@ class USPSFlags
24
24
  svg
25
25
  end
26
26
 
27
+ def intersections
28
+ # Static labeling
29
+ @fly = Rational(2048, 5)
30
+ @unit = ''
31
+
32
+ svg = spec_header(no_measurements: true)
33
+ svg << add_intersections
34
+
35
+ svg
36
+ end
37
+
27
38
  private
28
39
 
29
40
  def box_left
@@ -53,6 +64,71 @@ class USPSFlags
53
64
  add_trident(:Long, box_top, box_bottom, box_left, box_right)
54
65
  end
55
66
 
67
+ def add_intersections
68
+ svg = +''
69
+
70
+ svg += "<g transform=\"translate(-#{BF * 1 / 16}, #{BH / 4}) scale(0.6)\">"
71
+ svg += USPSFlags::Core::Tridents.cc(trident_color: :blue)
72
+ svg += cc_label
73
+ svg += '</g>'
74
+
75
+ svg += "<g transform=\"translate(#{BF * 7 / 16}, #{BH / 4}) scale(0.6)\">"
76
+ svg += USPSFlags::Core::Tridents.vc(trident_color: :red)
77
+ svg += vc_label
78
+ svg += '</g>'
79
+
80
+ svg
81
+ end
82
+
83
+ def cc_label
84
+ offset = BF.to_f * 1 / 32
85
+ height = BF.to_f * 15 / 64
86
+
87
+ small_arrow = SA.vertical(
88
+ offset, -height / 3, 0,
89
+ pointer_top: height / 3, pointer_bottom: 0, label_offset: BF / 35,
90
+ label_offset_y: -BF / 50, label_align: 'middle', fly: @fly, unit: @unit
91
+ )
92
+
93
+ <<~SVG
94
+ <!-- CC Intersection -->
95
+ <g transform="translate(#{BF / 2}, #{BH - 200}) rotate(45)">
96
+ #{big_arrow}
97
+ #{small_arrow}
98
+ </g>
99
+ SVG
100
+ end
101
+
102
+ def vc_label
103
+ offset = BF.to_f * 1 / 32
104
+ height = BF.to_f * 15 / 64
105
+
106
+ small_arrow = SA.vertical(
107
+ offset, -height * 15 / 32, 0,
108
+ pointer_top: height * 15 / 32, pointer_bottom: 0, label_offset: BF / 35,
109
+ label_offset_y: -BF / 50, label_align: 'middle', fly: @fly, unit: @unit
110
+ )
111
+
112
+ <<~SVG
113
+ <!-- CC Intersection -->
114
+ <g transform="translate(#{BF / 2}, #{BH - 200}) rotate(45)">
115
+ #{big_arrow}
116
+ #{small_arrow}
117
+ </g>
118
+ SVG
119
+ end
120
+
121
+ def big_arrow
122
+ offset = BF * 1 / 32
123
+ height = BF * 15 / 64
124
+
125
+ SA.vertical(
126
+ offset * 3, -height, 0,
127
+ pointer_top: height, pointer_bottom: 0, label_offset: BF / 60,
128
+ label_offset_y: -BF / 10, label_align: 'left', fly: @fly, unit: @unit
129
+ )
130
+ end
131
+
56
132
  def configure_sizes(fly)
57
133
  @fly = Rational(fly)
58
134
  get_hoist_from_fly(@fly)
@@ -109,10 +185,10 @@ class USPSFlags
109
185
  end
110
186
  end
111
187
 
112
- def spec_header
188
+ def spec_header(no_measurements: false)
113
189
  USPSFlags::Core::TridentSpecs::Header.new(
114
190
  fly: @fly, fly_fraction: @fly_fraction, hoist: @hoist, hoist_fraction: @hoist_fraction,
115
- unit_text: @unit_text, scaled_border: @scaled_border
191
+ unit_text: @unit_text, scaled_border: @scaled_border, no_measurements: no_measurements
116
192
  ).p
117
193
  end
118
194
 
@@ -15,6 +15,7 @@ class USPSFlags
15
15
  @hoist_fraction = options[:hoist_fraction]
16
16
  @unit_text = options[:unit_text]
17
17
  @scaled_border = options[:scaled_border]
18
+ @no_measurements = options.key?(:no_measurements) && options[:no_measurements]
18
19
  end
19
20
 
20
21
  def p
@@ -43,11 +44,21 @@ class USPSFlags
43
44
  <text x="#{BF / 2}" y="#{BH * 3 / 40}" font-family="sans-serif" font-size="#{BH / 20}px" font-weight="bold" fill="#041E42" text-anchor="middle">United States Power Squadrons<tspan class="heading" dy ="-#{BH / 50}">®</tspan></text>
44
45
  </g>
45
46
  <text x="#{BF / 2}" y="#{BH / 8}" font-family="sans-serif" font-size="#{BH / 30}px" fill="#041E42" text-anchor="middle">Officer Flag Trident Specification</text>
47
+ #{measurements_are_relative}
48
+ SVG
49
+ end
50
+
51
+ def measurements_are_relative
52
+ return if @no_measurements
53
+
54
+ <<~SVG
46
55
  <text x="#{BF / 2}" y="#{BH * 2 / 11}" font-family="sans-serif" font-size="#{BH / 40}px" fill="#041E42" text-anchor="middle">All measurements are relative to a field with</text>
47
56
  SVG
48
57
  end
49
58
 
50
59
  def units
60
+ return angles if @no_measurements
61
+
51
62
  <<~SVG
52
63
  <g>
53
64
  <style><![CDATA[tspan.title{font-size: #{USPSFlags::Config::FRACTION_SCALE * 9 / 10}%;}]]></style>
@@ -58,6 +69,12 @@ class USPSFlags
58
69
  SVG
59
70
  end
60
71
 
72
+ def angles
73
+ <<~SVG
74
+ <text x="#{BF / 2}" y="#{BH * 4 / 19}" font-family="sans-serif" font-size="#{BH / 40}px" fill="#041E42" text-anchor="middle">Angled tridents are 45 degrees from vertical.</text>
75
+ SVG
76
+ end
77
+
61
78
  def scaled_border
62
79
  <<~SVG
63
80
  <!-- Flag border scaled to spec trident size -->
@@ -8,30 +8,41 @@ class USPSFlags
8
8
  class Core
9
9
  class Tridents
10
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
11
+ # The side C/C tridents are angled 45 degrees, and intersect the central one at 1/3 up from the bottom
12
+ #
13
+ # Center of rotation:
14
+ # # radius = USPSFlags.configuration.trident[:bar_width] / 2
15
+ # <circle cx="#{cc_center[:x]}" cy="#{cc_center[:y]}" r="#{radius}" fill="red" />
16
+ def cc(_ = nil, trident_color:)
17
+ trident = USPSFlags::Core.trident(:n, color: trident_color)
18
+ x_distance = USPSFlags::Config::BASE_FLY * 4 / 39 # 4/39 or 28/39
19
+ y_distance = USPSFlags::Config::BASE_FLY * 2 / 39 # 5/78 or 27/156
16
20
  <<~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>
21
+ <g transform="translate(-#{x_distance * 1.25}, #{y_distance})">
22
+ <g transform="rotate(-45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g>
23
+ </g>
18
24
  \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>
25
+ <g transform="translate(#{x_distance * 1.25}, #{y_distance})">
26
+ <g transform="rotate(45)" transform-origin="center">\n#{trident}</g>
27
+ </g>
20
28
  SVG
21
29
  end
22
30
 
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
31
+ # V/C tridents are angled 45 degrees, and intersect at 15/32 up from the bottom
32
+ def vc(_ = nil, trident_color:)
33
+ trident = USPSFlags::Core.trident(:n, color: trident_color)
27
34
  <<~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>
35
+ <g transform="rotate(-45, #{vc_center[:x]}, #{vc_center[:y]})">
36
+ #{trident}
37
+ </g>
38
+ <g transform="rotate(45, #{vc_center[:x]}, #{vc_center[:y]})">
39
+ #{trident}
40
+ </g>
30
41
  SVG
31
42
  end
32
43
 
44
+ # Cdr and D/C tridents are spaced 1/2 the fly apart with the central one 1/4 the fly above the sides
33
45
  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
46
  trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
36
47
  x_distance = USPSFlags::Config::BASE_FLY / 4
37
48
  y_distance = USPSFlags::Config::BASE_FLY / 16
@@ -42,8 +53,8 @@ class USPSFlags
42
53
  SVG
43
54
  end
44
55
 
56
+ # Lt/C and D/Lt/C tridents are spaced 1/3 the fly apart
45
57
  def two(type, trident_color:, field_color:)
46
- # Lt/C and D/Lt/C tridents are spaced 1/3 the fly apart
47
58
  trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
48
59
  x_distance = USPSFlags::Config::BASE_FLY / 6
49
60
  <<~SVG
@@ -52,8 +63,8 @@ class USPSFlags
52
63
  SVG
53
64
  end
54
65
 
66
+ # Swallowtail tridents need to move towards the hoist due to the tails
55
67
  def offset(type, field_color:, field: true)
56
- # Swallowtail tridents need to move towards the hoist due to the tails
57
68
  x_distance = USPSFlags::Config::BASE_FLY / 10 if field
58
69
  svg = +''
59
70
  svg << "<g transform=\"translate(-#{x_distance})\">" if field
@@ -61,6 +72,25 @@ class USPSFlags
61
72
  svg << '</g>' if field
62
73
  svg
63
74
  end
75
+
76
+ private
77
+
78
+ def rotation_center(height_fraction)
79
+ {
80
+ x: USPSFlags::Config::BASE_FLY / 2,
81
+ y: (USPSFlags::Config::BASE_HOIST * 7 / 8) - (n_staff_height * height_fraction).to_f
82
+ }
83
+ end
84
+
85
+ def vc_center
86
+ rotation_center(Rational(15, 32))
87
+ end
88
+
89
+ def n_staff_height
90
+ top_height = USPSFlags.configuration.trident[:crossbar_from_top]
91
+ bars = (USPSFlags.configuration.trident[:bar_width] * 3)
92
+ USPSFlags.configuration.trident_heights[:n] - top_height - bars
93
+ end
64
94
  end
65
95
  end
66
96
  end
@@ -103,6 +103,22 @@ class USPSFlags
103
103
  USPSFlags::Helpers.output(svg, outfile: outfile)
104
104
  end
105
105
 
106
+ # Generate trident spec sheet for National Bridge intersections as an SVG image.
107
+ #
108
+ # @param [String] outfile The path to save the SVG file to. If not set, prints to console.
109
+ # @param [Integer] fly The nominal fly length of an appropriate flag field for the generated tridents.
110
+ # @param [String] outfile The unit to append to all trident measurements.
111
+ # @param [String] scale The image scale divisor factor.
112
+ # @return [String] Returns the SVG data.
113
+ def intersection_spec(outfile: nil, fly: USPSFlags::Config::BASE_FLY, unit: nil, scale: nil, scaled_border: false)
114
+ svg = +''
115
+ svg << USPSFlags::Core.headers(scale: scale, title: 'USPS Trident Specifications')
116
+ svg << USPSFlags::Core.intersection_spec(fly: fly, unit: unit, scaled_border: scaled_border)
117
+ svg << USPSFlags::Core.footer
118
+
119
+ USPSFlags::Helpers.output(svg, outfile: outfile)
120
+ end
121
+
106
122
  private
107
123
 
108
124
  def special_flag(flag, outfile, scale)
@@ -24,13 +24,14 @@ class USPSFlags
24
24
  end
25
25
 
26
26
  def special(type, level:, field: true)
27
+ translate = (type == :f && level == :n) || !field
27
28
  # Paths were designed for a base fly of 3000 pixels, but the base was changed for more useful fractions.
28
29
  svg = +''
29
- svg << "<g transform=\"translate(#{USPSFlags::Config::BASE_FLY / 10})\">" unless field
30
+ svg << "<g transform=\"translate(#{USPSFlags::Config::BASE_FLY / 10})\">" if translate
30
31
  svg << "<g transform=\"scale(#{Rational(USPSFlags::Config::BASE_FLY, 3000).to_f})\">"
31
32
  svg << special_icon(type, level)
32
33
  svg << '</g>'
33
- svg << '</g>' unless field
34
+ svg << '</g>' if translate
34
35
 
35
36
  svg
36
37
  end
@@ -120,6 +120,7 @@ class USPSFlags
120
120
 
121
121
  dirs = path.split('/')
122
122
  dirs.pop
123
+ dirs = ['.'] if dirs.empty?
123
124
  ::FileUtils.mkdir_p(dirs.join('/')).first
124
125
  end
125
126
 
@@ -179,7 +180,7 @@ class USPSFlags
179
180
  end
180
181
 
181
182
  def flag_type(rank)
182
- specifics = { 'PORTCAP' => :pc, 'FLEETCAP' => :fc, 'STFC' => :stf }
183
+ specifics = { 'PORTCAP' => :pc, 'FLEETCAP' => :fc, 'STFC' => :stf, 'PSTFC' => :stf }
183
184
  return specifics[rank] if specifics.key?(rank)
184
185
  return :a if rank.match?(/.AIDE/)
185
186
  return :f if rank.match?(/.?FLT/)
@@ -15,7 +15,7 @@ class USPSFlags
15
15
  @district_past = %w[PDLTC PDC]
16
16
  @district_elected = %w[D1LT DLTC DC]
17
17
  @district_swallowtail = %w[DLT DAIDE DFLT]
18
- @national_past = %w[PSTFC PRC PVC PCC]
18
+ @national_past = %w[PNFLT PSTFC PRC PVC PCC]
19
19
  @national_elected = %w[STFC RC VC CC]
20
20
  @national_swallowtail = %w[NAIDE NFLT]
21
21
  end
@@ -42,7 +42,7 @@ describe USPSFlags::Core do
42
42
  l #{@fly} 0
43
43
  l 0 #{@hoist}
44
44
  l -#{@fly} 0
45
- l 0 -#{@hoist}
45
+ l 0 -#{@hoist} z
46
46
  " fill="#FFFFFF" stroke="#000000" stroke-width="#{USPSFlags::Config::BASE_FLY / 600}" />
47
47
  SVG
48
48
  )
@@ -55,7 +55,7 @@ describe USPSFlags::Core do
55
55
  l #{@fly} 0
56
56
  l 0 #{@hoist}
57
57
  l -#{@fly} 0
58
- l 0 -#{@hoist}
58
+ l 0 -#{@hoist} z
59
59
  " fill="#{@red}" />
60
60
  SVG
61
61
  )
@@ -78,7 +78,7 @@ describe USPSFlags::Core do
78
78
  expect(described_class.field(style: :past, color: :blue)).to eql(
79
79
  <<~SVG
80
80
  <g transform="translate(2, 1)">
81
- <path d="M 0 5 l #{@fly / 2} #{@hoist * 1 / 12}
81
+ <path d="M 0 2 l #{@fly / 2} #{@hoist * 1 / 12}
82
82
  l 0 #{@hoist * 10 / 12}
83
83
  l -#{@fly / 2} #{@hoist * 1 / 12}
84
84
  " fill="#{@blue}" />
@@ -6,7 +6,7 @@ describe USPSFlags::Generate do
6
6
  describe 'general features' do
7
7
  it 'generates a flag with the correct size' do
8
8
  expect(described_class.svg('LtC', outfile: '')).to include(
9
- 'width="1024" height="682" viewBox="0 0 3072 2048"'
9
+ 'width="1024" height="682" viewBox="-3.072 -4.096 3084.288 2058.24"'
10
10
  )
11
11
  end
12
12
 
@@ -17,7 +17,7 @@ describe USPSFlags::Generate do
17
17
  l 3072 0
18
18
  l 0 2048
19
19
  l -3072 0
20
- l 0 -2048
20
+ l 0 -2048 z
21
21
  " fill="#E4002B" />
22
22
  SVG
23
23
  )
@@ -40,7 +40,7 @@ describe USPSFlags::Generate do
40
40
 
41
41
  describe 'officer flags' do
42
42
  %w[
43
- PLTC PC PDLTC PDC PSTFC PRC PVC PCC
43
+ PLTC PC PDLTC PDC PNFLT PSTFC PRC PVC PCC
44
44
  PORTCAP FLEETCAP FLT DAIDE DFLT NAIDE NFLT
45
45
  LT 1LT LTC CDR DLT D1LT DLTC DC STFC RC VC CC
46
46
  ].each do |flag|
@@ -88,6 +88,10 @@ describe USPSFlags::Generate do
88
88
  it 'generates the trident specification sheet with a fractional field size' do
89
89
  expect(described_class.spec(outfile: '', fly: 23.5)).to include('<title>USPS Trident Specifications</title>')
90
90
  end
91
+
92
+ it 'generates the intersection specification sheet' do
93
+ expect(described_class.intersection_spec(outfile: '')).to include('CC Intersection')
94
+ end
91
95
  end
92
96
 
93
97
  describe 'png' do
@@ -11,7 +11,7 @@ describe USPSFlags::Helpers do
11
11
  it 'returns all officer flags but nothing else when given type :officer' do
12
12
  expect(described_class.valid_flags(:officer).sort).to eql(%w[
13
13
  PLTC PC PORTCAP FLEETCAP LT FLT 1LT LTC CDR PDLTC PDC DLT DAIDE
14
- DFLT D1LT DLTC DC PSTFC PRC PVC PCC NAIDE NFLT STFC RC VC CC
14
+ DFLT D1LT DLTC DC PNFLT PSTFC PRC PVC PCC NAIDE NFLT STFC RC VC CC
15
15
  ].sort)
16
16
  end
17
17
 
@@ -7,7 +7,7 @@ describe USPSFlags do
7
7
  @valid_header = <<~SVG
8
8
  <?xml version="1.0" standalone="no"?>
9
9
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
10
- <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="614" height="409" viewBox="0 0 3072 2048" preserveAspectRatio="xMidYMid meet">
10
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="614" height="409" viewBox="-3.072 -4.096 3084.288 2058.24" preserveAspectRatio="xMidYMid meet">
11
11
  <title>LTC</title>
12
12
  <metadata>
13
13
  <desc id="created-by">Julian Fiander</desc>
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'usps_flags'
5
- s.version = '0.5.6'
6
- s.date = '2019-12-12'
5
+ s.version = '0.6.1'
6
+ s.date = '2020-08-03'
7
7
  s.summary = 'Flag generator for United States Power Squadrons'
8
8
  s.description = 'A flag image (PNG, SVG) generator for United States Power Squadrons.'
9
9
  s.homepage = 'http://rubygems.org/gems/usps_flags'
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_development_dependency 'rake', '~> 12.2', '>= 12.2.1'
24
24
  s.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
25
- s.add_development_dependency 'rubocop', '~> 0.71', '>= 0.71.0'
25
+ s.add_development_dependency 'rubocop', '~> 0.77', '>= 0.77.0'
26
26
  s.add_development_dependency 'rubocop-rspec', '~> 1.30', '>= 1.30.0'
27
27
  s.add_development_dependency 'simplecov', '~> 0.15', '>= 0.15.1'
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps_flags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-12 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: file_utils
@@ -116,20 +116,20 @@ dependencies:
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '0.71'
119
+ version: '0.77'
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: 0.71.0
122
+ version: 0.77.0
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0.71'
129
+ version: '0.77'
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
- version: 0.71.0
132
+ version: 0.77.0
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: rubocop-rspec
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -179,8 +179,10 @@ files:
179
179
  - ".gitignore"
180
180
  - ".rspec"
181
181
  - ".rubocop.yml"
182
+ - ".ruby-version"
182
183
  - ".travis.yml"
183
184
  - ".yardopts"
185
+ - CC.png
184
186
  - CONTRIBUTING.md
185
187
  - Gemfile
186
188
  - Gemfile.lock
@@ -192,6 +194,7 @@ files:
192
194
  - lib/usps_flags/config.rb
193
195
  - lib/usps_flags/configuration.rb
194
196
  - lib/usps_flags/core.rb
197
+ - lib/usps_flags/core/CC.svg
195
198
  - lib/usps_flags/core/ensign.rb
196
199
  - lib/usps_flags/core/field.rb
197
200
  - lib/usps_flags/core/footer.rb