Class: RubyPost::ImpulsePlot

Inherits:
AbstractPlot show all
Defined in:
lib/simpleplot.rb

Instance Attribute Summary

Attributes inherited from AbstractPlot

#x, #y

Attributes inherited from BaseDrawCommand

#drawable

Instance Method Summary collapse

Methods inherited from AbstractPlot

#xmax, #xmin, #ymax, #ymin

Methods inherited from BaseDrawCommand

#add_option, #color, #colour, #compile_options, #rotate, #scale, #set_drawable, #translate

Constructor Details

#initialize(x, y) ⇒ ImpulsePlot

Intitalise with two arrays of the same size.



182
183
184
185
186
# File 'lib/simpleplot.rb', line 182

def initialize(x, y)
  super()
  @x = x
  @y = y
end

Instance Method Details

#compileObject



188
189
190
191
192
193
194
# File 'lib/simpleplot.rb', line 188

def compile
  str = ''
  @x.each_index{ |i| 
    str = str + 'drawarrow (' + @x[i].to_s + 'cm, 0)--(' + @x[i].to_s + 'cm, ' + @y[i].to_s + 'cm) ' + compile_options + ";\n"
  }
  return str
end

#compilewithscale(xscale, yscale) ⇒ Object



196
197
198
199
200
201
202
# File 'lib/simpleplot.rb', line 196

def compilewithscale(xscale, yscale)
  str = ''
  @x.each_index{ |i|
    str = str + 'drawarrow (' + (@x[i]*xscale).to_s + 'cm, 0)--(' + (@x[i]*xscale).to_s + 'cm, ' + (@y[i]*yscale).to_s + 'cm) ' + compile_options + ";\n"
  }
  return str
end