From 1b93d166d6beeccffe3a3279a2b8ab93a2efc82a Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 25 Feb 2022 10:20:08 -0600 Subject: add geom.qt_node --- city/.#geometry-test.lua | 1 + city/geometry-test.lua | 22 ++++++++++++++++++++++ city/geometry.lua | 21 +++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 120000 city/.#geometry-test.lua (limited to 'city') 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 -- cgit v1.2.1