Module: USPSFlags::Core::Icons::TridentParts::Hashes

Included in:
USPSFlags::Core::Icons::Trident
Defined in:
lib/usps_flags/core/icons/trident_parts/hashes.rb

Instance Method Summary collapse

Instance Method Details

#circle_hashObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/usps_flags/core/icons/trident_parts/hashes.rb', line 45

def circle_hash
  center = @trident_config[:center_point]
  <<~SVG
    <circle cx="#{center}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2}" fill="#{@color_code}" mask="url(#circle-mask)" />
    <mask id="circle-mask">
      <g>
        <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
        <circle cx="#{center}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2 - @trident_config[:bar_width]}" fill="#000000" />
      </g>
    </mask>
    <mask id="circle-mask-for-main-spike">
      <g transform="scale(1.05) translate(-@trident_config[:br_width], -@trident_config[:br_width]/2)">
        <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
        <circle cx="#{center}" cy="#{@top_point + @circle_from_top}" r="#{@trident_config[:width] / 2 - @trident_config[:bar_width]}" fill="#000000" />
      </g>
    </mask>
  SVG
end

#delta_hashObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/usps_flags/core/icons/trident_parts/hashes.rb', line 12

def delta_hash
  <<~SVG
    <polyline mask="url(#delta-mask)" fill="#{@color_code}" points="#{delta_mask_points(@trident_config[:center_point], @trident_config[:height][:d], @trident_config[:delta_from_bottom])}" />
    <mask id="delta-mask">
      <g>
        <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY}" height="#{USPSFlags::Config::BASE_FLY}" fill="#FFFFFF" />
        <polyline transform="scale(#{@trident_config[:delta_gap_scale]}) translate(#{@trident_config[:delta_gap_x]},#{@trident_config[:delta_gap_y]})" fill="#000000" points="#{delta_points(@trident_config[:center_point], @trident_config[:height][:d], @trident_config[:delta_from_bottom])}" />
      </g>
    </mask>
  SVG
end

#delta_mask_points(center, height, bottom) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/usps_flags/core/icons/trident_parts/hashes.rb', line 24

def delta_mask_points(center, height, bottom)
  top = @top_point + height - bottom
  <<~SVG
    #{center}, #{top - @trident_config[:delta_height]}
    #{center + @trident_config[:width] / 2}, #{top}
    #{center - @trident_config[:width] / 2}, #{top}
    #{center}, #{top - @trident_config[:delta_height]}
  SVG
end

#delta_points(center, height, bottom) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/usps_flags/core/icons/trident_parts/hashes.rb', line 34

def delta_points(center, height, bottom)
  top = @top_point + height - bottom - @trident_config[:delta_height]
  mid = @top_point + height - bottom * 17 / 20
  <<~SVG
    #{center}, #{top}
    #{center + @trident_config[:width] / 2}, #{mid}
    #{center - @trident_config[:width] / 2}, #{mid}
    #{center}, #{top}
  SVG
end

#standard_hashObject



64
65
66
67
68
69
70
71
# File 'lib/usps_flags/core/icons/trident_parts/hashes.rb', line 64

def standard_hash
  x_pos = (@trident_config[:center_point] - @trident_config[:hash_width] / 2)
  svg = "<path d=\"M #{x_pos} #{(@top_point + @hash_from_top)}\n"
  @lower_hash.each { |x, y| svg << "l #{x} #{y}\n" }
  svg << "\" fill=\"#{@color_code}\" />\n"

  svg
end