mirror of
https://github.com/rm-code/Graphoon.git
synced 2024-11-16 18:24:22 +00:00
Remove name attribute in Node class
Seems kind of redundant to have both an id and a name attribute.
This commit is contained in:
parent
e6154ba5ea
commit
dba6a49587
@ -55,9 +55,9 @@ function Graph.new()
|
||||
for _, node in pairs( table.nodes ) do
|
||||
local rx, ry = math.random( x, w ), math.random( y, h );
|
||||
if type( node ) == 'string' then
|
||||
self:addNode( node, nil, rx, ry );
|
||||
self:addNode( node, rx, ry );
|
||||
elseif type( node ) == 'table' then
|
||||
self:addNode( node.id, node.name, node.x or rx, node.y or ry, node.anchor );
|
||||
self:addNode( node.id, node.x or rx, node.y or ry, node.anchor );
|
||||
end
|
||||
end
|
||||
|
||||
@ -72,9 +72,9 @@ function Graph.new()
|
||||
-- @param x - The x-coordinate at which to place the new node.
|
||||
-- @param y - The y-coordinate at which to place the new node.
|
||||
--
|
||||
function self:addNode( id, name, x, y, anchor )
|
||||
function self:addNode( id, x, y, anchor )
|
||||
assert( not nodes[id], "Node IDs must be unique." );
|
||||
nodes[id] = Node.new( id, name, x, y, anchor );
|
||||
nodes[id] = Node.new( id, x, y, anchor );
|
||||
return nodes[id];
|
||||
end
|
||||
|
||||
|
@ -12,10 +12,9 @@ local DEFAULT_MASS = 0.05;
|
||||
---
|
||||
-- @param id - A unique id which will be used to reference this node.
|
||||
--
|
||||
function Node.new( id, name, x, y, anchor )
|
||||
function Node.new( id, x, y, anchor )
|
||||
local self = {};
|
||||
|
||||
local name = name or id;
|
||||
local px, py = x or 0, y or 0;
|
||||
local ax, ay = 0, 0;
|
||||
local vx, vy = 0, 0;
|
||||
@ -80,10 +79,6 @@ function Node.new( id, name, x, y, anchor )
|
||||
return id;
|
||||
end
|
||||
|
||||
function self:getName()
|
||||
return name;
|
||||
end
|
||||
|
||||
function self:getX()
|
||||
return px;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user