-
Notifications
You must be signed in to change notification settings - Fork 275
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
Create Text with JSON model path #533
Comments
Hello, can you provide just the json that is retrieved ? |
Yes, this is my json response:
|
Here's a couple of things which you need to correct:
{
"type": "circle",
"origin": ["2150.4739", "2203.4505"],
"radius": 0.1
} Should be changed to: {
"type": "circle",
"origin": [2150.4739, 2203.4505],
"radius": 0.1
}
{
"type": "text",
"value": "Hello0",
"fontSize": 500
} You may want to look at captions for annotating with text. Or loading a font to render letterform outlines. |
Hello Dan! But i want have: I would like to generate these texts via json as well as other elements in my canvas |
First you will need to decide to use either captions or font-based Text outline models. If you decide to use captions, remember that you get only one caption per model. So, for multiple captions, just add more models. If you want to generate them on the server side, here's an example of the serialized JSON for a caption property on a model object: "caption": {
"text": "a square",
"anchor": {
"type": "line",
"origin": [
0,
50
],
"end": [
100,
50
]
}
}, Also note that captions currently do not allow a font size to be specified. This is to reduce complexity, and to ensure that captions remain visible at any zoom level or scaling with unit type conversions. If you need to specify the exact font and size (and are willing to have text converted to a bunch of raw lines & arcs), you'll need to load a font and then use the built-in Text model. Also note that you will get only outlines of letters, not filled as in your example. This is not something that you'll be able to do on the server side (unless you rewrite opentype.js and Maker.js in PHP 🤐 ). So, I would recommend passing your text specifications in a property that is a sibling to the model object, then modifying the model object on the client side JavaScript and creating Text models then. |
You have a model named “caption” with a “paths” property. You can name your model anything you like, but to avoid confusion for the moment, do not name it “caption”. Then you need a “caption” property on that model. Your json will work if you change “paths” to “caption”. |
Hello Dan, it not working :-( My JS:
My Json response:
Result: I check what give me "path = makerjs.exporter.toSVGPathData(data.routePath, { origin: [0, 0] });" , result in console.log or alert is "undefined" |
Captions are only exported as SVG, they are output as SVG elements: <text alignment-baseline="middle" text-anchor="middle" transform="rotate(0,50,50)" x="50" y="50">a square</text> So you may try |
Hello,
i have question, is it possible create text in json array (in php) and add text to canvas by 'toSVGPathData' ? i try similar to the points but it doesn't work :-(
Points:
Text:
After get model paths with ajax i append path to the div element:
Please HELP ME!
The text was updated successfully, but these errors were encountered: