usps_flags 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/.travis.yml +1 -0
- data/Gemfile.lock +17 -1
- data/lib/usps_flags/config.rb +38 -33
- data/lib/usps_flags/core/ensign.rb +34 -26
- data/lib/usps_flags/core/field.rb +56 -39
- data/lib/usps_flags/core/headers.rb +34 -30
- data/lib/usps_flags/core/icons/star.rb +12 -18
- data/lib/usps_flags/core/icons/trident.rb +46 -93
- data/lib/usps_flags/core/icons/trident_parts/hashes.rb +69 -0
- data/lib/usps_flags/core/icons/trumpet.rb +14 -10
- data/lib/usps_flags/core/pennant.rb +25 -28
- data/lib/usps_flags/core/trident_specs/circle.rb +3 -3
- data/lib/usps_flags/core/trident_specs/delta.rb +4 -4
- data/lib/usps_flags/core/trident_specs/long.rb +2 -2
- data/lib/usps_flags/core/trident_specs/short.rb +13 -13
- data/lib/usps_flags/core/tridents.rb +1 -1
- data/lib/usps_flags/core/us.rb +14 -16
- data/lib/usps_flags/generate/flag.rb +53 -34
- data/lib/usps_flags/generate/private.rb +199 -0
- data/lib/usps_flags/generate.rb +37 -185
- data/lib/usps_flags/helpers/builders.rb +70 -35
- data/lib/usps_flags/helpers/spec_arrows.rb +76 -26
- data/lib/usps_flags/helpers/valid_flags.rb +55 -0
- data/lib/usps_flags/helpers.rb +15 -52
- data/spec/spec_helper.rb +1 -3
- data/spec/usps_flags/core_spec.rb +27 -25
- data/spec/usps_flags/generate_spec.rb +24 -10
- data/spec/usps_flags/helpers_spec.rb +10 -3
- data/spec/usps_flags_spec.rb +5 -4
- data/usps_flags.gemspec +3 -2
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b32e5fbfbb5d0d90e1f3f449e96b89c5d3d52de7a9ea6ae6a042609bb69665
|
4
|
+
data.tar.gz: c35ad25ec8df45961cbf57829109ad05eacba524daf1674751f2649322ad5479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 451d050441eb4de435dc9f4463d8fcbe04b9b58d17264ce5fac69dc60d1578597f91069ba536e75fe7ed44faaca64dde43cc5c07175fb386776373e0cb5ec5d7
|
7
|
+
data.tar.gz: 16fd6eaf1886833465bb5a8e16a25a70b1ff381447d90fda55117d402247bb6552669b20d6d0792842bcdb4cbf473d409edc8d87dfad48091ff196c7c488a404
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
usps_flags (0.
|
4
|
+
usps_flags (0.5.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)
|
@@ -9,11 +9,17 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
+
ast (2.4.0)
|
12
13
|
diff-lcs (1.3)
|
13
14
|
docile (1.1.5)
|
14
15
|
file_utils (1.1.2)
|
16
|
+
jaro_winkler (1.5.2)
|
15
17
|
json (2.1.0)
|
16
18
|
mini_magick (4.9.3)
|
19
|
+
parallel (1.17.0)
|
20
|
+
parser (2.6.3.0)
|
21
|
+
ast (~> 2.4.0)
|
22
|
+
rainbow (3.0.0)
|
17
23
|
rake (12.3.0)
|
18
24
|
rspec (3.7.0)
|
19
25
|
rspec-core (~> 3.7.0)
|
@@ -28,12 +34,21 @@ GEM
|
|
28
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
35
|
rspec-support (~> 3.7.0)
|
30
36
|
rspec-support (3.7.0)
|
37
|
+
rubocop (0.71.0)
|
38
|
+
jaro_winkler (~> 1.5.1)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 2.6)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
ruby-progressbar (~> 1.7)
|
43
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
44
|
+
ruby-progressbar (1.10.1)
|
31
45
|
rubyzip (1.2.3)
|
32
46
|
simplecov (0.15.1)
|
33
47
|
docile (~> 1.1.0)
|
34
48
|
json (>= 1.8, < 3)
|
35
49
|
simplecov-html (~> 0.10.0)
|
36
50
|
simplecov-html (0.10.2)
|
51
|
+
unicode-display_width (1.6.0)
|
37
52
|
|
38
53
|
PLATFORMS
|
39
54
|
ruby
|
@@ -41,6 +56,7 @@ PLATFORMS
|
|
41
56
|
DEPENDENCIES
|
42
57
|
rake (~> 12.2, >= 12.2.1)
|
43
58
|
rspec (~> 3.7, >= 3.7.0)
|
59
|
+
rubocop (~> 0.59, >= 0.59.2)
|
44
60
|
simplecov (~> 0.15, >= 0.15.1)
|
45
61
|
usps_flags!
|
46
62
|
|
data/lib/usps_flags/config.rb
CHANGED
@@ -30,40 +30,11 @@ class USPSFlags::Config
|
|
30
30
|
#
|
31
31
|
# @return [Hash] RThe configuration values for tridents.
|
32
32
|
def trident
|
33
|
-
center_point_height = USPSFlags::Config::BASE_FLY / 48 * 23 / 8
|
34
|
-
side_point_height = USPSFlags::Config::BASE_FLY / 48 * 21 / 8
|
35
|
-
bar_width = USPSFlags::Config::BASE_FLY / 48 * 5 / 4
|
36
33
|
{
|
37
|
-
height: trident_heights,
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
width: USPSFlags::Config::BASE_FLY * 5 / 32,
|
42
|
-
|
43
|
-
bar_width: bar_width,
|
44
|
-
|
45
|
-
center_point_height: center_point_height,
|
46
|
-
side_point_height: side_point_height,
|
47
|
-
|
48
|
-
main_point_barb: USPSFlags::Config::BASE_HOIST / 82,
|
49
|
-
|
50
|
-
crossbar_from_top: USPSFlags::Config::BASE_HOIST / 4 + bar_width / 5,
|
51
|
-
|
52
|
-
side_spike_height: USPSFlags::Config::BASE_HOIST / 4 - side_point_height - bar_width * 3 / 5,
|
53
|
-
|
54
|
-
hash_width: USPSFlags::Config::BASE_FLY * 47 / 528,
|
55
|
-
|
56
|
-
delta_height: USPSFlags::Config::BASE_FLY * 33 / 240,
|
57
|
-
delta_gap_height: USPSFlags::Config::BASE_FLY / 16,
|
58
|
-
delta_gap_width: bar_width * 5 / 4,
|
59
|
-
delta_width: USPSFlags::Config::BASE_FLY * 43 / 768,
|
60
|
-
delta_from_bottom: USPSFlags::Config::BASE_HOIST * 10 / 64,
|
61
|
-
delta_gap_scale: 0.40,
|
62
|
-
delta_gap_x: USPSFlags::Config::BASE_HOIST * 144 / 128,
|
63
|
-
delta_gap_y: USPSFlags::Config::BASE_HOIST * 221 / 256,
|
64
|
-
|
65
|
-
circle_height_adj: USPSFlags::Config::BASE_FLY / 800
|
66
|
-
}
|
34
|
+
height: trident_heights, center_point: BASE_FLY / 2,
|
35
|
+
width: USPSFlags::Config::BASE_FLY * 5 / 32, bar_width: bar_width,
|
36
|
+
hash_width: USPSFlags::Config::BASE_FLY * 47 / 528
|
37
|
+
}.merge(spikes_config).merge(delta_config).merge(circle_config)
|
67
38
|
end
|
68
39
|
|
69
40
|
# Height values for trident insignia.
|
@@ -100,4 +71,38 @@ private
|
|
100
71
|
@use_larger_tridents = true
|
101
72
|
@clear = false
|
102
73
|
end
|
74
|
+
|
75
|
+
def center_point_height
|
76
|
+
USPSFlags::Config::BASE_FLY / 48 * 23 / 8
|
77
|
+
end
|
78
|
+
|
79
|
+
def side_point_height
|
80
|
+
USPSFlags::Config::BASE_FLY / 48 * 21 / 8
|
81
|
+
end
|
82
|
+
|
83
|
+
def bar_width
|
84
|
+
USPSFlags::Config::BASE_FLY / 48 * 5 / 4
|
85
|
+
end
|
86
|
+
|
87
|
+
def spikes_config
|
88
|
+
{
|
89
|
+
center_point_height: center_point_height, side_point_height: side_point_height,
|
90
|
+
main_point_barb: USPSFlags::Config::BASE_HOIST / 82,
|
91
|
+
crossbar_from_top: USPSFlags::Config::BASE_HOIST / 4 + bar_width / 5,
|
92
|
+
side_spike_height: USPSFlags::Config::BASE_HOIST / 4 - side_point_height - bar_width * 3 / 5
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
def delta_config
|
97
|
+
{
|
98
|
+
delta_height: USPSFlags::Config::BASE_FLY * 33 / 240, delta_gap_height: USPSFlags::Config::BASE_FLY / 16,
|
99
|
+
delta_gap_width: bar_width * 5 / 4, delta_width: USPSFlags::Config::BASE_FLY * 43 / 768,
|
100
|
+
delta_from_bottom: USPSFlags::Config::BASE_HOIST * 10 / 64, delta_gap_scale: 0.40,
|
101
|
+
delta_gap_x: USPSFlags::Config::BASE_HOIST * 144 / 128, delta_gap_y: USPSFlags::Config::BASE_HOIST * 221 / 256
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def circle_config
|
106
|
+
{ circle_height_adj: USPSFlags::Config::BASE_FLY / 800 }
|
107
|
+
end
|
103
108
|
end
|
@@ -8,6 +8,7 @@ class USPSFlags::Core::Ensign
|
|
8
8
|
def svg
|
9
9
|
<<~SVG
|
10
10
|
#{stripes}
|
11
|
+
#{canton}
|
11
12
|
<g transform="scale(0.3675)">
|
12
13
|
<g transform="translate(1200, 600)">
|
13
14
|
<g transform="rotate(-45, 693, 1500)">
|
@@ -22,39 +23,46 @@ class USPSFlags::Core::Ensign
|
|
22
23
|
private
|
23
24
|
|
24
25
|
def stripes
|
26
|
+
(0..12).map do |index|
|
27
|
+
index.odd? ? white_stripe(index) : blue_stripe(index)
|
28
|
+
end.join
|
29
|
+
end
|
30
|
+
|
31
|
+
def canton
|
25
32
|
<<~SVG
|
26
|
-
<rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
27
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 1 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#FFFFFF" />
|
28
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 2 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
29
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 3 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#FFFFFF" />
|
30
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 4 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
31
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 5 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#FFFFFF" />
|
32
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 6 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
33
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 7 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#FFFFFF" />
|
34
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 8 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
35
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 9 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#FFFFFF" />
|
36
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 10 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
37
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 11 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#FFFFFF" />
|
38
|
-
<rect x="#{USPSFlags::Config::BASE_FLY * 12 / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
39
33
|
<rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY * 6 / 13}" height="1000" fill="#{USPSFlags::Config::RED}" />
|
40
34
|
SVG
|
41
|
-
|
35
|
+
end
|
36
|
+
|
37
|
+
def white_stripe(index)
|
38
|
+
<<~SVG
|
39
|
+
<rect x="#{USPSFlags::Config::BASE_FLY * index / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#FFFFFF" />
|
40
|
+
SVG
|
41
|
+
end
|
42
|
+
|
43
|
+
def blue_stripe(index)
|
44
|
+
<<~SVG
|
45
|
+
<rect x="#{USPSFlags::Config::BASE_FLY * index / 13}" y="0" width="#{USPSFlags::Config::BASE_FLY / 13}" height="#{USPSFlags::Config::BASE_HOIST}" fill="#{USPSFlags::Config::BLUE}" />
|
46
|
+
SVG
|
42
47
|
end
|
43
48
|
|
44
49
|
def star_circle
|
45
|
-
svg = ''
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
svg = +''
|
51
|
+
|
52
|
+
(0..13).each { |i| svg << rotated_star(i * (360.0 / 13)) }
|
53
|
+
|
54
|
+
svg
|
55
|
+
end
|
56
|
+
|
57
|
+
def rotated_star(rotation)
|
58
|
+
<<~SVG
|
59
|
+
<g transform="scale(0.375)">
|
60
|
+
<g transform="translate(1885, 465)">
|
61
|
+
<g transform="rotate(#{rotation}, 0, 900)">
|
62
|
+
#{USPSFlags::Core.star}
|
54
63
|
</g>
|
55
64
|
</g>
|
56
|
-
|
57
|
-
|
58
|
-
svg
|
65
|
+
</g>
|
66
|
+
SVG
|
59
67
|
end
|
60
68
|
end
|
@@ -8,24 +8,13 @@ class USPSFlags::Core::Field
|
|
8
8
|
def initialize(style: :regular, color: :white, fly: USPSFlags::Config::BASE_FLY)
|
9
9
|
@style = style
|
10
10
|
@fly = fly
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
when :red
|
18
|
-
border = false
|
19
|
-
@color_code = USPSFlags::Config::RED
|
20
|
-
@past_mid_color = '#FFFFFF'
|
21
|
-
@past_tail_color = USPSFlags::Config::BLUE
|
22
|
-
when :blue
|
23
|
-
border = false
|
24
|
-
@color_code = USPSFlags::Config::BLUE
|
25
|
-
@past_mid_color = '#FFFFFF'
|
26
|
-
@past_tail_color = USPSFlags::Config::RED
|
11
|
+
border = color == :white
|
12
|
+
@color_code, @past_mid_color, @past_tail_color = send("#{color}_colors")
|
13
|
+
@border_svg = if border
|
14
|
+
"stroke=\"#000000\" stroke-width=\"#{USPSFlags::Config::BASE_FLY / 600}\" "
|
15
|
+
else
|
16
|
+
''
|
27
17
|
end
|
28
|
-
@border_svg = border ? "stroke=\"#000000\" stroke-width=\"#{USPSFlags::Config::BASE_FLY / 600}\" " : ''
|
29
18
|
|
30
19
|
@hoist = (@fly * 2) / 3
|
31
20
|
end
|
@@ -43,6 +32,18 @@ class USPSFlags::Core::Field
|
|
43
32
|
|
44
33
|
private
|
45
34
|
|
35
|
+
def white_colors
|
36
|
+
['#FFFFFF', USPSFlags::Config::BLUE, USPSFlags::Config::RED]
|
37
|
+
end
|
38
|
+
|
39
|
+
def red_colors
|
40
|
+
[USPSFlags::Config::RED, '#FFFFFF', USPSFlags::Config::BLUE]
|
41
|
+
end
|
42
|
+
|
43
|
+
def blue_colors
|
44
|
+
[USPSFlags::Config::BLUE, '#FFFFFF', USPSFlags::Config::RED]
|
45
|
+
end
|
46
|
+
|
46
47
|
def regular_field
|
47
48
|
<<~SVG
|
48
49
|
<path d="M 0 0
|
@@ -68,29 +69,45 @@ private
|
|
68
69
|
def past_field
|
69
70
|
<<~SVG
|
70
71
|
<g transform="translate(#{USPSFlags::Config::BASE_FLY / 1200}, #{USPSFlags::Config::BASE_FLY / 1800})">
|
71
|
-
<path d="M 0 #{USPSFlags::Config::BASE_FLY / 600}
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
" fill="#{@color_code}" />
|
76
|
-
<path d="M #{@fly / 2} #{@hoist / 12}
|
77
|
-
l #{@fly / 4} #{@hoist / 24}
|
78
|
-
l 0 #{@hoist * 9 / 12}
|
79
|
-
l -#{@fly / 4} #{@hoist / 24}
|
80
|
-
" fill="#{@past_mid_color}" />
|
81
|
-
<path d="M #{@fly * 3 / 4} #{@hoist * 3 / 24}
|
82
|
-
l #{@fly / 4} #{@hoist / 24}
|
83
|
-
l -#{@fly / 5} #{@hoist / 3}
|
84
|
-
l #{@fly / 5} #{@hoist / 3}
|
85
|
-
l -#{@fly / 4} #{@hoist / 24}
|
86
|
-
" fill="#{@past_tail_color}" />
|
87
|
-
<path d="M 0 0
|
88
|
-
l #{@fly} #{@hoist / 6}
|
89
|
-
l -#{@fly / 5} #{@hoist / 3}
|
90
|
-
l #{@fly / 5} #{@hoist / 3}
|
91
|
-
l -#{@fly} #{@hoist / 6} z
|
92
|
-
" fill="none" stroke="#000000" stroke-width="#{USPSFlags::Config::BASE_FLY / 600}" />
|
72
|
+
<path d="M 0 #{USPSFlags::Config::BASE_FLY / 600} #{past_line_one}" fill="#{@color_code}" />
|
73
|
+
<path d="M #{@fly / 2} #{@hoist / 12} #{past_line_two}" fill="#{@past_mid_color}" />
|
74
|
+
<path d="M #{@fly * 3 / 4} #{@hoist * 3 / 24} #{past_line_three}" fill="#{@past_tail_color}" />
|
75
|
+
<path d="M 0 0 #{past_line_four} z" fill="none" stroke="#000000" stroke-width="#{USPSFlags::Config::BASE_FLY / 600}" />
|
93
76
|
</g>
|
94
77
|
SVG
|
95
78
|
end
|
79
|
+
|
80
|
+
def past_line_one
|
81
|
+
<<~SVG
|
82
|
+
l #{@fly / 2} #{@hoist / 12}
|
83
|
+
l 0 #{@hoist * 10 / 12}
|
84
|
+
l -#{@fly / 2} #{@hoist / 12}
|
85
|
+
SVG
|
86
|
+
end
|
87
|
+
|
88
|
+
def past_line_two
|
89
|
+
<<~SVG
|
90
|
+
l #{@fly / 4} #{@hoist / 24}
|
91
|
+
l 0 #{@hoist * 9 / 12}
|
92
|
+
l -#{@fly / 4} #{@hoist / 24}
|
93
|
+
SVG
|
94
|
+
end
|
95
|
+
|
96
|
+
def past_line_three
|
97
|
+
<<~SVG
|
98
|
+
l #{@fly / 4} #{@hoist / 24}
|
99
|
+
l -#{@fly / 5} #{@hoist / 3}
|
100
|
+
l #{@fly / 5} #{@hoist / 3}
|
101
|
+
l -#{@fly / 4} #{@hoist / 24}
|
102
|
+
SVG
|
103
|
+
end
|
104
|
+
|
105
|
+
def past_line_four
|
106
|
+
<<~SVG
|
107
|
+
l #{@fly} #{@hoist / 6}
|
108
|
+
l -#{@fly / 5} #{@hoist / 3}
|
109
|
+
l #{@fly / 5} #{@hoist / 3}
|
110
|
+
l -#{@fly} #{@hoist / 6}
|
111
|
+
SVG
|
112
|
+
end
|
96
113
|
end
|
@@ -12,21 +12,38 @@ class USPSFlags::Core::Headers
|
|
12
12
|
scale ||= 3
|
13
13
|
@generated_at = Time.now.strftime('%Y%m%d.%H%S%z')
|
14
14
|
|
15
|
-
if @width.nil? || @height.nil?
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@view_height = USPSFlags::Config::BASE_HOIST
|
20
|
-
set_pennant_height(@height) if pennant
|
21
|
-
else
|
22
|
-
@view_width = width * scale
|
23
|
-
@view_height = height * scale
|
24
|
-
end
|
15
|
+
return no_sizes(scale, pennant) if @width.nil? || @height.nil?
|
16
|
+
|
17
|
+
@view_width = width * scale
|
18
|
+
@view_height = height * scale
|
25
19
|
end
|
26
20
|
|
27
21
|
def svg
|
28
|
-
svg = ''
|
29
|
-
svg <<
|
22
|
+
svg = +''
|
23
|
+
svg << header_top
|
24
|
+
svg << trademark unless @title == 'US Ensign'
|
25
|
+
svg << '</metadata>'
|
26
|
+
|
27
|
+
svg
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
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
|
39
|
+
|
40
|
+
def set_pennant_height(height)
|
41
|
+
@height = height / 4
|
42
|
+
@view_height = USPSFlags::Config::BASE_HOIST / 4
|
43
|
+
end
|
44
|
+
|
45
|
+
def header_top
|
46
|
+
<<~SVG
|
30
47
|
<?xml version="1.0" standalone="no"?>
|
31
48
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
32
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">
|
@@ -35,25 +52,12 @@ class USPSFlags::Core::Headers
|
|
35
52
|
<desc id="created-by">Julian Fiander</desc>
|
36
53
|
<desc id="generated-at">#{@generated_at}</desc>
|
37
54
|
SVG
|
38
|
-
|
39
|
-
unless @title == 'US Ensign'
|
40
|
-
svg << <<~SVG
|
41
|
-
<desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
|
42
|
-
<desc id="trademark-link">https://www.usps.org/images/secretary/itcom/trademark.pdf</desc>
|
43
|
-
SVG
|
44
|
-
end
|
45
|
-
|
46
|
-
svg << <<~SVG
|
47
|
-
</metadata>
|
48
|
-
SVG
|
49
|
-
|
50
|
-
svg
|
51
55
|
end
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
58
62
|
end
|
59
63
|
end
|
@@ -6,27 +6,21 @@
|
|
6
6
|
# @private
|
7
7
|
class USPSFlags::Core::Icons::Star
|
8
8
|
def svg
|
9
|
-
points = [
|
10
|
-
[117.555, 81.805],
|
11
|
-
[-41.47, -137.085],
|
12
|
-
[114.125, -86.525],
|
13
|
-
[-143.185, -2.915],
|
14
|
-
[-47.025, -135.28],
|
15
|
-
[-47.025, 135.28],
|
16
|
-
[-143.185, 2.915],
|
17
|
-
[114.125, 86.525],
|
18
|
-
[-41.47, 137.085],
|
19
|
-
[117.555, -81.805]
|
20
|
-
]
|
21
|
-
|
22
9
|
svg = "<path d=\"M 0 0\n"
|
23
|
-
|
24
|
-
points.each do |x, y|
|
25
|
-
svg << "l #{x} #{y}\n"
|
26
|
-
end
|
27
|
-
|
10
|
+
points.each { |x, y| svg << "l #{x} #{y}\n" }
|
28
11
|
svg << "\" fill=\"#FFFFFF\" />\n"
|
29
12
|
|
30
13
|
svg
|
31
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
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
|
+
]
|
25
|
+
end
|
32
26
|
end
|