www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit 80158979948635c9e03404a45ac8c6d186f0a5fd
parent e87407214f3c61636eead9a4e68a3037a79ba527
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Mon, 14 Oct 2024 22:32:50 -0700

Add subdivide button for pointmaps

You could already subdivide with double click, but I don't want to
use double clicks plus I want everything to have a button for
self-documenting.

Diffstat:
Mfiles/floorplans/floorplan/main.js | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js @@ -330,6 +330,29 @@ function selectHandler(event, editor, state) { c.appendChild(document.createElement("li")) .appendChild(document.createTextNode("Length: " + userLength(editor, editor.pointmapLength(groups.pntmap[0])))) + c.appendChild(document.createElement("li")) + .appendChild(ui.button("Subdivide", "Subdivide pointmap", null, { + handlers: { + click: function(ev) { + handled(ev) + let pm = editor.findObj(groups.pntmap[0]) + let p + if (State.lastClick) { + // This will mostly work well, but if the user manages to click + // somewhere else and keep this selected it'll maybe not be where + // they want. + p = pm.closestPoint(new Vector2(State.lastClick.x, State.lastClick.y)) + } else { + p = pm.interpolatedPoint(0.5) + } + let pid = editor.addPoint(p) + pm = editor.backend.reqObj(groups.pntmap[0]) + editor.mapPoints({ a: pid, b: pm.a }) + editor.mapPoints({ a: pid, b: pm.b }) + editor.remove(groups.pntmap[0]) + } + } + })) let pm = editor.backend.reqObj(groups.pntmap[0]) if (pm.type === "door") {