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.

22 lines
717B

  1. require_relative '../dimensions'
  2. require_relative '../control'
  3. module DHE
  4. class Box < Control
  5. CORNER_RADIUS = 1.0
  6. BUFFER = PADDING + STROKE_INSET
  7. def initialize(faceplate:, top:, right:, bottom:, left:, style: :normal)
  8. super(faceplate: faceplate, top: top - BUFFER, right: right + BUFFER, bottom: bottom + BUFFER, left: left -
  9. BUFFER)
  10. @stroke = faceplate.foreground
  11. @fill = style == :normal ? faceplate.background : @stroke
  12. end
  13. def draw_faceplate(svg:)
  14. svg.rect(x: left, y: top, width: @width, height: @height,
  15. rx: CORNER_RADIUS, ry: CORNER_RADIUS,
  16. stroke: @stroke, fill: @fill, 'stroke-width' => STROKE_WIDTH)
  17. end
  18. end
  19. end