usps_flags 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
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,60 +4,70 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::Headers
8
- def initialize(width: nil, height: nil, pennant: false, scale: nil, title: 'USPS Flag')
9
- @width = width
10
- @height = height
11
- @title = title
12
- scale ||= 3
13
- @generated_at = Time.now.strftime('%Y%m%d.%H%S%z')
14
-
15
- return no_sizes(scale, pennant) if @width.nil? || @height.nil?
16
-
17
- @view_width = width * scale
18
- @view_height = height * scale
19
- end
7
+ class USPSFlags
8
+ class Core
9
+ class Headers
10
+ def initialize(width: nil, height: nil, pennant: false, scale: nil, title: 'USPS Flag')
11
+ @width = width
12
+ @height = height
13
+ @title = title
14
+ scale ||= 3
15
+ @generated_at = Time.now.strftime('%Y%m%d.%H%S%z')
20
16
 
21
- def svg
22
- svg = +''
23
- svg << header_top
24
- svg << trademark unless @title == 'US Ensign'
25
- svg << '</metadata>'
17
+ if @width.nil? || @height.nil?
18
+ no_sizes(scale, pennant)
19
+ else
20
+ set_view_size(width, height, scale)
21
+ end
22
+ end
26
23
 
27
- svg
28
- end
24
+ def svg
25
+ svg = +''
26
+ svg << header_top
27
+ svg << trademark unless @title == 'US Ensign'
28
+ svg << '</metadata>'
29
29
 
30
- private
30
+ svg
31
+ end
31
32
 
32
- def no_sizes(scale, pennant)
33
- @width = USPSFlags::Config::BASE_FLY / scale
34
- @height = (@width * Rational(2, 3)).to_i
35
- @view_width = USPSFlags::Config::BASE_FLY
36
- @view_height = USPSFlags::Config::BASE_HOIST
37
- set_pennant_height(@height) if pennant
38
- end
33
+ private
39
34
 
40
- def set_pennant_height(height)
41
- @height = height / 4
42
- @view_height = USPSFlags::Config::BASE_HOIST / 4
43
- end
35
+ def no_sizes(scale, pennant)
36
+ @width = USPSFlags::Config::BASE_FLY / scale
37
+ @height = (@width * Rational(2, 3)).to_i
38
+ @view_width = USPSFlags::Config::BASE_FLY
39
+ @view_height = USPSFlags::Config::BASE_HOIST
40
+ set_pennant_height(@height) if pennant
41
+ end
44
42
 
45
- def header_top
46
- <<~SVG
47
- <?xml version="1.0" standalone="no"?>
48
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
49
- <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">
50
- <title>#{@title}</title>
51
- <metadata>
52
- <desc id="created-by">Julian Fiander</desc>
53
- <desc id="generated-at">#{@generated_at}</desc>
54
- SVG
55
- end
43
+ def set_pennant_height(height)
44
+ @height = height / 4
45
+ @view_height = USPSFlags::Config::BASE_HOIST / 4
46
+ end
47
+
48
+ def set_view_size(width, height, scale)
49
+ @view_width = width * scale
50
+ @view_height = height * scale
51
+ end
52
+
53
+ def header_top
54
+ <<~SVG
55
+ <?xml version="1.0" standalone="no"?>
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">
58
+ <title>#{@title}</title>
59
+ <metadata>
60
+ <desc id="created-by">Julian Fiander</desc>
61
+ <desc id="generated-at">#{@generated_at}</desc>
62
+ SVG
63
+ end
56
64
 
57
- def trademark
58
- <<~SVG
59
- <desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
60
- <desc id="trademark-link">https://www.usps.org/images/secretary/itcom/trademark.pdf</desc>
61
- SVG
65
+ def trademark
66
+ <<~SVG
67
+ <desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
68
+ <desc id="trademark-link">https://www.usps.org/images/secretary/itcom/trademark.pdf</desc>
69
+ SVG
70
+ end
71
+ end
62
72
  end
63
73
  end
@@ -4,11 +4,15 @@
4
4
  #
5
5
  # These methods should never need to be called directly.
6
6
  # @private
7
- module USPSFlags::Core::Icons
8
- require 'usps_flags/core/icons/anchor'
9
- require 'usps_flags/core/icons/binoculars'
10
- require 'usps_flags/core/icons/lighthouse'
11
- require 'usps_flags/core/icons/star'
12
- require 'usps_flags/core/icons/trident'
13
- require 'usps_flags/core/icons/trumpet'
7
+ class USPSFlags
8
+ class Core
9
+ module Icons
10
+ require 'usps_flags/core/icons/anchor'
11
+ require 'usps_flags/core/icons/binoculars'
12
+ require 'usps_flags/core/icons/lighthouse'
13
+ require 'usps_flags/core/icons/star'
14
+ require 'usps_flags/core/icons/trident'
15
+ require 'usps_flags/core/icons/trumpet'
16
+ end
17
+ end
14
18
  end
@@ -4,63 +4,69 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::Icons::Anchor
8
- def initialize(color: :red)
9
- @color_code = case color
10
- when :red
11
- USPSFlags::Config::RED
12
- when :white
13
- '#FFFFFF'
14
- end
15
- end
7
+ class USPSFlags
8
+ class Core
9
+ module Icons
10
+ class Anchor
11
+ def initialize(color: :red)
12
+ @color_code = case color
13
+ when :red
14
+ USPSFlags::Config::RED
15
+ when :white
16
+ '#FFFFFF'
17
+ end
18
+ end
16
19
 
17
- def svg
18
- <<~SVG
19
- <mask id="anchor-mask">
20
- <g>
21
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
22
- <path fill="#000000" d="M1252.3076435897437 462.05128846153843
23
- c-55.62957153846173-45.08196512820513-96.39672312820517 23.744812948717993-88.20503230769259 51.79489025641044 6.653223282051158 27.53726679487147 50.02959307692299 72.62890461538461 98.46155051282062 25.641023846153644-27.978308974358924-21.85968564102552-43.491535897435824-37.83963128205124-8.717984871794897-76.4102912820511
24
- M1270.7816162109375 632.2105102539062
25
- c11.54851016276666-6.899249317733052 39.425036990907756-18.726567019718118 51.28209197215574-38.46155724158655 18.5237216479145 6.418855931977646 41.891453418341825 56.769453150028085 42.05127579126565 78.97439966446314-44.455562242460246.1536644631529498-70.91589675334876-3.7750424355801897-92.82043457031227-4.102564102564088-.3660762785023053-20.3275216669839.4958814355788945-14.34922979993803-.5129331931091201-35.3846435546875
26
- M1271.807373046875 800.9284542768429
27
- c17.452943326530885-.46905043663332435 38.66574607901384-1.5444581957890477 72.82039701021631-2.051257011217899 19.28285605940755 11.288072979443086-54.75933644042357 64.92938750941744-76.92296424278834 66.15380859375-2.1636278023652267-19.80121994130843.7052539023432018-33.79374165575666-.00010016025635195547-64.61535801031664
28
- M1189.4276123046875 1008.6016845703125
29
- c2.974817410010928 29.162871686922244.9565995146047044 90.80892096853563-5.128155048076906 121.53843336838918-40.443728921655975-2.6038209334792555-89.68029403366631-82.60878014049194 3.0768291766826223-122.05126170622987
30
- M1322.38818359375 1290.0933837890625
31
- c19.593626045193105-1.2347605841421228 95.16059107098704 40.021664246269665 96.4102783203125 68.718017578125-14.134928135289783 16.901481536983738-35.666444420437074 27.636734330172885-47.17954351963135 29.743511493389406-22.282329868425222-9.688094631655076-55.15658121378351-81.19370160837752-50.256350786258054-97.4358097956731" />
32
- </g>
33
- </mask>
20
+ def svg
21
+ <<~SVG
22
+ <mask id="anchor-mask">
23
+ <g>
24
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
25
+ <path fill="#000000" d="M1252.3076435897437 462.05128846153843
26
+ c-55.62957153846173-45.08196512820513-96.39672312820517 23.744812948717993-88.20503230769259 51.79489025641044 6.653223282051158 27.53726679487147 50.02959307692299 72.62890461538461 98.46155051282062 25.641023846153644-27.978308974358924-21.85968564102552-43.491535897435824-37.83963128205124-8.717984871794897-76.4102912820511
27
+ M1270.7816162109375 632.2105102539062
28
+ c11.54851016276666-6.899249317733052 39.425036990907756-18.726567019718118 51.28209197215574-38.46155724158655 18.5237216479145 6.418855931977646 41.891453418341825 56.769453150028085 42.05127579126565 78.97439966446314-44.455562242460246.1536644631529498-70.91589675334876-3.7750424355801897-92.82043457031227-4.102564102564088-.3660762785023053-20.3275216669839.4958814355788945-14.34922979993803-.5129331931091201-35.3846435546875
29
+ M1271.807373046875 800.9284542768429
30
+ c17.452943326530885-.46905043663332435 38.66574607901384-1.5444581957890477 72.82039701021631-2.051257011217899 19.28285605940755 11.288072979443086-54.75933644042357 64.92938750941744-76.92296424278834 66.15380859375-2.1636278023652267-19.80121994130843.7052539023432018-33.79374165575666-.00010016025635195547-64.61535801031664
31
+ M1189.4276123046875 1008.6016845703125
32
+ c2.974817410010928 29.162871686922244.9565995146047044 90.80892096853563-5.128155048076906 121.53843336838918-40.443728921655975-2.6038209334792555-89.68029403366631-82.60878014049194 3.0768291766826223-122.05126170622987
33
+ M1322.38818359375 1290.0933837890625
34
+ c19.593626045193105-1.2347605841421228 95.16059107098704 40.021664246269665 96.4102783203125 68.718017578125-14.134928135289783 16.901481536983738-35.666444420437074 27.636734330172885-47.17954351963135 29.743511493389406-22.282329868425222-9.688094631655076-55.15658121378351-81.19370160837752-50.256350786258054-97.4358097956731" />
35
+ </g>
36
+ </mask>
34
37
 
35
- <path mask="url(#anchor-mask)" fill="#{@color_code}" d="M1182.0512562460422,634.8718105128619
36
- c-127.50414031806645,-57.87980084448043,-98.33494194360924,-157.05652261543366,-81.0255763281848,-194.8718025641362
37
- c38.84781387183102,-83.96914338466655,157.00304879489136,-82.85448702564872,195.89744384618598,-47.17948923074607
38
- c24.53542477435849,21.316034000046102,60.18456838981683,51.05085879482306,57.435807435916786,113.84615205126914
39
- c73.14866787698952,76.12863520509234,71.40198169752557,88.51520500000265,97.43599743583059,173.33334102563083
40
- c98.8545389450071,4.818131232624637,99.55414898847789,104.61193489364757,-8.205124358939429,109.74356999999225
41
- c-25.708004789625875,64.61882453844396,-67.14435745637093,120.94832935895647,-172.3077023077326,169.2307871794976
42
- c-2.5992382255190023,70.84656448715225,13.776934159119264,186.8525220513062,24.61535871798901,234.8717266666564
43
- c65.19738749240719,10.070483589747028,154.51026231285846,61.984337666644706,189.74357649238618,111.79495410250729
44
- c8.566643512772089,-9.676561051226827,56.736362820500744,-40.8957688974217,57.43582615383093,-78.97439564107322
45
- c-40.32617769227136,-22.694017358868905,-46.757061615423254,-10.478899461467563,-109.74353110771835,-21.53839897424041
46
- c42.65456538984108,-37.726172794888726,207.59033528726195,-161.09545651288613,250.25639615380942,-265.6410794871937
47
- c59.076290040109825,88.27497837399585,71.65445633351851,324.2269786926548,-2.051314102583092,434.871755473455
48
- c-10.116031236063236,-44.227132350911916,-43.09869935336155,-84.09163111133012,-55.38462128203264,-96.41016701191643
49
- c-29.72181832173783,50.24559976029536,-81.95636499161674,115.57349732649573,-102.56403256410249,133.33330897435894
50
- c28.623098711290822,72.11880743166671,-7.261530212306525,225.5893488434565,-68.71791375372572,185.6409501984151
51
- c-49.148681325965754,-15.333037922763424,18.549622107753976,-115.55505291498798,-7.1795841949922306,-107.69228609585093
52
- c-34.95998148195349,19.14481910912764,-167.90750204829328,129.20795509976756,-209.2307092307692,137.43596153846147
53
- c-134.6565200483485,-54.336144923914844,-317.1862187488996,-216.49730227173723,-389.7436059656784,-330.25645686152825
54
- c-38.71123409937445,37.01014857710106,-36.91255822003268,64.9171844290704,-48.205166417233386,92.30767560666914
55
- c-55.39517986825638,-51.583890538004425,-94.67406936751138,-281.75614280779905,-29.74354259488905,-429.7435328612896
56
- c18.77666857831457,47.91013041235192,164.53935578109724,200.61765517975073,269.7436206767652,257.4359318084928
57
- c-64.02654995017485,6.5618535897069705,-112.85686466785285,11.954077594442651,-115.8975015964005,26.666604615348206
58
- c13.369607980979595,27.020215106261958,110.16860728422273,133.64035296812426,184.61540871794875,151.7948817948718
59
- c38.54936064125013,-35.17882824956223,61.75817892673331,-120.13381382049238,62.564074222199,-170.2563782051027
60
- c-112.01461673846143,-68.58411333497293,-195.4475277093784,-202.73504102566642,21.538517829083048,-313.8462020513076
61
- c-0.44986397943876,-39.31628256413069,3.6634418754476883,-100.03343099000347,-4.10254271451231,-111.79488372654134
62
- c-172.89423135404945,-4.5819764834471925,-241.96276383285397,15.050453377662961,-246.15389305299936,-45.1281958802341
63
- c-1.1141929951265865,-65.30684495420007,65.9235006844765,-60.74779963470837,241.02560210253228,-73.84616725825663" />
64
- SVG
38
+ <path mask="url(#anchor-mask)" fill="#{@color_code}" d="M1182.0512562460422,634.8718105128619
39
+ c-127.50414031806645,-57.87980084448043,-98.33494194360924,-157.05652261543366,-81.0255763281848,-194.8718025641362
40
+ c38.84781387183102,-83.96914338466655,157.00304879489136,-82.85448702564872,195.89744384618598,-47.17948923074607
41
+ c24.53542477435849,21.316034000046102,60.18456838981683,51.05085879482306,57.435807435916786,113.84615205126914
42
+ c73.14866787698952,76.12863520509234,71.40198169752557,88.51520500000265,97.43599743583059,173.33334102563083
43
+ c98.8545389450071,4.818131232624637,99.55414898847789,104.61193489364757,-8.205124358939429,109.74356999999225
44
+ c-25.708004789625875,64.61882453844396,-67.14435745637093,120.94832935895647,-172.3077023077326,169.2307871794976
45
+ c-2.5992382255190023,70.84656448715225,13.776934159119264,186.8525220513062,24.61535871798901,234.8717266666564
46
+ c65.19738749240719,10.070483589747028,154.51026231285846,61.984337666644706,189.74357649238618,111.79495410250729
47
+ c8.566643512772089,-9.676561051226827,56.736362820500744,-40.8957688974217,57.43582615383093,-78.97439564107322
48
+ c-40.32617769227136,-22.694017358868905,-46.757061615423254,-10.478899461467563,-109.74353110771835,-21.53839897424041
49
+ c42.65456538984108,-37.726172794888726,207.59033528726195,-161.09545651288613,250.25639615380942,-265.6410794871937
50
+ c59.076290040109825,88.27497837399585,71.65445633351851,324.2269786926548,-2.051314102583092,434.871755473455
51
+ c-10.116031236063236,-44.227132350911916,-43.09869935336155,-84.09163111133012,-55.38462128203264,-96.41016701191643
52
+ c-29.72181832173783,50.24559976029536,-81.95636499161674,115.57349732649573,-102.56403256410249,133.33330897435894
53
+ c28.623098711290822,72.11880743166671,-7.261530212306525,225.5893488434565,-68.71791375372572,185.6409501984151
54
+ c-49.148681325965754,-15.333037922763424,18.549622107753976,-115.55505291498798,-7.1795841949922306,-107.69228609585093
55
+ c-34.95998148195349,19.14481910912764,-167.90750204829328,129.20795509976756,-209.2307092307692,137.43596153846147
56
+ c-134.6565200483485,-54.336144923914844,-317.1862187488996,-216.49730227173723,-389.7436059656784,-330.25645686152825
57
+ c-38.71123409937445,37.01014857710106,-36.91255822003268,64.9171844290704,-48.205166417233386,92.30767560666914
58
+ c-55.39517986825638,-51.583890538004425,-94.67406936751138,-281.75614280779905,-29.74354259488905,-429.7435328612896
59
+ c18.77666857831457,47.91013041235192,164.53935578109724,200.61765517975073,269.7436206767652,257.4359318084928
60
+ c-64.02654995017485,6.5618535897069705,-112.85686466785285,11.954077594442651,-115.8975015964005,26.666604615348206
61
+ c13.369607980979595,27.020215106261958,110.16860728422273,133.64035296812426,184.61540871794875,151.7948817948718
62
+ c38.54936064125013,-35.17882824956223,61.75817892673331,-120.13381382049238,62.564074222199,-170.2563782051027
63
+ c-112.01461673846143,-68.58411333497293,-195.4475277093784,-202.73504102566642,21.538517829083048,-313.8462020513076
64
+ c-0.44986397943876,-39.31628256413069,3.6634418754476883,-100.03343099000347,-4.10254271451231,-111.79488372654134
65
+ c-172.89423135404945,-4.5819764834471925,-241.96276383285397,15.050453377662961,-246.15389305299936,-45.1281958802341
66
+ c-1.1141929951265865,-65.30684495420007,65.9235006844765,-60.74779963470837,241.02560210253228,-73.84616725825663" />
67
+ SVG
68
+ end
69
+ end
70
+ end
65
71
  end
66
72
  end
@@ -4,21 +4,27 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::Icons::Binoculars
8
- def initialize(type: :d)
9
- @color = case type
10
- when :d
11
- USPSFlags::Config::RED
12
- when :n
13
- USPSFlags::Config::BLUE
14
- end
15
- end
7
+ class USPSFlags
8
+ class Core
9
+ module Icons
10
+ class Binoculars
11
+ def initialize(type: :d)
12
+ @color = case type
13
+ when :d
14
+ USPSFlags::Config::RED
15
+ when :n
16
+ USPSFlags::Config::BLUE
17
+ end
18
+ end
16
19
 
17
- def svg
18
- <<~SVG
19
- <polyline fill="#{@color}" points="700 1500 760 600 825 600 825 540 760 540 760 480 1030 480 1030 540 965 540 965 600 1030 600 1090 1500" />
20
- <polyline fill="#{@color}" transform="translate(660)" points="700 1500 760 600 825 600 825 540 760 540 760 480 1030 480 1030 540 965 540 965 600 1030 600 1090 1500" />
21
- <polyline fill="#{@color}" points="1000 690 1150 690 1150 660 1300 660 1300 690 1450 690 1450 740 1275 740 1275 1380 1390 1380 1390 1430 1060 1430 1060 1380 1175 1380 1175 740 1000 740"/>
22
- SVG
20
+ def svg
21
+ <<~SVG
22
+ <polyline fill="#{@color}" points="700 1500 760 600 825 600 825 540 760 540 760 480 1030 480 1030 540 965 540 965 600 1030 600 1090 1500" />
23
+ <polyline fill="#{@color}" transform="translate(660)" points="700 1500 760 600 825 600 825 540 760 540 760 480 1030 480 1030 540 965 540 965 600 1030 600 1090 1500" />
24
+ <polyline fill="#{@color}" points="1000 690 1150 690 1150 660 1300 660 1300 690 1450 690 1450 740 1275 740 1275 1380 1390 1380 1390 1430 1060 1430 1060 1380 1175 1380 1175 740 1000 740"/>
25
+ SVG
26
+ end
27
+ end
28
+ end
23
29
  end
24
30
  end
@@ -4,28 +4,34 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::Icons::Lighthouse
8
- def svg
9
- <<~SVG
10
- <mask id="lighthouse-mask">
11
- <g>
12
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
13
- <rect x="1150" y="540" fill="#000000" width="80" height="140" />
14
- <rect x="1270" y="540" fill="#000000" width="80" height="140" />
15
- <polyline fill="#000000" points="1065 690 1065 725 1075 725 1095 710 1095 690" />
16
- <polyline fill="#000000" points="1405 690 1435 690 1435 725 1425 725 1405 710" />
17
- <polyline fill="#000000" points="1065 760 1065 790 1085 775 1085 760" />
18
- <polyline fill="#000000" points="1435 760 1415 760 1415 775 1435 790" />
19
- </g>
20
- </mask>
7
+ class USPSFlags
8
+ class Core
9
+ module Icons
10
+ class Lighthouse
11
+ def svg
12
+ <<~SVG
13
+ <mask id="lighthouse-mask">
14
+ <g>
15
+ <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
16
+ <rect x="1150" y="540" fill="#000000" width="80" height="140" />
17
+ <rect x="1270" y="540" fill="#000000" width="80" height="140" />
18
+ <polyline fill="#000000" points="1065 690 1065 725 1075 725 1095 710 1095 690" />
19
+ <polyline fill="#000000" points="1405 690 1435 690 1435 725 1425 725 1405 710" />
20
+ <polyline fill="#000000" points="1065 760 1065 790 1085 775 1085 760" />
21
+ <polyline fill="#000000" points="1435 760 1415 760 1415 775 1435 790" />
22
+ </g>
23
+ </mask>
21
24
 
22
- <g mask="url(#lighthouse-mask)">
23
- <polyline fill="#{USPSFlags::Config::RED}" points="1100 475 1100 450 1200 400 1200 350 1300 350 1300 400 1400 450 1400 475" />
24
- <polyline fill="#{USPSFlags::Config::RED}" points="1050 800 1050 675 1100 675 1100 500 1400 500 1400 675 1450 675 1450 800" />
25
- <polyline fill="#{USPSFlags::Config::RED}" points="1050 825 1075 875 1425 875 1450 825" />
26
- <polyline fill="#{USPSFlags::Config::RED}" points="900 1500 1075 900 1425 900 1600 1500" />
27
- <polyline fill="#{USPSFlags::Config::RED}" points="900 1525 925 1575 1575 1575 1600 1525" />
28
- </g>
29
- SVG
25
+ <g mask="url(#lighthouse-mask)">
26
+ <polyline fill="#{USPSFlags::Config::RED}" points="1100 475 1100 450 1200 400 1200 350 1300 350 1300 400 1400 450 1400 475" />
27
+ <polyline fill="#{USPSFlags::Config::RED}" points="1050 800 1050 675 1100 675 1100 500 1400 500 1400 675 1450 675 1450 800" />
28
+ <polyline fill="#{USPSFlags::Config::RED}" points="1050 825 1075 875 1425 875 1450 825" />
29
+ <polyline fill="#{USPSFlags::Config::RED}" points="900 1500 1075 900 1425 900 1600 1500" />
30
+ <polyline fill="#{USPSFlags::Config::RED}" points="900 1525 925 1575 1575 1575 1600 1525" />
31
+ </g>
32
+ SVG
33
+ end
34
+ end
35
+ end
30
36
  end
31
37
  end
@@ -4,23 +4,29 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::Icons::Star
8
- def svg
9
- svg = "<path d=\"M 0 0\n"
10
- points.each { |x, y| svg << "l #{x} #{y}\n" }
11
- svg << "\" fill=\"#FFFFFF\" />\n"
7
+ class USPSFlags
8
+ class Core
9
+ module Icons
10
+ class Star
11
+ def svg
12
+ svg = "<path d=\"M 0 0\n"
13
+ points.each { |x, y| svg << "l #{x} #{y}\n" }
14
+ svg << "\" fill=\"#FFFFFF\" />\n"
12
15
 
13
- svg
14
- end
16
+ svg
17
+ end
15
18
 
16
- private
19
+ private
17
20
 
18
- def points
19
- [
20
- [117.555, 81.805], [-41.47, -137.085], [114.125, -86.525],
21
- [-143.185, -2.915], [-47.025, -135.28], [-47.025, 135.28],
22
- [-143.185, 2.915], [114.125, 86.525], [-41.47, 137.085],
23
- [117.555, -81.805]
24
- ]
21
+ def points
22
+ [
23
+ [117.555, 81.805], [-41.47, -137.085], [114.125, -86.525],
24
+ [-143.185, -2.915], [-47.025, -135.28], [-47.025, 135.28],
25
+ [-143.185, 2.915], [114.125, 86.525], [-41.47, 137.085],
26
+ [117.555, -81.805]
27
+ ]
28
+ end
29
+ end
30
+ end
25
31
  end
26
32
  end
@@ -4,133 +4,142 @@
4
4
  #
5
5
  # This class should never need to be called directly.
6
6
  # @private
7
- class USPSFlags::Core::Icons::Trident
8
- require 'usps_flags/core/icons/trident_parts/hashes'
9
- include USPSFlags::Core::Icons::TridentParts::Hashes
10
-
11
- def initialize(type, color: :blue, field_color: nil)
12
- valid_types = [:s, :d, :stf, :n]
13
- raise "Error: Invalid trident type. Options are #{valid_types}." unless valid_types.include?(type)
14
-
15
- @type = type
16
-
17
- @trident_config = USPSFlags.configuration.trident
18
- load_measures
19
- load_measures_from_top
20
- load_main_length
21
- configure_trident_segments
22
- configure_colors(color, field_color)
23
- end
24
-
25
- def svg
26
- svg = +''
27
- svg << '<g mask="url(#delta-mask)">' if @type == :d
28
- svg << '<g mask="url(#circle-mask-for-main-spike)">' if @type == :stf
29
- @trident_segments.each { |seg| svg << add_trident_segment(seg) }
30
- svg << '</g>' if [:d, :stf].include?(@type)
31
- svg << add_hash
32
-
33
- svg
34
- end
35
-
36
- private
37
-
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
56
- @main_spike_overhang = @trident_config[:bar_width] / 2
57
- @side_spike_overhang = @trident_config[:bar_width] / 2
58
- @top_point = ((USPSFlags::Config::BASE_HOIST - @trident_config[:height][@type]) / 2)
59
- end
60
-
61
- def load_measures_from_top
62
- @crossbar_top = @top_point + @trident_config[:crossbar_from_top]
63
- @hash_from_top = @trident_config[:crossbar_from_top] + (@trident_config[:bar_width] * 2)
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
68
- @main_length = @trident_config[:height][@type] - (@trident_config[:center_point_height] - @trident_config[:main_point_barb])
69
- end
70
-
71
- def configure_trident_segments
72
- @trident_segments = [main_spike, crossbar, left_spike, right_spike]
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
- ]
77
- end
78
-
79
- def main_spike
80
- {
81
- [@trident_config[:center_point], @top_point] =>
82
- [
83
- [@trident_config[:bar_width], @trident_config[:center_point_height]],
84
- [-@main_spike_overhang, -@trident_config[:main_point_barb]],
85
- [0, @main_length], [-(@trident_config[:bar_width]), 0], [0, -@main_length],
86
- [-@main_spike_overhang, @trident_config[:main_point_barb]],
87
- [@trident_config[:bar_width], -@trident_config[:center_point_height]]
88
- ]
89
- }
90
- end
91
-
92
- def crossbar
93
- {
94
- [(@trident_config[:center_point] - @trident_config[:width] / 2), (@crossbar_top)] =>
95
- [
96
- [@trident_config[:width], 0], [0, @trident_config[:bar_width]],
97
- [-@trident_config[:width], 0], [0, -@trident_config[:bar_width]]
98
- ]
99
- }
100
- end
101
-
102
- def left_spike
103
- {
104
- [(@trident_config[:center_point] - @trident_config[:width] / 2), (@crossbar_top + 1)] =>
105
- [
106
- [0, -(@trident_config[:side_spike_height] + @trident_config[:side_point_height])],
107
- [(@trident_config[:bar_width] + @side_spike_overhang), @trident_config[:side_point_height]],
108
- [-@side_spike_overhang, 0], [0, @trident_config[:side_spike_height]]
109
- ]
110
- }
111
- end
112
-
113
- def right_spike
114
- {
115
- [(@trident_config[:center_point] + @trident_config[:width] / 2), (@crossbar_top + 1)] =>
116
- [
117
- [0, -(@trident_config[:side_spike_height] + @trident_config[:side_point_height])],
118
- [-(@trident_config[:bar_width] + @side_spike_overhang), @trident_config[:side_point_height]],
119
- [@side_spike_overhang, 0], [0, @trident_config[:side_spike_height]]
120
- ]
121
- }
122
- end
123
-
124
- def configure_colors(color, field_color)
125
- @color_code = '#FFFFFF'
126
- if color == :red
127
- @color_code, @field_color_code = [USPSFlags::Config::RED, '#FFFFFF']
128
- elsif color == :blue
129
- @color_code, @field_color_code = [USPSFlags::Config::BLUE, '#FFFFFF']
130
- elsif field_color == :red
131
- @field_color_code = USPSFlags::Config::RED
132
- elsif field_color == :blue
133
- @field_color_code = USPSFlags::Config::BLUE
7
+ class USPSFlags
8
+ class Core
9
+ module Icons
10
+ class Trident
11
+ require 'usps_flags/core/icons/trident_parts/hashes'
12
+ include USPSFlags::Core::Icons::TridentParts::Hashes
13
+
14
+ def initialize(type, color: :blue, field_color: nil)
15
+ valid_types = %i[s d stf n]
16
+ raise "Error: Invalid trident type. Options are #{valid_types}." unless valid_types.include?(type)
17
+
18
+ @type = type
19
+
20
+ @trident_config = USPSFlags.configuration.trident
21
+ load_measures
22
+ load_measures_from_top
23
+ load_main_length
24
+ configure_trident_segments
25
+ configure_colors(color, field_color)
26
+ end
27
+
28
+ def svg
29
+ svg = +''
30
+ svg << '<g mask="url(#delta-mask)">' if @type == :d
31
+ svg << '<g mask="url(#circle-mask-for-main-spike)">' if @type == :stf
32
+ @trident_segments.each { |seg| svg << add_trident_segment(seg) }
33
+ svg << '</g>' if %i[d stf].include?(@type)
34
+ svg << add_hash
35
+
36
+ svg
37
+ end
38
+
39
+ private
40
+
41
+ def add_trident_segment(segment)
42
+ svg = +''
43
+ start = segment.keys.first
44
+ points = segment.values.first
45
+ svg << "<path d=\"M #{start[0]} #{start[1]}\n"
46
+ points.each { |x, y| svg << "l #{x} #{y}\n" }
47
+ svg << "\" fill=\"#{@color_code}\" />\n"
48
+ svg
49
+ end
50
+
51
+ def add_hash
52
+ return delta_hash if @type == :d
53
+ return circle_hash if @type == :stf
54
+
55
+ standard_hash
56
+ end
57
+
58
+ def load_measures
59
+ @main_spike_overhang = @trident_config[:bar_width] / 2
60
+ @side_spike_overhang = @trident_config[:bar_width] / 2
61
+ @top_point = ((USPSFlags::Config::BASE_HOIST - @trident_config[:height][@type]) / 2)
62
+ end
63
+
64
+ def load_measures_from_top
65
+ @crossbar_top = @top_point + @trident_config[:crossbar_from_top]
66
+ @hash_from_top = @trident_config[:crossbar_from_top] + (@trident_config[:bar_width] * 2)
67
+
68
+ height = @trident_config[:bar_width] * 123 / 128 + @trident_config[:width] / 2
69
+ @circle_from_top = @trident_config[:crossbar_from_top] + height
70
+ end
71
+
72
+ def load_main_length
73
+ point = @trident_config[:center_point_height] - @trident_config[:main_point_barb]
74
+ @main_length = @trident_config[:height][@type] - point
75
+ end
76
+
77
+ def configure_trident_segments
78
+ @trident_segments = [main_spike, crossbar, left_spike, right_spike]
79
+ @lower_hash = [
80
+ [@trident_config[:hash_width], 0], [0, @trident_config[:bar_width]],
81
+ [-@trident_config[:hash_width], 0], [0, -@trident_config[:bar_width]]
82
+ ]
83
+ end
84
+
85
+ def main_spike
86
+ {
87
+ [@trident_config[:center_point], @top_point] =>
88
+ [
89
+ [@trident_config[:bar_width], @trident_config[:center_point_height]],
90
+ [-@main_spike_overhang, -@trident_config[:main_point_barb]],
91
+ [0, @main_length], [-(@trident_config[:bar_width]), 0], [0, -@main_length],
92
+ [-@main_spike_overhang, @trident_config[:main_point_barb]],
93
+ [@trident_config[:bar_width], -@trident_config[:center_point_height]]
94
+ ]
95
+ }
96
+ end
97
+
98
+ def crossbar
99
+ {
100
+ [(@trident_config[:center_point] - @trident_config[:width] / 2), @crossbar_top] =>
101
+ [
102
+ [@trident_config[:width], 0], [0, @trident_config[:bar_width]],
103
+ [-@trident_config[:width], 0], [0, -@trident_config[:bar_width]]
104
+ ]
105
+ }
106
+ end
107
+
108
+ def left_spike
109
+ {
110
+ [(@trident_config[:center_point] - @trident_config[:width] / 2), (@crossbar_top + 1)] =>
111
+ [
112
+ [0, -(@trident_config[:side_spike_height] + @trident_config[:side_point_height])],
113
+ [(@trident_config[:bar_width] + @side_spike_overhang), @trident_config[:side_point_height]],
114
+ [-@side_spike_overhang, 0], [0, @trident_config[:side_spike_height]]
115
+ ]
116
+ }
117
+ end
118
+
119
+ def right_spike
120
+ {
121
+ [(@trident_config[:center_point] + @trident_config[:width] / 2), (@crossbar_top + 1)] =>
122
+ [
123
+ [0, -(@trident_config[:side_spike_height] + @trident_config[:side_point_height])],
124
+ [-(@trident_config[:bar_width] + @side_spike_overhang), @trident_config[:side_point_height]],
125
+ [@side_spike_overhang, 0], [0, @trident_config[:side_spike_height]]
126
+ ]
127
+ }
128
+ end
129
+
130
+ def configure_colors(color, field_color)
131
+ @color_code = '#FFFFFF'
132
+ if color == :red
133
+ @color_code, @field_color_code = [USPSFlags::Config::RED, '#FFFFFF']
134
+ elsif color == :blue
135
+ @color_code, @field_color_code = [USPSFlags::Config::BLUE, '#FFFFFF']
136
+ elsif field_color == :red
137
+ @field_color_code = USPSFlags::Config::RED
138
+ elsif field_color == :blue
139
+ @field_color_code = USPSFlags::Config::BLUE
140
+ end
141
+ end
142
+ end
134
143
  end
135
144
  end
136
145
  end