Class | AppMath::Graphs |
In: |
graph.rb
|
Parent: | Object |
The code
root = TkRoot.new{ title 'Test of ...'} g = Graphs.new(root,3,2,1000,700)
generates a 2 times 3 matrix of Graph-objects
g.at(0,0), g.at(0,1), g.at(0,2) g.at(1,0), g.at(1,1), g.at(1,2)
which together make up a rectangle of 1000 pixels in x-direction and 700 pixels in y-direction. Notice that the matrix is a grid with 3 items in x-direction and 2 items in y-direction. Since these items are of class Graph, the can be used for graphical representations of arrays and of functions without needing suport fom the present class Graphs.
grs | [R] | |
mx | [R] | |
my | [R] | |
px | [R] | |
py | [R] |
# File graph.rb, line 200 200: def initialize(parent,px,py,nx,ny) 201: zero = R.c0 202: one = R.c1 203: @px = px 204: @py = py 205: @mx = nx / @px 206: @my = ny / @py 207: ivx = Iv.new(zero,one) 208: ivy = Iv.new(zero,one) 209: @grs = Array.new 210: py.times{ |r| 211: gr = Array.new 212: px.times{ |c| 213: fr = TkFrame.new(parent).grid('row' => r, 'column' => c) 214: gr << Graph.new(fr,@mx,@my,ivx,ivy) 215: } 216: @grs << gr 217: } 218: end