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
25
26
# File 'lib/idml/render/renderers/graphic_line_renderer.rb', line 7

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

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

  box = Placement.box(line, context.page_height)
  return unless box

  Blending.wrap(canvas, line.transparency_setting) do
    StrokeStyle.apply(canvas, line) 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
end