Class: USPSFlags::Core::Tridents

Inherits:
Object
  • Object
show all
Defined in:
lib/usps_flags/core/tridents.rb

Class Method Summary collapse

Class Method Details

.cc(_ = nil, trident_color:) ⇒ Object

The side C/C tridents are angled 45 degrees, and intersect the central one at 1/3 up from the bottom

Center of rotation: # radius = USPSFlags.configuration.trident / 2 <circle cx=“#:x” cy=“#:y” r=“#radius” fill=“red” />



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/usps_flags/core/tridents.rb', line 16

def cc(_ = nil, trident_color:)
  trident = USPSFlags::Core.trident(:n, color: trident_color)
  x_distance = USPSFlags::Config::BASE_FLY * 4 / 39 # 4/39 or 28/39
  y_distance = USPSFlags::Config::BASE_FLY * 2 / 39 # 5/78 or 27/156
  <<~SVG
    <g transform="translate(-#{x_distance * 1.25}, #{y_distance})">
      <g transform="rotate(-45, #{USPSFlags::Config::BASE_FLY / 2}, #{USPSFlags::Config::BASE_HOIST / 2})">\n#{trident}</g>
    </g>
    \n#{trident}
    <g transform="translate(#{x_distance * 1.25}, #{y_distance})">
      <g transform="rotate(45)" transform-origin="center">\n#{trident}</g>
    </g>
  SVG
end

.offset(type, field_color:, field: true) ⇒ Object

Swallowtail tridents need to move towards the hoist due to the tails



67
68
69
70
71
72
73
74
# File 'lib/usps_flags/core/tridents.rb', line 67

def offset(type, field_color:, field: true)
  x_distance = USPSFlags::Config::BASE_FLY / 10 if field
  svg = +''
  svg << "<g transform=\"translate(-#{x_distance})\">" if field
  svg << USPSFlags::Core.trident(type, field_color: field_color, color: :red)
  svg << '</g>' if field
  svg
end

.three(type, trident_color:, field_color:) ⇒ Object

Cdr and D/C tridents are spaced 1/2 the fly apart with the central one 1/4 the fly above the sides



45
46
47
48
49
50
51
52
53
54
# File 'lib/usps_flags/core/tridents.rb', line 45

def three(type, trident_color:, field_color:)
  trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
  x_distance = USPSFlags::Config::BASE_FLY / 4
  y_distance = USPSFlags::Config::BASE_FLY / 16
  <<~SVG
    <g transform="translate(-#{x_distance}, #{y_distance})">\n#{trident}</g>
    <g transform="translate(0, -#{y_distance + 1})">\n#{trident}</g>
    <g transform="translate(#{x_distance}, #{y_distance})">\n#{trident}</g>
  SVG
end

.two(type, trident_color:, field_color:) ⇒ Object

Lt/C and D/Lt/C tridents are spaced 1/3 the fly apart



57
58
59
60
61
62
63
64
# File 'lib/usps_flags/core/tridents.rb', line 57

def two(type, trident_color:, field_color:)
  trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
  x_distance = USPSFlags::Config::BASE_FLY / 6
  <<~SVG
    <g transform="translate(-#{x_distance})">\n#{trident}</g>
    <g transform="translate(#{x_distance})">\n#{trident}</g>
  SVG
end

.vc(_ = nil, trident_color:) ⇒ Object

V/C tridents are angled 45 degrees, and intersect at 15/32 up from the bottom



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/usps_flags/core/tridents.rb', line 32

def vc(_ = nil, trident_color:)
  trident = USPSFlags::Core.trident(:n, color: trident_color)
  <<~SVG
    <g transform="rotate(-45, #{vc_center[:x]}, #{vc_center[:y]})">
      #{trident}
    </g>
    <g transform="rotate(45, #{vc_center[:x]}, #{vc_center[:y]})">
      #{trident}
    </g>
  SVG
end