diff --git a/docs/lib-arc.md b/docs/lib-arc.md index acc3f891..bf17f5d8 100644 --- a/docs/lib-arc.md +++ b/docs/lib-arc.md @@ -6,7 +6,7 @@ Create an arc. You can pass a 2 element vector to define the central angle. It p - `radius` : The radius of the circle. - `angles` : A 2 element vector which defines the central angle. The first element of the vector is the beginning angle in degrees, and the second element is the ending angle. -- `width_mode` : The default value is `LINE_CROSS`. The arc line will move outward by `width /2` and inward by `width / 2`. If it's `LINE_OUTWARD`, the arc line moves outward by `width`. The `LINE_INWARD` moves the arc line inward by `width`. +- `width_mode` : The default value is `"LINE_CROSS"`. The arc line will move outward by `width /2` and inward by `width / 2`. If it's `"LINE_OUTWARD"`, the arc line moves outward by `width`. The `"LINE_INWARD"` moves the arc line inward by `width`. - `fn` : The `$fn` value used by the `circle` module internally. The default value is 24. ## Examples @@ -16,12 +16,12 @@ Create an arc. You can pass a 2 element vector to define the central angle. It p ![arc](images/lib-arc-1.JPG) - arc(radius = 20, angles = [45, 290], width = 2); + arc(radius = 20, angles = [45, 290], width = 2, width_mode = "LINE_INWARD"); %circle(r = 20, $fn = 24); ![arc](images/lib-arc-2.JPG) - arc(radius = 20, angles = [45, 290], width = 2, width_mode = LINE_OUTWARD); + arc(radius = 20, angles = [45, 290], width = 2, width_mode = "LINE_OUTWARD"); %circle(r = 20, $fn = 24); ![arc](images/lib-arc-3.JPG) diff --git a/docs/lib-line2d.md b/docs/lib-line2d.md index 82b3dafa..c5def092 100644 --- a/docs/lib-line2d.md +++ b/docs/lib-line2d.md @@ -7,9 +7,9 @@ Creates a line from two points. - `p1` : 2 element vector `[x, y]`. - `p2` : 2 element vector `[x, y]`. - `width` : The line width. -- `p1Style` : The end-cap style of the point `p1`. The value must be `CAP_BUTT`, `CAP_SQUARE` or `CAP_ROUND`. The default value is `CAP_SQUARE`. -- `p2Style` : The end-cap style of the point `p2`. The value must be `CAP_BUTT`, `CAP_SQUARE` or `CAP_ROUND`. The default value is `CAP_SQUARE`. -- `round_fn` : When the end-cap style is `CAP_ROUND`, it controlls the `$fn` value used by the `circle` module. The default value is `24`. +- `p1Style` : The end-cap style of the point `p1`. The value must be `"CAP_BUTT"`, `"CAP_SQUARE"` or `"CAP_ROUND"`. The default value is `"CAP_SQUARE"`. +- `p2Style` : The end-cap style of the point `p2`. The value must be `"CAP_BUTT"`, `"CAP_SQUARE"` or `"CAP_ROUND"`. The default value is `"CAP_SQUARE"`. +- `round_fn` : When the end-cap style is `"CAP_ROUND"`, it controlls the `$fn` value used by the `circle` module. The default value is `24`. ## Examples @@ -17,10 +17,10 @@ Creates a line from two points. translate([0, -2, 0]) line2d(p1 = [0, 0], p2 = [5, 0], width = 1, - p1Style = CAP_ROUND, p2Style = CAP_ROUND); + p1Style = "CAP_ROUND", p2Style = "CAP_ROUND"); translate([0, -4, 0]) line2d(p1 = [0, 0], p2 = [5, 0], width = 1, - p1Style = CAP_BUTT, p2Style = CAP_BUTT); + p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); ![line2d](images/lib-line2d-1.JPG) diff --git a/docs/lib-line3d.md b/docs/lib-line3d.md index 706f8403..52ec2631 100644 --- a/docs/lib-line3d.md +++ b/docs/lib-line3d.md @@ -7,8 +7,8 @@ Creates a 3D line from two points. - `p1` : 3 element vector `[x, y, z]`. - `p2` : 3 element vector `[x, y, z]`. - `thickness` : The line thickness. -- `p1Style` : The end-cap style of the point `p1`. The value must be `CAP_BUTT`, `CAP_CIRCLE` or `CAP_SPHERE`. The default value is `CAP_CIRCLE`. -- `p2Style` : The end-cap style of the point `p2`. The value must be `CAP_BUTT`, `CAP_CIRCLE` or `CAP_SPHERE`. The default value is `CAP_CIRCLE`. +- `p1Style` : The end-cap style of the point `p1`. The value must be `"CAP_BUTT"`, `"CAP_CIRCLE"` or `"CAP_SPHERE"`. The default value is `"CAP_CIRCLE"`. +- `p2Style` : The end-cap style of the point `p2`. The value must be `"CAP_BUTT"`, `"CAP_CIRCLE"` or `"CAP_SPHERE"`. The default value is `"CAP_CIRCLE"`. - `fn` : It controlls the `$fn` value used by the `circle` or `sphere` module. The default value is `24`. ## Examples @@ -25,8 +25,8 @@ Creates a 3D line from two points. p1 = [0, 0, 0], p2 = [10, 2, 10], thickness = 1, - p1Style = CAP_BUTT, - p2Style = CAP_BUTT + p1Style = "CAP_BUTT", + p2Style = "CAP_BUTT" ); ![line3d](images/lib-line3d-2.JPG) @@ -35,8 +35,8 @@ Creates a 3D line from two points. p1 = [0, 0, 0], p2 = [10, 2, 10], thickness = 1, - p1Style = CAP_SPHERE, - p2Style = CAP_SPHERE + p1Style = "CAP_SPHERE", + p2Style = "CAP_SPHERE" ); ![line3d](images/lib-line3d-3.JPG) diff --git a/docs/lib-polyline2d.md b/docs/lib-polyline2d.md index 66692d0f..77b6f9dd 100644 --- a/docs/lib-polyline2d.md +++ b/docs/lib-polyline2d.md @@ -6,9 +6,9 @@ Creates a polyline from a list of `x`, `y` coordinates. It depends on the `line2 - `points` : The list of `x`, `y` points of the polyline. : A vector of 2 element vectors. The points are indexed from 0 to n-1. - `width` : The line width. -- `startingStyle` : The end-cap style of the starting point. The value must be `CAP_BUTT`, `CAP_SQUARE` or `CAP_ROUND` (defined in line2d.scad). The default value is `CAP_SQUARE`. -- endingStyle : The end-cap style of the ending point. The value must be `CAP_BUTT`, `CAP_SQUARE` or `CAP_ROUND` (defined in line2d.scad). The default value is `CAP_SQUARE`. -- `round_fn` : When the end-cap style is `CAP_ROUND`, it controlls the `$fn` value used by the `circle` module. The default value is `24`. +- `startingStyle` : The end-cap style of the starting point. The value must be `"CAP_BUTT"`, `"CAP_SQUARE"` or `"CAP_ROUND"`. The default value is `"CAP_SQUARE"`. +- endingStyle : The end-cap style of the ending point. The value must be `"CAP_BUTT"`, `"CAP_SQUARE"` or `"CAP_ROUND"`. The default value is `"CAP_SQUARE"`. +- `round_fn` : When the end-cap style is "CAP_ROUND", it controlls the `$fn` value used by the `circle` module. The default value is `24`. ## Examples @@ -17,11 +17,11 @@ Creates a polyline from a list of `x`, `y` coordinates. It depends on the `line2 ![polyline2d](images/lib-polyline2d-1.JPG) polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1, - endingStyle = CAP_ROUND); + endingStyle = "CAP_ROUND"); ![polyline2d](images/lib-polyline2d-2.JPG) polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1, - startingStyle = CAP_ROUND, endingStyle = CAP_ROUND); + startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND"); ![polyline2d](images/lib-polyline2d-3.JPG) \ No newline at end of file diff --git a/docs/lib-polyline3d.md b/docs/lib-polyline3d.md index 5a69e6c7..43c92275 100644 --- a/docs/lib-polyline3d.md +++ b/docs/lib-polyline3d.md @@ -6,8 +6,8 @@ Creates a polyline from a list of `[x, y, z]` coordinates. It depends on the `li - `points` : The list of `[x, y, z]` points of the polyline. : A vector of 3 element vectors. The points are indexed from 0 to n-1. - `thickness` : The line thickness. -- `startingStyle` : The end-cap style of the starting point. The value must be `CAP_BUTT`, `CAP_CIRCLE` or `CAP_SPHERE` (defined in line3d.scad). The default value is `CAP_CIRCLE`. -- endingStyle : The end-cap style of the ending point. The value must be `CAP_BUTT`, `CAP_CIRCLE` or `CAP_SPHERE` (defined in line3d.scad). The default value is `CAP_CIRCLE`. +- `startingStyle` : The end-cap style of the starting point. The value must be `"CAP_BUTT"`, `"CAP_CIRCLE"` or `"CAP_SPHERE"`. The default value is `"CAP_CIRCL"`. +- endingStyle : The end-cap style of the ending point. The value must be `"CAP_BUTT"`, `"CAP_CIRCLE"` or `"CAP_SPHERE"`. The default value is `"CAP_CIRCLE"`. - `fn` : It controlls the `$fn` value used by the `circle` and `sphere` module. The default value is `24`. ## Examples @@ -32,7 +32,7 @@ Creates a polyline from a list of `[x, y, z]` coordinates. It depends on the `li [5, 5, 4] ], thickness = 1, - endingStyle = CAP_SPHERE + endingStyle = "CAP_SPHERE" ); ![polyline3d](images/lib-polyline3d-2.JPG) @@ -45,8 +45,8 @@ Creates a polyline from a list of `[x, y, z]` coordinates. It depends on the `li [5, 5, 4] ], thickness = 1, - startingStyle = CAP_SPHERE, - endingStyle = CAP_SPHERE + startingStyle = "CAP_SPHERE", + endingStyle = "CAP_SPHERE" ); ![polyline3d](images/lib-polyline3d-3.JPG) diff --git a/src/arc.scad b/src/arc.scad index 964d8d4c..9dfe47f0 100644 --- a/src/arc.scad +++ b/src/arc.scad @@ -12,14 +12,9 @@ * **/ - -LINE_CROSS = 0; -LINE_OUTWARD = 1; -LINE_INWARD = 2; - -module arc(radius, angles, width, width_mode = LINE_CROSS, fn = 24) { - w_offset = width_mode == LINE_CROSS ? [width / 2, -width / 2] : ( - width_mode == LINE_INWARD ? [0, -width] : [width, 0] +module arc(radius, angles, width, width_mode = "LINE_CROSS", fn = 24) { + w_offset = width_mode == "LINE_CROSS" ? [width / 2, -width / 2] : ( + width_mode == "LINE_INWARD" ? [0, -width] : [width, 0] ); difference() { diff --git a/src/line2d.scad b/src/line2d.scad index 14469b56..a2f1c7d5 100644 --- a/src/line2d.scad +++ b/src/line2d.scad @@ -10,12 +10,7 @@ * **/ -// The end-cap style -CAP_BUTT = 0; -CAP_SQUARE = 1; -CAP_ROUND = 2; - -module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_fn = 24) { +module line2d(p1, p2, width, p1Style = "CAP_SQUARE", p2Style = "CAP_SQUARE", round_fn = 24) { $fn = round_fn; half_width = 0.5 * width; @@ -44,15 +39,15 @@ module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_ circle(half_width, center = true); } - if(p1Style == CAP_SQUARE) { + if(p1Style == "CAP_SQUARE") { square_end(p1); - } else if(p1Style == CAP_ROUND) { + } else if(p1Style == "CAP_ROUND") { round_end(p1); } - if(p2Style == CAP_SQUARE) { + if(p2Style == "CAP_SQUARE") { square_end(p2); - } else if(p2Style == CAP_ROUND) { + } else if(p2Style == "CAP_ROUND") { round_end(p2); } } \ No newline at end of file diff --git a/src/line3d.scad b/src/line3d.scad index 0c4ccba4..1a7c2db6 100644 --- a/src/line3d.scad +++ b/src/line3d.scad @@ -10,11 +10,7 @@ * **/ -CAP_BUTT = 0; -CAP_CIRCLE = 1; -CAP_SPHERE = 2; - -module line3d(p1, p2, thickness, p1Style = CAP_CIRCLE, p2Style = CAP_CIRCLE, fn = 24) { +module line3d(p1, p2, thickness, p1Style = "CAP_CIRCLE", p2Style = "CAP_CIRCLE", fn = 24) { $fn = fn; r = thickness / 2; @@ -52,9 +48,9 @@ module line3d(p1, p2, thickness, p1Style = CAP_CIRCLE, p2Style = CAP_CIRCLE, fn } module cap(p, style) { - if(style == CAP_CIRCLE) { + if(style == "CAP_CIRCLE") { capCube(p); - } else if(style == CAP_SPHERE) { + } else if(style == "CAP_SPHERE") { if(fn > 4) { capSphere(p); } else { diff --git a/src/polyline2d.scad b/src/polyline2d.scad index 946803bc..374fa7bf 100644 --- a/src/polyline2d.scad +++ b/src/polyline2d.scad @@ -10,11 +10,11 @@ * **/ -module polyline2d(points, width, startingStyle = CAP_SQUARE, endingStyle = CAP_SQUARE, round_fn = 24) { +module polyline2d(points, width, startingStyle = "CAP_SQUARE", endingStyle = "CAP_SQUARE", round_fn = 24) { module line_segment(index) { - styles = index == 1 ? [startingStyle, CAP_ROUND] : ( - index == len(points) - 1 ? [CAP_ROUND, endingStyle] : [ - CAP_ROUND, CAP_ROUND + styles = index == 1 ? [startingStyle, "CAP_ROUND"] : ( + index == len(points) - 1 ? ["CAP_ROUND", endingStyle] : [ + "CAP_ROUND", "CAP_ROUND" ] ); diff --git a/src/polyline3d.scad b/src/polyline3d.scad index 4c64db3f..d35bcac3 100644 --- a/src/polyline3d.scad +++ b/src/polyline3d.scad @@ -11,11 +11,11 @@ * **/ -module polyline3d(points, thickness, startingStyle = CAP_CIRCLE, endingStyle = CAP_CIRCLE, fn = 24) { +module polyline3d(points, thickness, startingStyle = "CAP_CIRCLE", endingStyle = "CAP_CIRCLE", fn = 24) { module line_segment(index) { - styles = index == 1 ? [startingStyle, CAP_BUTT] : ( - index == len(points) - 1 ? [CAP_SPHERE, endingStyle] : [ - CAP_SPHERE, CAP_BUTT + styles = index == 1 ? [startingStyle, "CAP_BUTT"] : ( + index == len(points) - 1 ? ["CAP_SPHERE", endingStyle] : [ + "CAP_SPHERE", "CAP_BUTT" ] );