@@ -65,6 +65,7 @@ class Font {
65
65
/**
66
66
* Checks whether a font has glyph point data and
67
67
* can thus be used for textToPoints(), WEBGL mode, etc.
68
+ * @private
68
69
*/
69
70
static hasGlyphData ( textFont ) {
70
71
let { font } = textFont ;
@@ -117,11 +118,7 @@ class Font {
117
118
* coordinates of the bounding box's bottom-left corner. See
118
119
* <a href="#/p5/textAlign">textAlign()</a> for more ways to align text.
119
120
*
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()`
125
122
* expects an object with the following properties:
126
123
*
127
124
* `sampleFactor` is the ratio of the text's path length to the number of
@@ -135,8 +132,6 @@ class Font {
135
132
* @param {String } str string of text.
136
133
* @param {Number } x x-coordinate of the text.
137
134
* @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>.
140
135
* @param {Object } [options] object with sampleFactor and simplifyThreshold
141
136
* properties.
142
137
* @return {Array<Object> } array of point objects, each with `x`, `y`, and `alpha` (path angle) properties.
@@ -151,9 +146,10 @@ class Font {
151
146
* font = await loadFont('assets/inconsolata.otf');
152
147
*
153
148
* background(200);
149
+ * textSize(35);
154
150
*
155
151
* // 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 });
157
153
*
158
154
* // Draw a dot at each point.
159
155
* for (let p of points) {
@@ -188,11 +184,7 @@ class Font {
188
184
* coordinates of the bounding box's bottom-left corner. See
189
185
* <a href="#/p5/textAlign">textAlign()</a> for more ways to align text.
190
186
*
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()`
196
188
* expects an object with the following properties:
197
189
*
198
190
* `sampleFactor` is the ratio of the text's path length to the number of
@@ -206,8 +198,6 @@ class Font {
206
198
* @param {String } str string of text.
207
199
* @param {Number } x x-coordinate of the text.
208
200
* @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>.
211
201
* @param {Object } [options] object with sampleFactor and simplifyThreshold
212
202
* properties.
213
203
* @return {Array<Array<Object>> } array of point objects, each with `x`, `y`, and `alpha` (path angle) properties.
@@ -219,18 +209,22 @@ class Font {
219
209
*
220
210
* async function setup() {
221
211
* createCanvas(100, 100);
222
- * font = await loadFont('assets/inconsolata.otf');
212
+ * font = await loadFont('/assets/inconsolata.otf');
213
+ * }
223
214
*
215
+ * function draw() {
224
216
* background(200);
217
+ * textAlign(CENTER, CENTER);
218
+ * textSize(30);
225
219
*
226
220
* // 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 });
228
222
*
229
223
* beginShape();
230
224
* for (const pts of contours) {
231
225
* beginContour();
232
226
* 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 );
234
228
* }
235
229
* endContour(CLOSE);
236
230
* }
0 commit comments