Class: Termular::Graph::ImplicitCartesian

Inherits:
Termular::Graph show all
Defined in:
lib/termular/graph.rb

Instance Attribute Summary

Attributes inherited from Termular::Graph

#expression, #max_x, #max_y, #min_x, #min_y, #needs_redraw, #options, #start_time

Instance Method Summary collapse

Methods inherited from Termular::Graph

#center, #initialize, #invalidate, #pan, #point_to_screen, #render_axes, #screen_to_point, #zoom

Constructor Details

This class inherits a constructor from Termular::Graph

Instance Method Details

#renderObject



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/termular/graph.rb', line 130

def render
  @needs_redraw = false
  Console.buffered_print do |buff|
    buff << render_axes
    ctx = Context.new Context.global
    ctx["time"] = Time.now.to_f - @start_time
    buff << Console.color(:green)
    1.upto(Console.rows - 1) do |sy|
      1.upto(Console.cols) do |sx|
        ctx["x"], ctx["y"] = screen_to_point sx, sy
        if expression.eval ctx
          buff << Console.move(sx, Console.rows - sy) << "+"
        end
      end
    end
  end
end