# frozen_string_literal: false
# SVG building helpers.
#
# These methods should never need to be called directly, except when designing new flags.
# @private
class USPSFlags
class Helpers
class Builders
class << self
# Displays an overlay grid with regularly spaced locator markers.
#
# This is useful for adjusting or creating new SVG data generators, but should not otherwise need to be called.
# @private
def grid(width: USPSFlags::Config::BASE_FLY, height: USPSFlags::Config::BASE_HOIST)
@width = width
@height = height
@stroke_width = @width / 600
"#{circles}#{horizontal_lines}#{vertical_lines}#{diagonal_lines}"
end
# Displays an overlay indicator of concentric circles and radiating lines.
#
# This is useful for adjusting or creating new SVG data generators, but should not otherwise need to be called.
# @private
def locator
<<~SVG
SVG
end
private
def circles
<<~SVG
#{pos_circle(0, 0)}
#{pos_circle(@width, 0)}
#{pos_circle(@width, @height)}
#{pos_circle(0, @height)}
#{radial_circles}
SVG
end
def radial_circles
<<~SVG
#{radial_circle(1, @width / 60)}
#{radial_circle(2, @width / 60)}
#{radial_circle(2, @width / 75)}
#{radial_circle(2, @width / 100)}
#{radial_circle(3, @width / 60)}
SVG
end
def pos_circle(cx, cy)
<<~SVG
SVG
end
def radial_circle(index, radius)
<<~SVG
SVG
end
def horizontal_lines
(0..4).map { |index| horizontal_line(index) }.join
end
def horizontal_line(index)
<<~SVG
SVG
end
def vertical_lines
(0..6).map { |index| vertical_line(index) }.join
end
def vertical_line(index)
<<~SVG
SVG
end
def diagonal_lines
diagonal_line(2, 1, 3, 2) +
diagonal_line(3, 2, 2, 3) +
diagonal_line(2, 3, 1, 2) +
diagonal_line(1, 2, 2, 1)
end
def diagonal_line(a, b, c, d)
<<~SVG
SVG
end
end
end
end
end