From 38d668ee7c99f6032bc99eb951e975460655563f Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 26 Apr 2020 11:01:45 +0200 Subject: [PATCH] text in drawing tool (not yet addable) --- mapeditor.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/mapeditor.cpp b/mapeditor.cpp index 7570e80b..1a9fb714 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -91,6 +91,38 @@ EX namespace mapeditor { return abs(hdist(s, h) - radius); } }; + + struct dttext : dtshape { + hyperpoint where; + ld size; + string caption; + + void rotate(const transmatrix& T) override { + where = T * where; + } + + void save(hstream& hs) override { + hs.write(4); + hs.write(where); + hs.write(size); + hs.write(caption); + } + + dtshape *load(hstream& hs) override { + hs.read(where); + hs.read(size); + hs.read(caption); + return this; + } + + void draw(const transmatrix& V) override { + queuestr(V * rgpushxto0(where), size, caption, col); + } + + ld distance(hyperpoint h) override { + return hdist(h, where); + } + }; struct dtfree : dtshape { @@ -189,6 +221,19 @@ EX namespace mapeditor { dt_add(b, l); } + EX void dt_add_text(hyperpoint h, ld size, string cap) { + cell *b = centerover; + + h = inverse(ggmatrix(b)) * h; + virtualRebase(b, h); + + auto l = new dttext; + l->where = h; + l->size = size; + l->caption = cap; + dt_add(b, l); + } + dtshape *load_shape(hstream& hs) { char type = hs.get(); switch(type) {