Class: WhirledPeas::Graphics::GraphPainter

Inherits:
ContentPainter
  • Object
show all
Defined in:
lib/whirled_peas/graphics/graph_painter.rb

Instance Method Summary collapse

Instance Method Details

#paint(canvas, left, top, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/whirled_peas/graphics/graph_painter.rb', line 12

def paint(canvas, left, top, &block)
  axis_formatting = [*settings.axis_color, *settings.bg_color]
  plot_formatting = [*settings.color, *settings.bg_color]
  axes_lines.each.with_index do |axis_line, row_index|
    canvas.stroke(left, top + row_index, axis_line, axis_formatting, &block)
    next if row_index >= plot_lines.length
    canvas.stroke(left + 1, top + row_index, plot_lines[row_index], plot_formatting, &block)
  end
end