mirror of
https://github.com/rm-code/Graphoon.git
synced 2024-11-16 18:24:22 +00:00
Rewrite the drawing function to take two functions as parameters
These function will be called on each edge and node in the graph and allow the user to determine how the graph is drawn.
This commit is contained in:
parent
b30389bf8a
commit
86788b748d
20
fd/Graph.lua
20
fd/Graph.lua
@ -151,13 +151,21 @@ function Graph.new()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- This function receives a single parameter of type function to which it
|
-- Draws the graph.
|
||||||
-- will pass the edges and nodes tables. This means the user has to provide
|
-- Takes two callback functions as a parameter. These will be called
|
||||||
-- his own drawing function.
|
-- on each edge and node in the graph and will be used to wite a custom
|
||||||
-- @param func - The function to pass the tables to.
|
-- drawing function.
|
||||||
|
-- @param nodeCallback - A callback called on every node.
|
||||||
|
-- @param edgeCallback - A callback called on every edge.
|
||||||
--
|
--
|
||||||
function self:draw( func )
|
function self:draw( nodeCallback, edgeCallback )
|
||||||
func( edges, nodes );
|
for _, edge in pairs( edges ) do
|
||||||
|
edgeCallback( edge );
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, node in pairs( nodes ) do
|
||||||
|
nodeCallback( node );
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
|
Loading…
Reference in New Issue
Block a user