Class: Idml::Render::Renderers::GraphicLineRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/idml/render/renderers/graphic_line_renderer.rb

Class Method Summary collapse

Class Method Details

.render(canvas, context) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/idml/render/renderers/graphic_line_renderer.rb', line 7

def self.render(canvas, context)
  line = context.item
  return unless RectangleRenderer.strokeable?(line)

  color = context.color_resolver&.resolve(line.stroke_color)
  return unless color

  box = RectangleRenderer.placement_box(line, context.page_height)
  return unless box

  canvas.save_graphics_state do
    canvas.stroke_color(ColorHelper.to_canvas(color))
    canvas.line_width = line.stroke_weight
    canvas.move_to(box[:x], box[:y] + box[:height])
    canvas.line_to(box[:x] + box[:width], box[:y])
    canvas.stroke
  end
end