Open hjfreyer opened 4 years ago
Maybe this is working as intended, but I found it surprising.
var m = require("makerjs"); function box1() { return { paths: {}, origin: [0, 0], models: { inner: new m.models.Rectangle(10, 10) }, caption: { text: "B1", anchor: new m.paths.Line([5, 5], [5, 5]) } }; } function box2() { return { paths: {}, origin: [11, 0], models: { inner: new m.models.Rectangle(10, 10) }, caption: { text: "B2", anchor: new m.paths.Line([5, 5], [5, 5]) } }; } function main() { return { paths: {}, models: { box1: box1(), box2: box2() } }; } module.exports = main();
Each caption is in the middle of its box.
Captions are displayed on top of each other.
Calling originate() on the overall model puts the captions into their proper places:
originate()
function main() { return originate({ paths: {}, models: { box1: box1(), box2: box2() } }); }
I think this is very confusing, considering everything else is drawn relative to the model's origin.
If I put the caption in its own sub-model, then it works as I expected:
function box2() { return { paths: {}, origin: [11, 0], models: { inner: new m.models.Rectangle(10, 10), cap: { caption: { text: "B2", anchor: new m.paths.Line([5, 5], [5, 5]) } } } }; }
Is this the intended use case? If so addCaption is a little weird for not doing it that way.
addCaption
Thanks for pointing this out @hjfreyer - I believe your expectation is correct, I'll take a look.
Maybe this is working as intended, but I found it surprising.
Steps to reproduce
Expected result
Each caption is in the middle of its box.
Actual result
Captions are displayed on top of each other.
Workaround
Calling
originate()
on the overall model puts the captions into their proper places:Commentary
I think this is very confusing, considering everything else is drawn relative to the model's origin.
If I put the caption in its own sub-model, then it works as I expected:
Is this the intended use case? If so
addCaption
is a little weird for not doing it that way.