Class: AppMath::Graphs
- Inherits:
-
Object
- Object
- AppMath::Graphs
- Defined in:
- lib/graph.rb
Overview
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, they can be used for graphical representations of arrays and of functions without needing support fom the present class Graphs.
Instance Attribute Summary collapse
-
#grs ⇒ Object
readonly
Returns the value of attribute grs.
-
#mx ⇒ Object
readonly
Returns the value of attribute mx.
-
#my ⇒ Object
readonly
Returns the value of attribute my.
-
#px ⇒ Object
readonly
Returns the value of attribute px.
-
#py ⇒ Object
readonly
Returns the value of attribute py.
Instance Method Summary collapse
-
#at(i, j) ⇒ Object
Access function.
-
#initialize(parent, px, py, nx, ny) ⇒ Graphs
constructor
Generating a (py,px)-matrix of Graph-objects, in an rectangular area which is a (ny,nx)-matrix of pixels.
Constructor Details
#initialize(parent, px, py, nx, ny) ⇒ Graphs
Generating a (py,px)-matrix of Graph-objects, in an rectangular area which is a (ny,nx)-matrix of pixels.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/graph.rb', line 257 def initialize(parent,px,py,nx,ny) zero = R.c0 one = R.c1 @px = px @py = py @mx = nx / @px @my = ny / @py ivx = Iv.new(zero,one) ivy = Iv.new(zero,one) @grs = Array.new py.times{ |r| gr = Array.new px.times{ |c| fr = TkFrame.new(parent).grid('row' => r, 'column' => c) gr << Graph.new(fr,@mx,@my,ivx,ivy) } @grs << gr } end |
Instance Attribute Details
#grs ⇒ Object (readonly)
Returns the value of attribute grs.
253 254 255 |
# File 'lib/graph.rb', line 253 def grs @grs end |
#mx ⇒ Object (readonly)
Returns the value of attribute mx.
253 254 255 |
# File 'lib/graph.rb', line 253 def mx @mx end |
#my ⇒ Object (readonly)
Returns the value of attribute my.
253 254 255 |
# File 'lib/graph.rb', line 253 def my @my end |
#px ⇒ Object (readonly)
Returns the value of attribute px.
253 254 255 |
# File 'lib/graph.rb', line 253 def px @px end |
#py ⇒ Object (readonly)
Returns the value of attribute py.
253 254 255 |
# File 'lib/graph.rb', line 253 def py @py end |
Instance Method Details
#at(i, j) ⇒ Object
Access function. For a Graphs-object g, one has the Graph-objects
g.at(i,j), 0 <= i < p.py, 0 <= j < g.px .
All integer values are allowed and these then are understood periodically.
281 282 283 |
# File 'lib/graph.rb', line 281 def at(i,j) return @grs[i.to_i%@py][j.to_i%@px] end |