Skip to content

Commit 9b7048e

Browse files
committed
Update textToPaths example for cubic + quadratic
1 parent 1dc9805 commit 9b7048e

File tree

4 files changed

+103
-88
lines changed

4 files changed

+103
-88
lines changed

docs/parameterData.json

Lines changed: 71 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,6 @@
382382
]
383383
]
384384
},
385-
"sketchVerifier": {
386-
"overloads": [
387-
[]
388-
]
389-
},
390385
"setup": {
391386
"overloads": [
392387
[]
@@ -1855,6 +1850,50 @@
18551850
]
18561851
]
18571852
},
1853+
"bezierOrder": {
1854+
"overloads": [
1855+
[],
1856+
[
1857+
"Number"
1858+
]
1859+
]
1860+
},
1861+
"splineVertex": {
1862+
"overloads": [
1863+
[
1864+
"Number",
1865+
"Number",
1866+
"Number?",
1867+
"Number?"
1868+
],
1869+
[
1870+
"Number",
1871+
"Number",
1872+
"Number",
1873+
"Number?",
1874+
"Number?"
1875+
]
1876+
]
1877+
},
1878+
"splineProperty": {
1879+
"overloads": [
1880+
[
1881+
"String"
1882+
],
1883+
[
1884+
"String",
1885+
null
1886+
]
1887+
]
1888+
},
1889+
"splineProperties": {
1890+
"overloads": [
1891+
[],
1892+
[
1893+
"Object"
1894+
]
1895+
]
1896+
},
18581897
"vertex": {
18591898
"overloads": [
18601899
[
@@ -1864,12 +1903,13 @@
18641903
[
18651904
"Number",
18661905
"Number",
1906+
"Number?",
18671907
"Number?"
18681908
],
18691909
[
18701910
"Number",
18711911
"Number",
1872-
"Number?",
1912+
"Number",
18731913
"Number?",
18741914
"Number?"
18751915
]
@@ -1899,21 +1939,15 @@
18991939
[
19001940
"Number",
19011941
"Number",
1902-
"Number",
1903-
"Number",
1904-
"Number",
1905-
"Number"
1942+
"Number?",
1943+
"Number?"
19061944
],
19071945
[
19081946
"Number",
19091947
"Number",
19101948
"Number",
1911-
"Number",
1912-
"Number",
1913-
"Number",
1914-
"Number",
1915-
"Number",
1916-
"Number"
1949+
"Number?",
1950+
"Number?"
19171951
]
19181952
]
19191953
},
@@ -1955,11 +1989,6 @@
19551989
[
19561990
"String",
19571991
"Number|Number[]"
1958-
],
1959-
[
1960-
"String",
1961-
"Number|Number[]",
1962-
"Number?"
19631992
]
19641993
]
19651994
},
@@ -3090,22 +3119,6 @@
30903119
[]
30913120
]
30923121
},
3093-
"findClosestSchema": {
3094-
"overloads": [
3095-
[
3096-
"z.ZodSchema",
3097-
"Array"
3098-
]
3099-
]
3100-
},
3101-
"validate": {
3102-
"overloads": [
3103-
[
3104-
"String",
3105-
"Array"
3106-
]
3107-
]
3108-
},
31093122
"createVideo": {
31103123
"overloads": [
31113124
[
@@ -3131,31 +3144,6 @@
31313144
"Function?"
31323145
]
31333146
]
3134-
},
3135-
"bezierOrder": {
3136-
"overloads": [
3137-
[]
3138-
]
3139-
},
3140-
"splineVertex": {
3141-
"overloads": [
3142-
[]
3143-
]
3144-
},
3145-
"splineProperty": {
3146-
"overloads": [
3147-
[
3148-
"String",
3149-
null
3150-
]
3151-
]
3152-
},
3153-
"splineProperties": {
3154-
"overloads": [
3155-
[
3156-
"Object?"
3157-
]
3158-
]
31593147
}
31603148
},
31613149
"p5.Geometry": {
@@ -3201,6 +3189,15 @@
32013189
"overloads": [
32023190
[]
32033191
]
3192+
},
3193+
"vertexProperty": {
3194+
"overloads": [
3195+
[
3196+
"String",
3197+
"Number|Number[]",
3198+
"Number?"
3199+
]
3200+
]
32043201
}
32053202
},
32063203
"p5.Color": {
@@ -4505,6 +4502,18 @@
45054502
}
45064503
},
45074504
"p5.Font": {
4505+
"textToPaths": {
4506+
"overloads": [
4507+
[
4508+
"String",
4509+
"Number",
4510+
"Number",
4511+
"Number?",
4512+
"Number?",
4513+
"Object?"
4514+
]
4515+
]
4516+
},
45084517
"textToPoints": {
45094518
"overloads": [
45104519
[

src/shape/custom_shapes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,11 +1584,11 @@ function customShapes(p5, fn) {
15841584
// ---- FUNCTIONS ----
15851585

15861586
/**
1587-
* @method beierOrder
1587+
* @method bezierOrder
15881588
* @returns {Number} The current bezier order.
15891589
*/
15901590
/**
1591-
* @method beierOrder
1591+
* @method bezierOrder
15921592
* @param {Number} order The new order to set.
15931593
*/
15941594
fn.bezierOrder = function(order) {

src/shape/vertex.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,10 @@ function vertex(p5, fn){
429429
* <a href="#/p5/beginShape">beginShape()</a>.
430430
*
431431
* @method bezierVertex
432-
* @param {Number} x2 x-coordinate of the first control point.
433-
* @param {Number} y2 y-coordinate of the first control point.
434-
* @param {Number} x3 x-coordinate of the second control point.
435-
* @param {Number} y3 y-coordinate of the second control point.
436-
* @param {Number} x4 x-coordinate of the anchor point.
437-
* @param {Number} y4 y-coordinate of the anchor point.
432+
* @param {Number} x x-coordinate of the first control point.
433+
* @param {Number} y y-coordinate of the first control point.
434+
* @param {Number} [u]
435+
* @param {Number} [v]
438436
*
439437
* @example
440438
* <div>
@@ -652,15 +650,11 @@ function vertex(p5, fn){
652650

653651
/**
654652
* @method bezierVertex
655-
* @param {Number} x2
656-
* @param {Number} y2
657-
* @param {Number} z2 z-coordinate of the first control point.
658-
* @param {Number} x3
659-
* @param {Number} y3
660-
* @param {Number} z3 z-coordinate of the second control point.
661-
* @param {Number} x4
662-
* @param {Number} y4
663-
* @param {Number} z4 z-coordinate of the anchor point.
653+
* @param {Number} x
654+
* @param {Number} y
655+
* @param {Number} z
656+
* @param {Number} [u]
657+
* @param {Number} [v]
664658
*/
665659
fn.bezierVertex = function(...args) {
666660
this._renderer.bezierVertex(...args);

src/type/p5.Font.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Font {
110110
* @param {Number} [height] Optional height for text wrapping.
111111
* @param {Object} [options] Configuration object for rendering text.
112112
* @return {Array<Array>} A flat array of path commands.
113-
*
113+
*
114114
* @example
115115
* <div>
116116
* <code>
@@ -128,7 +128,7 @@ class Font {
128128
* stroke(0);
129129
* noFill();
130130
* textSize(60);
131-
*
131+
*
132132
* // Get path commands for "Hello" (drawn at baseline x=50, y=100):
133133
* const pathCommands = font.textToPaths('Hello', 30, 110);
134134
*
@@ -154,15 +154,28 @@ class Font {
154154
* vertex(x, y);
155155
* break;
156156
* }
157+
* case 'Q': {
158+
* // Quadratic bezier
159+
* const cx = cmd[1];
160+
* const cy = cmd[2];
161+
* const x = cmd[3];
162+
* const y = cmd[4];
163+
* bezierOrder(2);
164+
* bezierVertex(cx, cy);
165+
* bezierVertex(x, y);
166+
* break;
167+
* }
157168
* case 'C': {
158169
* // Cubic bezier
159-
* // Simplified to just draw line to endpoint
160-
* const cx = cmd[3];
161-
* const cy = cmd[4];
170+
* const cx1 = cmd[1];
171+
* const cy1 = cmd[2];
172+
* const cx2 = cmd[3];
173+
* const cy2 = cmd[4];
162174
* const x = cmd[5];
163175
* const y = cmd[6];
164-
* bezierOrder(2);
165-
* bezierVertex(cx, cy);
176+
* bezierOrder(3);
177+
* bezierVertex(cx1, cy1);
178+
* bezierVertex(cx2, cy2);
166179
* bezierVertex(x, y);
167180
* break;
168181
* }
@@ -176,12 +189,11 @@ class Font {
176189
* }
177190
* endContour();
178191
* endShape();
179-
*
180192
* }
181193
* </code>
182194
* </div>
183195
*/
184-
196+
185197
textToPaths(str, x, y, width, height, options) {
186198

187199
({ width, height, options } = this._parseArgs(width, height, options));

0 commit comments

Comments
 (0)