mirror of
https://github.com/rm-code/Graphoon.git
synced 2024-11-16 18:24:22 +00:00
Update README.md
This commit is contained in:
parent
576297a5c7
commit
55138721c1
25
README.md
25
README.md
@ -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') )
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user