You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0KB

  1. require_relative '../control'
  2. module DHE
  3. class Port < RoundControl
  4. DIAMETER = 8.4
  5. attr_reader :x, :y
  6. def initialize(faceplate:, x:, y:)
  7. super(faceplate: faceplate, x: x, y: y, diameter: DIAMETER)
  8. @foreground = faceplate.foreground
  9. @background = faceplate.background
  10. @path = faceplate.slug / 'port'
  11. @x = x
  12. @y = y
  13. end
  14. def draw(svg:, x:, y:)
  15. stroke_width = DIAMETER * 0.025
  16. sleeve_diameter = DIAMETER - stroke_width
  17. step = sleeve_diameter / 7.0
  18. sleeve_radius = sleeve_diameter / 2.0
  19. ring_radius = sleeve_radius - step
  20. tip_radius = ring_radius - step
  21. svg.g(transform: "translate(#{x} #{y})", stroke: @foreground, fill: @background, 'stroke-width' => stroke_width) do |g|
  22. g.circle(r: sleeve_radius)
  23. g.circle(r: ring_radius)
  24. g.circle(r: tip_radius, fill: @foreground)
  25. end
  26. end
  27. def svg_files
  28. [
  29. svg_file(path: @path) do |svg|
  30. draw_control(svg: svg)
  31. end
  32. ]
  33. end
  34. end
  35. end