MCPcopy Index your code
hub / github.com/processing/p5.js / textToContours

Method textToContours

src/type/p5.Font.js:341–354  ·  view source on GitHub ↗

* Returns an array of arrays of points outlining a string of text written using the * font. Each array represents a contour, so the letter O will have two outer arrays: * one for the outer edge of the shape, and one for the inner edge of the hole. * * Each point object in a contour array

(str, x = 0, y = 0, width, height, options)

Source from the content-addressed store, hash-verified

339 * }
340 */
341 textToContours(str, x = 0, y = 0, width, height, options) {
342 ({ width, height, options } = this._parseArgs(width, height, options));
343
344 const cmds = this.textToPaths(str, x, y, width, height, options);
345 const cmdContours = [];
346 for (const cmd of cmds) {
347 if (cmd[0] === 'M') {
348 cmdContours.push([]);
349 }
350 cmdContours[cmdContours.length - 1].push(cmd);
351 }
352
353 return cmdContours.map(commands => pathToPoints(commands, options, this));
354 }
355 /**
356 *
357 * Converts text into a 3D model that can be rendered in WebGL mode.

Callers 4

textToPointsMethod · 0.95
textToModelMethod · 0.95
drawFunction · 0.80
typography.jsFile · 0.80

Calls 4

_parseArgsMethod · 0.95
textToPathsMethod · 0.95
pathToPointsFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected