-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I get the angle of the text created by model.Text()? #604
Comments
Hello, one thing to note is that your drawing is a plain object to which you can add your own properties: caption.rememberMyRotation = 55; Properties not used by Maker.js will remain untouched. Hope that helps. |
Ohhhh( This decision was one of the first in my head) But I thought that maybe someone solved the problem in a different way. My attempt to solve the problem without adding my own properties: export function getCircumscribedRectangleAngle(model) {
const { center, width, height, high } = makerjs.measure.modelExtents(model);
if (width >= height) {
const rightMiddle = [high[0], center[1]];
return makerjs.angle.ofPointInDegrees(center, rightMiddle);
} else {
const topMiddle = [center[0], high[1]];
return makerjs.angle.ofPointInDegrees(center, topMiddle);
}
} Has the development of the library stopped? A similar method would be very useful) |
That's a cool solution! There are probably corner cases where, with a font that has ascenders and descenders, the bounding rectangle will not correlate with the font baseline. But if all characters are the same height, it should do the job :) I have learned a lot (about computational geometry) while developing this library, and the JavaScript ecosystem has changed rapidly since I started. I'm always thinking of what I would do differently for the next version. So, I'm waiting for the right time to get leverage without as much work. Back to your issue, another idea: perhaps you can add a baseline Line path to your Text model prior to rotating? |
How can I find out how rotated the text is in another part of the program?
The text was updated successfully, but these errors were encountered: