KCL: Convert x/y lines to use keyword arguments (#5615)
Previously, `xLine`, `xLineTo`, `yLine` and `yLineTo` used positional arguments. Now: - `xLineTo` and `yLineTo` have been removed - `xLine` and `yLine` both use keyword arguments: - `length`, optional (i.e. a relative distance along the X or Y axis) - `endAbsolute` optional (i.e. an absolute point along the X or Y axis) - `tag` optional - Exactly one of `length` or `endAbsolute` must be given. Not both, not neither. For example: ``` // Old way |> xLine(6.04, %) |> yLineTo(20, %, $base) // New way |> xLine(length = 6.04) |> yLine(endAbsolute = 20, tag = $base) ``` This also improves some of the general-purpose keyword arguments code in modeling app's TS codebase.
This commit is contained in:
		| @ -40,7 +40,7 @@ sketch001 = startSketchOn('XZ') | ||||
|        angle = angleToMatchLengthY(seg01, 15, %), | ||||
|        length = 5 | ||||
|      }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| extrusion = extrude(sketch001, length = 5) | ||||
|  | ||||
| @ -35,10 +35,10 @@ angledLine( | ||||
| ```js | ||||
| exampleSketch = startSketchOn(XZ) | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> yLineTo(15, %) | ||||
|   |> yLine(endAbsolute = 15) | ||||
|   |> angledLine({ angle = 30, length = 15 }, %) | ||||
|   |> line(end = [8, -10]) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 10) | ||||
|  | ||||
| @ -37,7 +37,7 @@ sketch001 = startSketchOn('XZ') | ||||
|        angle = toDegrees(asin(0.5)), | ||||
|        length = 20 | ||||
|      }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| extrude001 = extrude(sketch001, length = 5) | ||||
|  | ||||
| @ -37,7 +37,7 @@ sketch001 = startSketchOn('XZ') | ||||
|        angle = toDegrees(atan(1.25)), | ||||
|        length = 20 | ||||
|      }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| extrude001 = extrude(sketch001, length = 5) | ||||
|  | ||||
| @ -41,7 +41,7 @@ sketch001 = startSketchOn('XZ') | ||||
|        angle = toDegrees(atan2(1.25, 2)), | ||||
|        length = 20 | ||||
|      }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| extrude001 = extrude(sketch001, length = 5) | ||||
|  | ||||
| @ -35,7 +35,7 @@ sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> line(endAbsolute = [12, 10]) | ||||
|   |> line(end = [ceil(7.02986), 0]) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| extrude001 = extrude(sketch001, length = 5) | ||||
|  | ||||
| @ -21,7 +21,7 @@ exampleSketch = startSketchOn("XZ") | ||||
|     angle = 30, | ||||
|     length = 2 * E ^ 2, | ||||
|   }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 10) | ||||
|  | ||||
| @ -21,7 +21,7 @@ exampleSketch = startSketchOn("XZ") | ||||
|     angle = 50, | ||||
|     length = 10 * TAU, | ||||
|   }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -31,7 +31,7 @@ e(): number | ||||
| exampleSketch = startSketchOn("XZ") | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> angledLine({ angle = 30, length = 2 * e() ^ 2 }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 10) | ||||
|  | ||||
| @ -35,7 +35,7 @@ sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> line(endAbsolute = [12, 10]) | ||||
|   |> line(end = [floor(7.02986), 0]) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| extrude001 = extrude(sketch001, length = 5) | ||||
|  | ||||
| @ -131,9 +131,7 @@ layout: manual | ||||
|   * [`toRadians`](kcl/toRadians) | ||||
|   * [`translate`](kcl/translate) | ||||
|   * [`xLine`](kcl/xLine) | ||||
|   * [`xLineTo`](kcl/xLineTo) | ||||
|   * [`yLine`](kcl/yLine) | ||||
|   * [`yLineTo`](kcl/yLineTo) | ||||
|   * [`yd`](kcl/yd) | ||||
| * **std::math** | ||||
|   * [`E`](kcl/const_std-math-E) | ||||
|  | ||||
| @ -38,7 +38,7 @@ pow( | ||||
| exampleSketch = startSketchOn("XZ") | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> angledLine({ angle = 50, length = pow(5, 2) }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -35,7 +35,7 @@ sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> line(endAbsolute = [12, 10]) | ||||
|   |> line(end = [round(7.02986), 0]) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| extrude001 = extrude(sketch001, length = 5) | ||||
|  | ||||
| @ -34,7 +34,7 @@ sqrt(num: number): number | ||||
| exampleSketch = startSketchOn("XZ") | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> angledLine({ angle = 50, length = sqrt(2500) }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -137,9 +137,9 @@ a1 = startSketchOn({ | ||||
|      }) | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> line(end = [100.0, 0]) | ||||
|   |> yLine(-100.0, %) | ||||
|   |> xLine(-100.0, %) | ||||
|   |> yLine(100.0, %) | ||||
|   |> yLine(length = -100.0) | ||||
|   |> xLine(length = -100.0) | ||||
|   |> yLine(length = 100.0) | ||||
|   |> close() | ||||
|   |> extrude(length = 3.14) | ||||
| ``` | ||||
|  | ||||
| @ -33,7 +33,7 @@ exampleSketch = startSketchOn("XZ") | ||||
|     angle = 30, | ||||
|     length = 3 / cos(toRadians(30)), | ||||
|   }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -33,7 +33,7 @@ exampleSketch = startSketchOn("XZ") | ||||
|     angle = 50, | ||||
|     length = 15 / sin(toDegrees(135)), | ||||
|   }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -33,7 +33,7 @@ exampleSketch = startSketchOn("XZ") | ||||
|     angle = 50, | ||||
|     length = 50 * tan(1/2), | ||||
|   }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
							
								
								
									
										10330
									
								
								docs/kcl/std.json
									
									
									
									
									
								
							
							
						
						
									
										10330
									
								
								docs/kcl/std.json
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -31,7 +31,7 @@ tau(): number | ||||
| exampleSketch = startSketchOn("XZ") | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> angledLine({ angle = 50, length = 10 * tau() }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -37,7 +37,7 @@ exampleSketch = startSketchOn("XZ") | ||||
|        angle = 50, | ||||
|        length = 70 * cos(toDegrees(pi() / 4)) | ||||
|      }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -37,7 +37,7 @@ exampleSketch = startSketchOn("XZ") | ||||
|        angle = 50, | ||||
|        length = 70 * cos(toRadians(45)) | ||||
|      }, %) | ||||
|   |> yLineTo(0, %) | ||||
|   |> yLine(endAbsolute = 0) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 5) | ||||
|  | ||||
| @ -10,8 +10,9 @@ Draw a line relative to the current origin to a specified distance away from the | ||||
|  | ||||
| ```js | ||||
| xLine( | ||||
|   length: number, | ||||
|   sketch: Sketch, | ||||
|   length?: number, | ||||
|   endAbsolute?: number, | ||||
|   tag?: TagDeclarator, | ||||
| ): Sketch | ||||
| ``` | ||||
| @ -21,9 +22,10 @@ xLine( | ||||
|  | ||||
| | Name | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `length` | [`number`](/docs/kcl/types/number) |  | Yes | | ||||
| | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) |  | Yes | | ||||
| | [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) |  | No | | ||||
| | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes | | ||||
| | `length` | [`number`](/docs/kcl/types/number) | How far away along the X axis should this line go? Incompatible with `endAbsolute`. | No | | ||||
| | `endAbsolute` | [`number`](/docs/kcl/types/number) | Which absolute X value should this line go to? Incompatible with `length`. | No | | ||||
| | [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Create a new tag which refers to this line | No | | ||||
|  | ||||
| ### Returns | ||||
|  | ||||
| @ -35,12 +37,12 @@ xLine( | ||||
| ```js | ||||
| exampleSketch = startSketchOn(XZ) | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> xLine(15, %) | ||||
|   |> xLine(length = 15) | ||||
|   |> angledLine({ angle = 80, length = 15 }, %) | ||||
|   |> line(end = [8, -10]) | ||||
|   |> xLine(10, %) | ||||
|   |> xLine(length = 10) | ||||
|   |> angledLine({ angle = 120, length = 30 }, %) | ||||
|   |> xLine(-15, %) | ||||
|   |> xLine(length = -15) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 10) | ||||
|  | ||||
| @ -10,8 +10,9 @@ Draw a line relative to the current origin to a specified distance away from the | ||||
|  | ||||
| ```js | ||||
| yLine( | ||||
|   length: number, | ||||
|   sketch: Sketch, | ||||
|   length?: number, | ||||
|   endAbsolute?: number, | ||||
|   tag?: TagDeclarator, | ||||
| ): Sketch | ||||
| ``` | ||||
| @ -21,9 +22,10 @@ yLine( | ||||
|  | ||||
| | Name | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `length` | [`number`](/docs/kcl/types/number) |  | Yes | | ||||
| | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) |  | Yes | | ||||
| | [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) |  | No | | ||||
| | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes | | ||||
| | `length` | [`number`](/docs/kcl/types/number) | How far away along the Y axis should this line go? Incompatible with `endAbsolute`. | No | | ||||
| | `endAbsolute` | [`number`](/docs/kcl/types/number) | Which absolute Y value should this line go to? Incompatible with `length`. | No | | ||||
| | [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Create a new tag which refers to this line | No | | ||||
|  | ||||
| ### Returns | ||||
|  | ||||
| @ -35,10 +37,10 @@ yLine( | ||||
| ```js | ||||
| exampleSketch = startSketchOn(XZ) | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> yLine(15, %) | ||||
|   |> yLine(length = 15) | ||||
|   |> angledLine({ angle = 30, length = 15 }, %) | ||||
|   |> line(end = [8, -10]) | ||||
|   |> yLine(-5, %) | ||||
|   |> yLine(length = -5) | ||||
|   |> close() | ||||
|  | ||||
| example = extrude(exampleSketch, length = 10) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user