position nodes on discrete multiples of 100
I have a few ideas for encouraging arrangements of definitions to have more life in the sense of Christopher Alexander: * quantize the x axis to discrete columns * don't force a single grid; that can look boring. Each node occupies 600px of width, so quantizing at multiples of 100 gives us 6 possible arrangements. * always position new nodes within the current viewport * always position new nodes at least some amount of padding above to give the node above some room to grow * forbid overlap * moving a node against another should push the other node as well * I want a node to yield some resistance, but I don't want resistance to grow linearly by the number of nodes pushed
This commit is contained in:
parent
5a3deb7524
commit
34f286270f
|
@ -19,6 +19,8 @@ on.update = function(dt)
|
|||
if Move then
|
||||
Move.node.x = sx(App.mouse_x()-Move.xoff)
|
||||
Move.node.y = sy(App.mouse_y()-Move.yoff)
|
||||
-- quantize the x axis to discrete columns
|
||||
Move.node.x = round(Move.node.x/100)*100
|
||||
A1(Move.node.key)
|
||||
return
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
round = function(f)
|
||||
-- apparently this is wrong for one floating point under 0.5
|
||||
-- there's an alleged better way at https://stackoverflow.com/questions/18313171/lua-rounding-numbers-and-then-truncate/58411671#58411671
|
||||
return math.floor(f+0.5)
|
||||
end
|
Loading…
Reference in New Issue