|
7759 | 7759 | "todo": null,
|
7760 | 7760 | "summary": "Gets a text's paragraph style or gets a paragraph style by name.",
|
7761 | 7761 | "codetitle": "paragraphStyle(textOrName, [props])"
|
| 7762 | + }, |
| 7763 | + { |
| 7764 | + "name": "createOutlines", |
| 7765 | + "description": "Returns an array of polygons after outlining text and optionally processes them with a callback function.\nUse together with `pathToPoints()` for getting point and bezier coordinates from outlines. If used on a text frame,\nall linked text frames will be converted to outlines as well.", |
| 7766 | + "returns": { |
| 7767 | + "name": null, |
| 7768 | + "description": "Returns an array of polygons.", |
| 7769 | + "type": [ |
| 7770 | + "Array" |
| 7771 | + ] |
| 7772 | + }, |
| 7773 | + "category": "Typography", |
| 7774 | + "subcategory": null, |
| 7775 | + "parameters": [ |
| 7776 | + { |
| 7777 | + "name": "item", |
| 7778 | + "description": "Text or TextPath to be outlined.", |
| 7779 | + "optional": false, |
| 7780 | + "type": [ |
| 7781 | + "TextFrame", |
| 7782 | + "TextPath" |
| 7783 | + ] |
| 7784 | + }, |
| 7785 | + { |
| 7786 | + "name": "cb", |
| 7787 | + "description": "Optional: Callback function to use with each polygon. Passed arguments: `obj`, `loopCounter`", |
| 7788 | + "optional": true, |
| 7789 | + "type": [ |
| 7790 | + "Function" |
| 7791 | + ] |
| 7792 | + } |
| 7793 | + ], |
| 7794 | + "kind": "function", |
| 7795 | + "tags": [ |
| 7796 | + { |
| 7797 | + "title": "summary", |
| 7798 | + "description": "Convert text items to outlines." |
| 7799 | + }, |
| 7800 | + { |
| 7801 | + "title": "description", |
| 7802 | + "description": "Returns an array of polygons after outlining text and optionally processes them with a callback function.\nUse together with `pathToPoints()` for getting point and bezier coordinates from outlines. If used on a text frame,\nall linked text frames will be converted to outlines as well." |
| 7803 | + } |
| 7804 | + ], |
| 7805 | + "examples": [ |
| 7806 | + { |
| 7807 | + "description": "Convert text to outlines", |
| 7808 | + "code": "textSize(150);\nvar myText = text(\"Hello\", 0, 0, width, height);\nvar outlines = createOutlines(myText);" |
| 7809 | + }, |
| 7810 | + { |
| 7811 | + "description": "Run a callback function on each resulting shape", |
| 7812 | + "code": "textSize(150);\nvar myText = text(\"Hello \\nWorld\", 0, 0, width, height);\nvar outlines = createOutlines(myText, function(obj){\n var pts = pathToPoints(obj);\n println(pts.length); // check number of points\n});" |
| 7813 | + } |
| 7814 | + ], |
| 7815 | + "todo": null, |
| 7816 | + "summary": "Convert text items to outlines.", |
| 7817 | + "codetitle": "createOutlines(item, [cb])" |
7762 | 7818 | }
|
7763 | 7819 | ],
|
7764 | 7820 | "cat": "Typography"
|
|
9994 | 10050 | "todo": null,
|
9995 | 10051 | "summary": "Adds a vertex during drawing complex paths or shapes.",
|
9996 | 10052 | "codetitle": "vertex(x, y, [xLeftHandle], [yLeftHandle], [xRightHandle], [yRightHandle])"
|
| 10053 | + }, |
| 10054 | + { |
| 10055 | + "name": "pathToPoints", |
| 10056 | + "description": "Returns an object containing an array of all points, an array of all beziers (points + their anchor points) and an array of all paths (containing its array of points + beziers) of a given pageItem in InDesign. Together with `createOutlines()` this can be used on text items. Accepts both single paths or a collection/group of paths.\nWhen using this on a multi path object (e.g. text with separate paths), the `paths` property can be used to loop over every path separately, whereas the properties `points` and `beziers` contain arrays for all paths combined.\nAn optional second parameter adds interpolated points between existing points, which is helpful for subdividing existing paths.", |
| 10057 | + "returns": { |
| 10058 | + "name": null, |
| 10059 | + "description": "Returns object with the following arrays `points`, `beziers`, `paths`", |
| 10060 | + "type": [ |
| 10061 | + "Object" |
| 10062 | + ] |
| 10063 | + }, |
| 10064 | + "category": "Shape", |
| 10065 | + "subcategory": null, |
| 10066 | + "parameters": [ |
| 10067 | + { |
| 10068 | + "name": "obj", |
| 10069 | + "description": "The pageItem(s) to process point/bezier coordinates of.", |
| 10070 | + "optional": false, |
| 10071 | + "type": [ |
| 10072 | + "Object" |
| 10073 | + ] |
| 10074 | + }, |
| 10075 | + { |
| 10076 | + "name": "addPoints", |
| 10077 | + "description": "Optional amount of additional interpolated points.", |
| 10078 | + "optional": true, |
| 10079 | + "type": [ |
| 10080 | + "Number" |
| 10081 | + ] |
| 10082 | + } |
| 10083 | + ], |
| 10084 | + "kind": "function", |
| 10085 | + "tags": [ |
| 10086 | + { |
| 10087 | + "title": "summary", |
| 10088 | + "description": "Get points and bezier coordinates from path(s)." |
| 10089 | + }, |
| 10090 | + { |
| 10091 | + "title": "description", |
| 10092 | + "description": "Returns an object containing an array of all points, an array of all beziers (points + their anchor points) and an array of all paths (containing its array of points + beziers) of a given pageItem in InDesign. Together with `createOutlines()` this can be used on text items. Accepts both single paths or a collection/group of paths.\nWhen using this on a multi path object (e.g. text with separate paths), the `paths` property can be used to loop over every path separately, whereas the properties `points` and `beziers` contain arrays for all paths combined.\nAn optional second parameter adds interpolated points between existing points, which is helpful for subdividing existing paths." |
| 10093 | + } |
| 10094 | + ], |
| 10095 | + "examples": [ |
| 10096 | + { |
| 10097 | + "description": "Draw all points of a vector path", |
| 10098 | + "code": "noFill();\nvar myCircle = ellipse(width / 2, height / 2, width / 2, width / 2);\nvar pts = pathToPoints(myCircle);\n\nfor (var i = 0; i < pts.points.length; i++) {\n var pt = pts.points[i];\n ellipse(pt.x, pt.y, 3, 3);\n}" |
| 10099 | + }, |
| 10100 | + { |
| 10101 | + "description": "With Interpolation between Points", |
| 10102 | + "code": "noFill();\nvar myCircle = ellipse(width / 2, height / 2, width / 2, width / 2);\nvar pts = pathToPoints(myCircle, 5); // add 5 points between each point\n\nfor (var i = 0; i < pts.points.length; i++) {\n var pt = pts.points[i];\n ellipse(pt.x, pt.y, 3, 3);\n}" |
| 10103 | + }, |
| 10104 | + { |
| 10105 | + "description": "Draw Beziers and handles from Path", |
| 10106 | + "code": "noFill();\ntextSize(400);\nvar myText = text('S', 0, 0, width, height);\nvar myOutlines = createOutlines(myText);\nvar pts = pathToPoints(myOutlines);\n\nbeginShape();\nfor (var i = 0; i < pts.beziers.length; i++) {\n var bz = pts.beziers[i];\n vertex(bz.anchor.x, bz.anchor.y, bz.left.x, bz.left.y, bz.right.x, bz.right.y);\n line(bz.anchor.x, bz.anchor.y, bz.left.x, bz.left.y); // left handle\n line(bz.anchor.x, bz.anchor.y, bz.right.x, bz.right.y); // right handle\n}\nendShape(CLOSE);" |
| 10107 | + }, |
| 10108 | + { |
| 10109 | + "description": "Separated Paths of Beziers", |
| 10110 | + "code": "noFill();\ntextSize(400);\nvar myText = text('B', 0, 0, width, height);\nvar myOutlines = createOutlines(myText);\nvar pts = pathToPoints(myOutlines); // add 3 for more detail\n\nfor (var j = 0; j < pts.paths.length; j++) {\n var path = pts.paths[j];\n\n beginShape();\n for (var i = 0; i < path.beziers.length; i++) {\n var bz = path.beziers[i];\n vertex(bz.anchor.x, bz.anchor.y, bz.left.x, bz.left.y, bz.right.x, bz.right.y);\n line(bz.anchor.x, bz.anchor.y, bz.left.x, bz.left.y); // left handle\n line(bz.anchor.x, bz.anchor.y, bz.right.x, bz.right.y); // right handle\n }\n endShape(CLOSE);\n}" |
| 10111 | + } |
| 10112 | + ], |
| 10113 | + "todo": null, |
| 10114 | + "summary": "Get points and bezier coordinates from path(s).", |
| 10115 | + "codetitle": "pathToPoints(obj, [addPoints])" |
9997 | 10116 | }
|
9998 | 10117 | ],
|
9999 | 10118 | "cat": "Shape"
|
|
0 commit comments