summaryrefslogtreecommitdiff
path: root/city
diff options
context:
space:
mode:
Diffstat (limited to 'city')
l---------city/.#geometry-test.lua1
-rw-r--r--city/geometry-test.lua22
-rw-r--r--city/geometry.lua21
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