Skip to content

Commit 3c688ca

Browse files
committed
Update params, mark hasGlyphData as private
1 parent 66bb5f8 commit 3c688ca

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

Diff for: src/type/p5.Font.js

+12-18
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Font {
6565
/**
6666
* Checks whether a font has glyph point data and
6767
* can thus be used for textToPoints(), WEBGL mode, etc.
68+
* @private
6869
*/
6970
static hasGlyphData(textFont) {
7071
let { font } = textFont;
@@ -117,11 +118,7 @@ class Font {
117118
* coordinates of the bounding box's bottom-left corner. See
118119
* <a href="#/p5/textAlign">textAlign()</a> for more ways to align text.
119120
*
120-
* The fourth parameter, `fontSize`, is optional. It sets the text's font
121-
* size. By default, `font.textToPoints()` will use the current
122-
* <a href="#/p5/textSize">textSize()</a>.
123-
*
124-
* The fifth parameter, `options`, is also optional. `font.textToPoints()`
121+
* The fourth parameter, `options`, is also optional. `font.textToPoints()`
125122
* expects an object with the following properties:
126123
*
127124
* `sampleFactor` is the ratio of the text's path length to the number of
@@ -135,8 +132,6 @@ class Font {
135132
* @param {String} str string of text.
136133
* @param {Number} x x-coordinate of the text.
137134
* @param {Number} y y-coordinate of the text.
138-
* @param {Number} [fontSize] font size. Defaults to the current
139-
* <a href="#/p5/textSize">textSize()</a>.
140135
* @param {Object} [options] object with sampleFactor and simplifyThreshold
141136
* properties.
142137
* @return {Array<Object>} array of point objects, each with `x`, `y`, and `alpha` (path angle) properties.
@@ -151,9 +146,10 @@ class Font {
151146
* font = await loadFont('assets/inconsolata.otf');
152147
*
153148
* background(200);
149+
* textSize(35);
154150
*
155151
* // Get the point array.
156-
* let points = font.textToPoints('p5*js', 6, 60, 35, { sampleFactor: 0.5 });
152+
* let points = font.textToPoints('p5*js', 6, 60, { sampleFactor: 0.5 });
157153
*
158154
* // Draw a dot at each point.
159155
* for (let p of points) {
@@ -188,11 +184,7 @@ class Font {
188184
* coordinates of the bounding box's bottom-left corner. See
189185
* <a href="#/p5/textAlign">textAlign()</a> for more ways to align text.
190186
*
191-
* The fourth parameter, `fontSize`, is optional. It sets the text's font
192-
* size. By default, `font.textToPoints()` will use the current
193-
* <a href="#/p5/textSize">textSize()</a>.
194-
*
195-
* The fifth parameter, `options`, is also optional. `font.textToPoints()`
187+
* The fourth parameter, `options`, is also optional. `font.textToPoints()`
196188
* expects an object with the following properties:
197189
*
198190
* `sampleFactor` is the ratio of the text's path length to the number of
@@ -206,8 +198,6 @@ class Font {
206198
* @param {String} str string of text.
207199
* @param {Number} x x-coordinate of the text.
208200
* @param {Number} y y-coordinate of the text.
209-
* @param {Number} [fontSize] font size. Defaults to the current
210-
* <a href="#/p5/textSize">textSize()</a>.
211201
* @param {Object} [options] object with sampleFactor and simplifyThreshold
212202
* properties.
213203
* @return {Array<Array<Object>>} array of point objects, each with `x`, `y`, and `alpha` (path angle) properties.
@@ -219,18 +209,22 @@ class Font {
219209
*
220210
* async function setup() {
221211
* createCanvas(100, 100);
222-
* font = await loadFont('assets/inconsolata.otf');
212+
* font = await loadFont('/assets/inconsolata.otf');
213+
* }
223214
*
215+
* function draw() {
224216
* background(200);
217+
* textAlign(CENTER, CENTER);
218+
* textSize(30);
225219
*
226220
* // Get the point array.
227-
* let contours = font.textToContours('p5*js', 6, 60, 35, { sampleFactor: 0.5 });
221+
* let contours = font.textToContours('p5*js', width/2, height/2, { sampleFactor: 0.5 });
228222
*
229223
* beginShape();
230224
* for (const pts of contours) {
231225
* beginContour();
232226
* for (const pt of pts) {
233-
* vertex(pt.x + 20*sin(pt.y*0.01), pt.y + 20*sin(pt.x*0.01));
227+
* vertex(pt.x + 5*sin(pt.y*0.1 + millis()*0.01), pt.y);
234228
* }
235229
* endContour(CLOSE);
236230
* }

0 commit comments

Comments
 (0)