diff options
author | sanine <sanine.not@pm.me> | 2022-02-25 10:20:08 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-02-25 10:20:08 -0600 |
commit | 1b93d166d6beeccffe3a3279a2b8ab93a2efc82a (patch) | |
tree | c73e4009d4d528ca9b2fb6be708d868daa981dd9 | |
parent | b10141db0f63429111f6c82c85ccb921723b5b82 (diff) |
add geom.qt_node
l--------- | city/.#geometry-test.lua | 1 | ||||
-rw-r--r-- | city/geometry-test.lua | 22 | ||||
-rw-r--r-- | city/geometry.lua | 21 |
3 files changed, 44 insertions, 0 deletions
diff --git a/city/.#geometry-test.lua b/city/.#geometry-test.lua new file mode 120000 index 0000000..4290946 --- /dev/null +++ b/city/.#geometry-test.lua @@ -0,0 +1 @@ +kate@amalthea.2265651:1645662843
\ No newline at end of file diff --git a/city/geometry-test.lua b/city/geometry-test.lua index 74ddb3a..3227cd1 100644 --- a/city/geometry-test.lua +++ b/city/geometry-test.lua @@ -130,3 +130,25 @@ test( assert(bb.span == 2) end ) + + +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- geom.qt_node +-- +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +test( + 'create qt_node', + function() + local center = geom.point(2, 2) + local node = geom.qt_node(center, 4) + + assert(node.square.center.x == 2) + assert(node.square.center.y == 2) + assert(node.square.span == 4) + + assert(not node:is_leaf()) + assert(not node.point) + end +) diff --git a/city/geometry.lua b/city/geometry.lua index 13088d1..78c2aa7 100644 --- a/city/geometry.lua +++ b/city/geometry.lua @@ -80,4 +80,25 @@ geom.square = class{ end } + +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- qt_node +-- +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +geom.qt_node = class{ + __call = function(this, center, span) + local node = {} + node.square = geom.square(center, span) + setmetatable(node, {__index=this}) + return node + end, + + is_leaf = function(self) + if self.children then return true end + return false + end, +} + return geom |