Update README.md

This commit is contained in:
Robert Machmer 2016-01-12 03:37:03 +01:00
parent 576297a5c7
commit 55138721c1

View File

@ -62,3 +62,28 @@ Or by using the ```setAnchor``` function:
-- Invert anchor status
node:setAnchor( not node:isAnchor(), mouseX, mouseY )
```
### Using custom classes for Nodes and Edges
If you prefer to not touch the default classes, you can simply inherit from them and tell Graphoon to use your custom classes instead.
```lua
local GraphLibraryNode = require('lib.libfdgraph.fd').Node
local CustomNodeClass = {}
-- You can pass additional arguments to your custom class. Just make sure the
-- default parameters ar in the right order.
function CustomNodeClass.new( id, x, y, anchor, ... )
local self = GraphLibraryNode.new( id, x, y, anchor )
-- ... Custom code
end
return CustomNodeClass
```
```lua
local GraphLibrary = require('Graphoon').Graph
GraphLibrary.setNodeClass( require('CustomNodeClass') )
```