text in drawing tool (not yet addable)

This commit is contained in:
Zeno Rogue 2020-04-26 11:01:45 +02:00
parent 5b26fd0059
commit 38d668ee7c
1 changed files with 45 additions and 0 deletions

View File

@ -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<char>(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<char>();
switch(type) {