forked from microsoft/maker.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextOnChain.js
More file actions
34 lines (25 loc) · 1.24 KB
/
textOnChain.js
File metadata and controls
34 lines (25 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var makerjs = require('makerjs');
function TextOnChain(font, text, fontSize, baseline, reversed, contain, rotate, svgPathData, showPath) {
var textModel = new makerjs.models.Text(font, text, fontSize);
var svgPath = makerjs.importer.fromSVGPathData(svgPathData);
var chain = makerjs.model.findSingleChain(svgPath);
makerjs.layout.childrenOnChain(textModel, chain, baseline, reversed, contain, rotate);
this.models = {
text: textModel
};
if (showPath) {
this.models.svgPath = svgPath;
}
}
TextOnChain.metaParameters = [
{ title: "font", type: "font", value: '*' },
{ title: "text", type: "text", value: 'We go up, then we go down, then up again' },
{ title: "font size", type: "range", min: 1, max: 200, value: 42.5 },
{ title: "baseline", type: "range", min: -1, max: 2, step: 0.1, value: 0.5 },
{ title: "reversed", type: "bool", value: false },
{ title: "contain", type: "bool", value: false },
{ title: "rotate", type: "bool", value: true },
{ title: "svg path data", type: "text", value: 'M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100' },
{ title: "show path", type: "bool", value: true },
];
module.exports = TextOnChain;