Skip to content
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

childrenOnChain Problem #470

Open
Byteschmiede opened this issue Aug 5, 2020 · 3 comments
Open

childrenOnChain Problem #470

Byteschmiede opened this issue Aug 5, 2020 · 3 comments

Comments

@Byteschmiede
Copy link

Hey!

I'm playing around with layout.childrenOnChain and have question how to accomplish following task:

There is a curved path id like to use to position my text on it. Just like childrenOnChain.
The only problem is, that this method is built for text who covers the whole chain.

Example:

Text: Foobaafooba
Text on Path: F_o_o_b_a_a_f_o_o_b_a

Text: Foo
Text on Path: F___________o__________o

But I want to center on the path like:

Text on Path: Foo

here are Screenshots from the playground

Bildschirmfoto 2020-08-05 um 13 02 44

I hack fix it with pre- and post characters with spaces:
But that's too hacky for my choice

Bildschirmfoto 2020-08-05 um 13 03 21

@danmarshall
Copy link
Contributor

Hi @Byteschmiede - can you "clip" your chain? Perhaps do a boolean subtraction from a rectangle to get the piece you want.

@Byteschmiede
Copy link
Author

result

Hey Dan,

I tried my best but clipping a chain with a rect results to an endless chain.

@danmarshall
Copy link
Contributor

Hi @Byteschmiede , this is one of those situations where you can use the flags for boolean operations:

var m = require('makerjs');

var curve = new m.models.BezierCurve([[0, 100], [100,0], [200, 100]]);
var square = m.model.move(new m.models.Square(80), [60, 10]);
var rect = new m.models.Rectangle(200, 100);

this.models = { curve, square, rect };

m.model.combine(curve, square, true, false, false, false, {trimDeadEnds: false});

image
image

(the rectangle is just there because of a bug in the Playground canvas 😕)
Also, maybe the documentation shouldn't say Each model must be a closed geometry like it does. In this advanced case you can control which segments are kept and deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants