matt.smillie@gmail.com
2/18/2006 3:18:00 PM
The children of a node go in @children. They're probably other nodes.
The transformation matrix and function would likely be data members
holding, respectively, a matrix and a proc object. An alternate
approach for the drawing function would be to make an instance method
that receives a block (where the block would contain the drawing
function).
So, potentially something like this:
class Node
attr_accessor :children, :parent, :transform
def initialize(parent = nil, transform = some_sort_of _matrix_object)
@children = []
@transform = transform
if parent then parent.add_child(self) end
end
def add_child(node)
@children.push(node)
node.parent = self
end
def draw(&block)
yield
end
end