usps_flags 0.1.26 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaffc7ccddc27ce5e71b12e62c4ca7b9dacefc15
4
- data.tar.gz: 2e12d76245da32f5f244faae056c79033742e083
3
+ metadata.gz: 1f60a474823123130c88cb0644669640e155c213
4
+ data.tar.gz: 9bbf9f5359b28e8a8f375754000a5290046f6a69
5
5
  SHA512:
6
- metadata.gz: 125aed09b0115a6c149b280fbf91a6e2404b98b5abb49bd56f9624f1e038de06a27481690c91dac356bc4b7af6b67e374d4cf4bccceb18f8184330284740d678
7
- data.tar.gz: b4d47e17b881b673ef4c3880da22fab90348d816300b3cbd6936c7e74e8535084dbe4d71f49ea6ec43821ab3f372b979ee51adcb7b4f5ed84f9a912cee812e42
6
+ metadata.gz: 24bf52afae4c48b31d9304939e350922f27e8fb9409130c5b897cc4bf78db1f99f9632320d49f1092fbd226302846fe8d4c1d917534fd4c36f35c1e7b081d7e5
7
+ data.tar.gz: d1ee90e5fe2895a6cdbc1f8306237258b5835b93b8939f2111f3e6f81c56e0ac1a01b2459d507212a20094b67062362698864aa9fc5f6daf43802b384bcde319
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
1
- @]u�Q�o�(�6��W�����H\��d�aC�����<"����RKz��`��rݳ_�3��u�!w'C��j d_��6P>?��Nm{��P�H�V�G?�_�{�?ݛ��P�ˌ�&,g���� � �Y[ߵ�Áv��x4uh�W���1�X��5%U���.�M}�B��h����6q�x�{�*!��k���]��CeV��o]����>`�e����R(��g�.5�>G)h[��P� �Z.�T���ӝ0^�'
1
+ ׳[pgM���� 'M�/r�����,.;ƁBO��9K81����/C��r���˄=�Qeg[����-�}�� 72A�/��s鶱F
2
+ %�1n��fK�׌�X�l�8
3
+ Z����I�
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps_flags (0.1.26)
4
+ usps_flags (0.2.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)
data/README.md CHANGED
@@ -2,30 +2,37 @@
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/usps_flags.svg)](https://rubygems.org/gems/usps_flags)
4
4
  [![Build Status](https://travis-ci.org/jfiander/usps-flags.svg)](https://travis-ci.org/jfiander/usps-flags)
5
- [![Coverage Status](https://coveralls.io/repos/github/jfiander/usps-flags/badge.svg?branch=master)](https://coveralls.io/github/jfiander/usps-flags?branch=master)
5
+ [![Coverage Status](https://coveralls.io/repos/github/jfiander/usps-flags/badge.svg?branch=master&service=github)](https://coveralls.io/github/jfiander/usps-flags?branch=master)
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/760b824f0edac3316a11/maintainability)](https://codeclimate.com/github/jfiander/usps-flags/maintainability)
7
7
 
8
- This gem allows you to generate precise SVG and PNG flag images based on official specifications.
8
+ This gem allows you to generate precise SVG and PNG flag images based on
9
+ official specifications.
9
10
 
10
11
  ## Installation
11
12
 
12
13
  ### Rails
13
14
 
14
15
  Add to your Gemfile:
16
+
15
17
  ```ruby
16
18
  gem 'usps_flags'
17
19
  ```
18
20
 
19
21
  Create the file `config/initializers/usps_flags.rb`:
22
+
20
23
  ```ruby
21
24
  USPSFlags::Config.flags_dir "#{Rails.root}/app/assets/images/flags"
22
25
  ```
23
26
 
24
27
  ### Other
25
28
 
26
- Run `gem install usps_flags`.
29
+ Run the following commands:
27
30
 
28
- Run `require 'usps_flags'` then `USPSFlags::Config.flags_dir "path/to/flags/dir"` to specify where to output all generated files and logs. (Otherwise, will default to `/output` in the gem directory.)
31
+ ```ruby
32
+ gem install usps_flags
33
+ require 'usps_flags'
34
+ USPSFlags::Config.flags_dir "path/to/flags/dir"
35
+ ```
29
36
 
30
37
  ## Available flags
31
38
 
@@ -45,6 +52,7 @@ Tests are written in Rspec. To run all specs in a cloned repo, run 'rake'.
45
52
  ### All files
46
53
 
47
54
  To generate all static files, run:
55
+
48
56
  ```ruby
49
57
  USPSFlags::Generate.all svg: true, png: true, zips: true
50
58
  ```
@@ -54,6 +62,7 @@ USPSFlags::Generate.all svg: true, png: true, zips: true
54
62
  ### Zip archives
55
63
 
56
64
  To re-generate zip files from current static files, run:
65
+
57
66
  ```ruby
58
67
  USPSFlags::Generate.zips svg: true, png: true
59
68
  ```
@@ -63,38 +72,47 @@ USPSFlags::Generate.zips svg: true, png: true
63
72
  ### Individual files
64
73
 
65
74
  To generate an individual SVG file, run:
75
+
66
76
  ```ruby
67
- USPSFlags::Generate.get "flag", outfile: nil, scale: nil, field: true
77
+ USPSFlags::Generate.svg "flag", outfile: nil, scale: nil, field: true
68
78
  ```
69
79
 
70
- - `outfile` specifies where to save the file. If left as `nil`, this method will `puts` the generated SVG. Either way, the SVG code is returned.
71
- - `scale` is a divisor scaling factor – the larger it is, the smaller the resulting SVG will be rendered. Accepted values are floats between 0 and 1, and integers above that.
72
- - `field` specifies whether to render the field of a flag, or to only render the insignia. Setting this to `false` will invert some colors for visibility.
80
+ - `outfile` specifies where to save the file. If left as `nil`, this method will
81
+ `puts` the generated SVG. Either way, the SVG code is returned.
82
+ - `scale` is a divisor scaling factor the larger it is, the smaller the
83
+ resulting SVG will be rendered. Accepted values are floats between 0 and 1,
84
+ and integers above that.
85
+ - `field` specifies whether to render the field of a flag, or to only render the
86
+ insignia. Setting this to `false` will invert some colors for visibility.
73
87
 
74
88
  ### Trident spec sheet
75
89
 
76
90
  To generate the trident spec sheet, run:
91
+
77
92
  ```ruby
78
93
  USPSFlags::Generate.spec outfile: nil, scale: nil, fly: 24, unit: "in"
79
94
  ```
80
95
 
81
- - `outfile` specifies where to save the file. If left as `nil`, this method will `puts` the generated SVG. Either way, the SVG code is returned.
82
- - `scale` is a divisor scaling factor – the larger it is, the smaller the resulting SVG will be rendered. Accepted values are floats between 0 and 1, and integers above that.
96
+ - `outfile` specifies where to save the file. If left as `nil`, this method will
97
+ `puts` the generated SVG. Either way, the SVG code is returned.
98
+ - `scale` is a divisor scaling factor – the larger it is, the smaller the
99
+ resulting SVG will be rendered. Accepted values are floats between 0 and 1,
100
+ and integers above that.
83
101
  - `fly` specifies the custom fly measurement to scale all trident labels to.
84
- - `unit` specifies the custom fly measurement unit to append to all trident labels.
102
+ - `unit` specifies the custom fly measurement unit to append to all trident
103
+ labels.
85
104
 
86
105
  ### Convert SVG to PNG
87
106
 
88
107
  To convert SVG data to a PNG image, run:
108
+
89
109
  ```ruby
90
110
  USPSFlags::Generate.png svg_data, outfile: nil, trim: false
91
-
92
- # USPSFlags::Generate.png File.read("path/to/svg_image.svg"), outfile: "path/to/output.png", trim: false
93
- # USPSFlags::Generate.png USPSFlags::Generate.get("LtC"), outfile: "path/to/output.png", trim: true
94
111
  ```
95
112
 
96
113
  - `outfile` is required, and specifies where to save the file.
97
- - `trim` specifies whether to trim blank space from around the image. (This is ideal for generating insignia.)
114
+ - `trim` specifies whether to trim blank space from around the image. (This is
115
+ ideal for generating insignia.)
98
116
 
99
117
  ## Constructing
100
118
 
@@ -114,13 +132,16 @@ f.svg # Generate SVG file
114
132
  f.png # Generate PNG file
115
133
  ```
116
134
 
117
- - Calling any DSL method without argument, or with `nil` as argument will return the current value.
118
- - You can explicitly set `svg_file` to `""` to suppress printing the SVG content to console/log.
135
+ - Calling any DSL method without argument, or with `nil` as argument will return
136
+ the current value.
137
+ - You can explicitly set `svg_file` to `""` to suppress printing the SVG content
138
+ to console/log.
119
139
  - Calling `.png` requires `png_file` to be set.
120
140
 
121
141
  ## Security
122
142
 
123
- This gem is cryptographically signed. To be sure the gem code hasn’t been tampered with:
143
+ This gem is cryptographically signed. To be sure the gem code hasn’t been
144
+ tampered with:
124
145
 
125
146
  Add my public key as a trusted certificate:
126
147
 
@@ -136,6 +157,9 @@ gem install usps_flags -P HighSecurity
136
157
 
137
158
  ## License
138
159
 
139
- Actual images generated (other than the US Ensign) are [registered trademarks](http://www.usps.org/national/itcom/trademark.html) of United States Power Squadrons.
160
+ Actual images generated (other than the US Ensign) are
161
+ [registered trademarks](http://www.usps.org/national/itcom/trademark.html) of
162
+ United States Power Squadrons.
140
163
 
141
- This project is released under the [GPLv3](https://raw.github.com/jfiander/usps-flags/master/LICENSE).
164
+ This project is released under the
165
+ [GPLv3](https://raw.github.com/jfiander/usps-flags/master/LICENSE).
@@ -31,25 +31,25 @@ class USPSFlags::Core::Field
31
31
  def svg
32
32
  case @style
33
33
  when :regular
34
- <<~FIELD
34
+ <<~SVG
35
35
  <path d="M 0 0
36
36
  l #{@fly} 0
37
37
  l 0 #{@hoist}
38
38
  l -#{@fly} 0
39
39
  l 0 -#{@hoist}
40
40
  " fill="#{@color_code}" #{@border_svg}/>
41
- FIELD
41
+ SVG
42
42
  when :swallowtail
43
- <<~FIELD
43
+ <<~SVG
44
44
  <path d="M 0 0
45
45
  l #{@fly} #{@hoist/6}
46
46
  l -#{@fly/5} #{@hoist/3}
47
47
  l #{@fly/5} #{@hoist/3}
48
48
  l -#{@fly} #{@hoist/6}
49
49
  " fill="#FFFFFF" stroke="#000000" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
50
- FIELD
50
+ SVG
51
51
  when :past
52
- <<~FIELD
52
+ <<~SVG
53
53
  <path d="M 0 0
54
54
  l #{@fly/2} #{@hoist*1/12}
55
55
  l 0 #{@hoist*10/12}
@@ -72,7 +72,7 @@ class USPSFlags::Core::Field
72
72
  l #{@fly/5} #{@hoist/3}
73
73
  l -#{@fly} #{@hoist/6}
74
74
  " fill="none" stroke="#000000" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
75
- FIELD
75
+ SVG
76
76
  end
77
77
  end
78
78
  end
@@ -4,8 +4,8 @@
4
4
  # @private
5
5
  class USPSFlags::Core::Footer
6
6
  def svg
7
- <<~FOOTER
7
+ <<~SVG
8
8
  </svg>
9
- FOOTER
9
+ SVG
10
10
  end
11
11
  end
@@ -15,26 +15,26 @@ class USPSFlags::Core::Pennant
15
15
  <polyline fill="#{USPSFlags::Config::BLUE}" points="0 0 #{USPSFlags::Config::BASE_FLY} #{USPSFlags::Config::BASE_HOIST/8} 0 #{USPSFlags::Config::BASE_HOIST/4}" />
16
16
  SVG
17
17
  elsif @type == "CRUISE"
18
- svg = <<~FIELD
18
+ svg = <<~SVG
19
19
  <path d="M 0 0
20
- l #{fly*10/36} #{hoist*5/36}
21
- l 0 #{hoist*26/36}
22
- l -#{fly*10/36} #{hoist*5/36}
20
+ l #{@fly*10/36} #{@hoist*5/36}
21
+ l 0 #{@hoist*26/36}
22
+ l -#{@fly*10/36} #{@hoist*5/36}
23
23
  " fill="#{USPSFlags::Config::RED}" />
24
- <path d="M #{fly*10/36} #{hoist*5/36}
25
- l #{fly*11/36} #{hoist*5.5/36}
26
- l 0 #{hoist*15/36}
27
- l -#{fly*11/36} #{hoist*5.5/36}
24
+ <path d="M #{@fly*10/36} #{@hoist*5/36}
25
+ l #{@fly*11/36} #{@hoist*5.5/36}
26
+ l 0 #{@hoist*15/36}
27
+ l -#{@fly*11/36} #{@hoist*5.5/36}
28
28
  " fill="#FFFFFF" />
29
- <path d="M #{fly*21/36} #{hoist*10.5/36}
30
- l #{fly*15/36} #{hoist*7.5/36}
31
- l -#{fly*15/36} #{hoist*7.5/36}
29
+ <path d="M #{@fly*21/36} #{@hoist*10.5/36}
30
+ l #{@fly*15/36} #{@hoist*7.5/36}
31
+ l -#{@fly*15/36} #{@hoist*7.5/36}
32
32
  " fill="#{USPSFlags::Config::BLUE}" />
33
33
  <path d="M 0 0
34
- l #{fly} #{hoist/2}
35
- l -#{fly} #{hoist/2}
34
+ l #{@fly} #{@hoist/2}
35
+ l -#{@fly} #{@hoist/2}
36
36
  " fill="none" stroke="#000000" stroke-width="2" />
37
- FIELD
37
+ SVG
38
38
 
39
39
  svg << "<g transform=\"translate(385, 340)\">"
40
40
  svg << USPSFlags::Core::Star.new.svg
@@ -8,158 +8,171 @@ class USPSFlags::Core::Trident
8
8
  raise "Error: Invalid trident type. Options are #{valid_types}." unless valid_types.include? type
9
9
  @type = type
10
10
 
11
+ load_config
12
+ configure_trident_segments
13
+ configure_colors(color, field_color)
14
+ end
15
+
16
+ def svg
17
+ svg = ""
18
+ svg << "<g mask=\"url(#delta-mask)\">" if @type == :d
19
+ svg << "<g mask=\"url(#circle-mask-for-main-spike)\">" if @type == :stf
20
+
21
+ @trident_segments.each do |segment|
22
+ start = segment.keys.first
23
+ points = segment.values.first
24
+ svg << "<path d=\"M #{start[0]} #{start[1]}\n"
25
+ points.each { |x, y| svg << "l #{x} #{y}\n" }
26
+ svg << "\" fill=\"#{@color_code}\" />\n"
27
+ end
28
+ svg << "</g>" if [:d, :stf].include?(@type)
29
+
30
+ case @type
31
+ when :d
32
+ svg << delta_hash
33
+ when :stf
34
+ svg << circle_hash
35
+ else
36
+ svg << standard_hash
37
+ end
38
+
39
+ svg
40
+ end
41
+
42
+ private
43
+ def load_config
11
44
  @trident_config = USPSFlags::Config.trident
12
- main_spike_overhang = @trident_config[:bar_width] / 2
13
- side_spike_overhang = @trident_config[:bar_width] / 2
45
+ @main_spike_overhang = @trident_config[:bar_width] / 2
46
+ @side_spike_overhang = @trident_config[:bar_width] / 2
14
47
  @top_point = ((USPSFlags::Config::BASE_HOIST - @trident_config[:height][@type]) / 2)
15
- crossbar_top = @top_point + @trident_config[:crossbar_from_top]
48
+ @crossbar_top = @top_point + @trident_config[:crossbar_from_top]
16
49
  @hash_from_top = @trident_config[:crossbar_from_top] + (@trident_config[:bar_width] * 2)
17
50
  @circle_from_top = @trident_config[:crossbar_from_top] + @trident_config[:bar_width]*123/128 + @trident_config[:width]/2
18
- main_length = @trident_config[:height][@type] - (@trident_config[:point_height] - @trident_config[:main_point_barb])
19
-
20
- @trident_segments = [
21
- {
22
- # Main spike
23
- [@trident_config[:center_point], @top_point] =>
24
- [
25
- [@trident_config[:bar_width], @trident_config[:point_height]],
26
- [-main_spike_overhang, -@trident_config[:main_point_barb]],
27
- [0, main_length],
28
- [-(@trident_config[:bar_width]), 0],
29
- [0, -main_length],
30
- [-main_spike_overhang, @trident_config[:main_point_barb]],
31
- [@trident_config[:bar_width], -@trident_config[:point_height]]
32
- ]
33
- },
34
- {
35
- # Crossbar
36
- [(@trident_config[:center_point] - @trident_config[:width]/2), (crossbar_top)] =>
37
- [
38
- [@trident_config[:width], 0],
39
- [0, @trident_config[:bar_width]],
40
- [-@trident_config[:width], 0],
41
- [0, -@trident_config[:bar_width]]
42
- ]
43
- },
44
- {
45
- # Left spike
46
- [(@trident_config[:center_point] - @trident_config[:width]/2), (crossbar_top + 1)] =>
47
- [
48
- [0, -(@trident_config[:side_spike_height]+@trident_config[:point_height])],
49
- [(@trident_config[:bar_width]+side_spike_overhang), @trident_config[:point_height]],
50
- [-side_spike_overhang, 0],
51
- [0, @trident_config[:side_spike_height]]
52
- ]
53
- },
54
- {
55
- # Right spike
56
- [(@trident_config[:center_point] + @trident_config[:width]/2), (crossbar_top + 1)] =>
57
- [
58
- [0, -(@trident_config[:side_spike_height]+@trident_config[:point_height])],
59
- [-(@trident_config[:bar_width]+side_spike_overhang), @trident_config[:point_height]],
60
- [side_spike_overhang, 0],
61
- [0, @trident_config[:side_spike_height]]
62
- ]
63
- }
64
- ]
51
+ @main_length = @trident_config[:height][@type] - (@trident_config[:point_height] - @trident_config[:main_point_barb])
52
+ end
53
+
54
+ def configure_trident_segments
55
+ @trident_segments = [main_spike, crossbar, left_spike, right_spike]
56
+ @lower_hash = lower_hash
57
+ end
58
+
59
+ def main_spike
60
+ {
61
+ [@trident_config[:center_point], @top_point] =>
62
+ [
63
+ [@trident_config[:bar_width], @trident_config[:point_height]],
64
+ [-@main_spike_overhang, -@trident_config[:main_point_barb]],
65
+ [0, @main_length],
66
+ [-(@trident_config[:bar_width]), 0],
67
+ [0, -@main_length],
68
+ [-@main_spike_overhang, @trident_config[:main_point_barb]],
69
+ [@trident_config[:bar_width], -@trident_config[:point_height]]
70
+ ]
71
+ }
72
+ end
65
73
 
66
- @lower_hash = [
74
+ def crossbar
75
+ {
76
+ [(@trident_config[:center_point] - @trident_config[:width]/2), (@crossbar_top)] =>
77
+ [
78
+ [@trident_config[:width], 0],
79
+ [0, @trident_config[:bar_width]],
80
+ [-@trident_config[:width], 0],
81
+ [0, -@trident_config[:bar_width]]
82
+ ]
83
+ }
84
+ end
85
+
86
+ def left_spike
87
+ {
88
+ [(@trident_config[:center_point] - @trident_config[:width]/2), (@crossbar_top + 1)] =>
89
+ [
90
+ [0, -(@trident_config[:side_spike_height]+@trident_config[:point_height])],
91
+ [(@trident_config[:bar_width]+@side_spike_overhang), @trident_config[:point_height]],
92
+ [-@side_spike_overhang, 0],
93
+ [0, @trident_config[:side_spike_height]]
94
+ ]
95
+ }
96
+ end
97
+
98
+ def right_spike
99
+ {
100
+ [(@trident_config[:center_point] + @trident_config[:width]/2), (@crossbar_top + 1)] =>
101
+ [
102
+ [0, -(@trident_config[:side_spike_height]+@trident_config[:point_height])],
103
+ [-(@trident_config[:bar_width]+@side_spike_overhang), @trident_config[:point_height]],
104
+ [@side_spike_overhang, 0],
105
+ [0, @trident_config[:side_spike_height]]
106
+ ]
107
+ }
108
+ end
109
+
110
+ def lower_hash
111
+ [
67
112
  [@trident_config[:hash_width], 0],
68
113
  [0, @trident_config[:bar_width]],
69
114
  [-@trident_config[:hash_width], 0],
70
115
  [0, -@trident_config[:bar_width]]
71
116
  ]
117
+ end
72
118
 
73
- case color
74
- when :white
75
- @color_code = "#FFFFFF"
76
- @field_color_code = case field_color
77
- when :red
78
- USPSFlags::Config::RED
79
- when :blue
80
- USPSFlags::Config::BLUE
81
- end
82
- when :red
119
+ def configure_colors(color, field_color)
120
+ @color_code = "#FFFFFF"
121
+ if color == :red
83
122
  @color_code = USPSFlags::Config::RED
84
123
  @field_color_code = "#FFFFFF"
85
- when :blue
124
+ elsif color == :blue
86
125
  @color_code = USPSFlags::Config::BLUE
87
126
  @field_color_code = "#FFFFFF"
127
+ elsif color == :white && field_color == :red
128
+ @field_color_code = USPSFlags::Config::RED
129
+ elsif color == :white && field_color == :blue
130
+ @field_color_code = USPSFlags::Config::BLUE
88
131
  end
89
132
  end
90
133
 
91
- def svg
92
- svg = case @type
93
- when :d
94
- "<g mask=\"url(#delta-mask)\">"
95
- when :stf
96
- "<g mask=\"url(#circle-mask-for-main-spike)\">"
97
- else
98
- ""
99
- end
100
-
101
- @trident_segments.each do |segment|
102
- start = segment.keys.first
103
- points = segment.values.first
104
- svg << "<path d=\"M #{start[0]} #{start[1]}\n"
105
- points.each do |x, y|
106
- svg << "l #{x} #{y}\n"
107
- end
108
- svg << "\" fill=\"#{@color_code}\" />\n"
109
- end
110
- svg << "</g>" if [:d, :stf].include?(@type)
134
+ def delta_hash
135
+ <<~SVG
136
+ <polyline mask="url(#delta-mask)" fill="#{@color_code}" points="
137
+ #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}
138
+ #{@trident_config[:center_point] + @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
139
+ #{@trident_config[:center_point] - @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
140
+ #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}" />
141
+ <mask id="delta-mask">
142
+ <g>
143
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
144
+ <polyline transform="scale(#{@trident_config[:delta_gap_scale]}) translate(#{@trident_config[:delta_gap_x]},#{@trident_config[:delta_gap_y]})" fill="#000000" points="
145
+ #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}
146
+ #{@trident_config[:center_point] + @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
147
+ #{@trident_config[:center_point] - @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
148
+ #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}" />
149
+ </g>
150
+ </mask>
151
+ SVG
152
+ end
111
153
 
112
- if @type == :d
113
- # Delta hash
114
- svg << <<~SVG
115
- <polyline mask="url(#delta-mask)" fill="#{@color_code}" points="
116
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}
117
- #{@trident_config[:center_point] + @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
118
- #{@trident_config[:center_point] - @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
119
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}" />
120
- <mask id="delta-mask">
121
- <g>
122
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
123
- <polyline transform="scale(#{@trident_config[:delta_gap_scale]}) translate(#{@trident_config[:delta_gap_x]},#{@trident_config[:delta_gap_y]})" fill="#000000" points="
124
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}
125
- #{@trident_config[:center_point] + @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
126
- #{@trident_config[:center_point] - @trident_config[:width]/2}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom]}
127
- #{@trident_config[:center_point]}, #{@top_point + @trident_config[:height][:d] - @trident_config[:delta_from_bottom] - @trident_config[:delta_height]}" />
128
- </g>
129
- </mask>
130
- SVG
131
- elsif @type == :stf
132
- # Circle hash
133
- svg << <<~SVG
134
- <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width]/2}" fill="#{@color_code}" mask="url(#circle-mask)" />
135
- <mask id="circle-mask">
136
- <g>
137
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
138
- <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width]/2-@trident_config[:bar_width]}" fill="#000000" />
139
- </g>
140
- </mask>
141
- <mask id="circle-mask-for-main-spike">
142
- <g transform="scale(1.05) translate(-@trident_config[:br_width], -@trident_config[:br_width]/2)">
143
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
144
- <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width]/2-@trident_config[:bar_width]}" fill="#000000" />
145
- </g>
146
- </mask>
147
- SVG
148
- else
149
- # Standard hash
150
- svg << "<path d=\"M #{(@trident_config[:center_point] - @trident_config[:hash_width]/2)} #{(@top_point + @hash_from_top)}\n"
151
- @lower_hash.each do |x, y|
152
- svg << "l #{x} #{y}\n"
153
- end
154
- svg << "\" fill=\"#{@color_code}\" />\n"
154
+ def circle_hash
155
+ <<~SVG
156
+ <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width]/2}" fill="#{@color_code}" mask="url(#circle-mask)" />
157
+ <mask id="circle-mask">
158
+ <g>
159
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
160
+ <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width]/2-@trident_config[:bar_width]}" fill="#000000" />
161
+ </g>
162
+ </mask>
163
+ <mask id="circle-mask-for-main-spike">
164
+ <g transform="scale(1.05) translate(-@trident_config[:br_width], -@trident_config[:br_width]/2)">
165
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
166
+ <circle cx="#{@trident_config[:center_point]}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width]/2-@trident_config[:bar_width]}" fill="#000000" />
167
+ </g>
168
+ </mask>
169
+ SVG
170
+ end
155
171
 
156
- # # V/C crossing, marks @ 15/32 up
157
- # vc_cross_marker = USPSFlags::Config::BASE_HOIST*7/8-(USPSFlags::Config::BASE_HOIST/8+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]*3)*15/32
158
- # svg << "<line x1=\"#{USPSFlags::Config::BASE_FLY*3/8}\" x2=\"#{USPSFlags::Config::BASE_FLY*5/8}\" y1=\"#{vc_cross_marker}\" y2=\"#{vc_cross_marker}\" stroke=\"black\" stroke-width=\"#{USPSFlags::Config::BASE_FLY/600}\" />"
159
- # # C/C crossing, marks @ 1/3 up
160
- # cc_cross_marker = USPSFlags::Config::BASE_HOIST*7/8-(USPSFlags::Config::BASE_HOIST/8+@trident_config[:crossbar_from_top]+@trident_config[:bar_width]*3)*1/3
161
- # svg << "<line x1=\"#{USPSFlags::Config::BASE_FLY*3/8}\" x2=\"#{USPSFlags::Config::BASE_FLY*5/8}\" y1=\"#{cc_cross_marker}\" y2=\"#{cc_cross_marker}\" stroke=\"black\" stroke-width=\"#{USPSFlags::Config::BASE_FLY/600}\" />"
162
- end
172
+ def standard_hash
173
+ svg = "<path d=\"M #{(@trident_config[:center_point] - @trident_config[:hash_width]/2)} #{(@top_point + @hash_from_top)}\n"
174
+ @lower_hash.each { |x, y| svg << "l #{x} #{y}\n" }
175
+ svg << "\" fill=\"#{@color_code}\" />\n"
163
176
 
164
177
  svg
165
178
  end