Class: RubyPost::CurvedPlot

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) ⇒ CurvedPlot

Intitalise with two arrays of the same size.



159
160
161
162
163
# File 'lib/simpleplot.rb', line 159

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

Instance Method Details

#compileObject



165
166
167
168
169
# File 'lib/simpleplot.rb', line 165

def compile
  @p = Path.new.curved
  @x.each_index{ |i| @p.add_pair(Pair.new(@x[i].cm, @y[i].cm)) }
  'draw ' + @p.compile + ' ' + compile_options + ";\n"
end

#compilewithscale(xscale, yscale) ⇒ Object



171
172
173
174
175
# File 'lib/simpleplot.rb', line 171

def compilewithscale(xscale, yscale)
  @p = Path.new.curved
  @x.each_index{ |i| @p.add_pair(Pair.new((@x[i]*xscale).cm, (@y[i]*yscale).cm)) }
  'draw ' + @p.compile + ' ' + compile_options + ";\n"
end