mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-15 03:05:41 +02:00
integer to string
This commit is contained in:
@@ -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.
|
- `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.
|
- `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.
|
- `fn` : The `$fn` value used by the `circle` module internally. The default value is 24.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -16,12 +16,12 @@ Create an arc. You can pass a 2 element vector to define the central angle. It p
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
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);
|
%circle(r = 20, $fn = 24);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
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);
|
%circle(r = 20, $fn = 24);
|
||||||
|
|
||||||

|

|
||||||
|
@@ -7,9 +7,9 @@ Creates a line from two points.
|
|||||||
- `p1` : 2 element vector `[x, y]`.
|
- `p1` : 2 element vector `[x, y]`.
|
||||||
- `p2` : 2 element vector `[x, y]`.
|
- `p2` : 2 element vector `[x, y]`.
|
||||||
- `width` : The line width.
|
- `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`.
|
- `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`.
|
- `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`.
|
- `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
|
## Examples
|
||||||
|
|
||||||
@@ -17,10 +17,10 @@ Creates a line from two points.
|
|||||||
|
|
||||||
translate([0, -2, 0])
|
translate([0, -2, 0])
|
||||||
line2d(p1 = [0, 0], p2 = [5, 0], width = 1,
|
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])
|
translate([0, -4, 0])
|
||||||
line2d(p1 = [0, 0], p2 = [5, 0], width = 1,
|
line2d(p1 = [0, 0], p2 = [5, 0], width = 1,
|
||||||
p1Style = CAP_BUTT, p2Style = CAP_BUTT);
|
p1Style = "CAP_BUTT", p2Style = "CAP_BUTT");
|
||||||
|
|
||||||

|

|
||||||
|
@@ -7,8 +7,8 @@ Creates a 3D line from two points.
|
|||||||
- `p1` : 3 element vector `[x, y, z]`.
|
- `p1` : 3 element vector `[x, y, z]`.
|
||||||
- `p2` : 3 element vector `[x, y, z]`.
|
- `p2` : 3 element vector `[x, y, z]`.
|
||||||
- `thickness` : The line thickness.
|
- `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`.
|
- `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`.
|
- `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`.
|
- `fn` : It controlls the `$fn` value used by the `circle` or `sphere` module. The default value is `24`.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -25,8 +25,8 @@ Creates a 3D line from two points.
|
|||||||
p1 = [0, 0, 0],
|
p1 = [0, 0, 0],
|
||||||
p2 = [10, 2, 10],
|
p2 = [10, 2, 10],
|
||||||
thickness = 1,
|
thickness = 1,
|
||||||
p1Style = CAP_BUTT,
|
p1Style = "CAP_BUTT",
|
||||||
p2Style = CAP_BUTT
|
p2Style = "CAP_BUTT"
|
||||||
);
|
);
|
||||||
|
|
||||||

|

|
||||||
@@ -35,8 +35,8 @@ Creates a 3D line from two points.
|
|||||||
p1 = [0, 0, 0],
|
p1 = [0, 0, 0],
|
||||||
p2 = [10, 2, 10],
|
p2 = [10, 2, 10],
|
||||||
thickness = 1,
|
thickness = 1,
|
||||||
p1Style = CAP_SPHERE,
|
p1Style = "CAP_SPHERE",
|
||||||
p2Style = CAP_SPHERE
|
p2Style = "CAP_SPHERE"
|
||||||
);
|
);
|
||||||
|
|
||||||

|

|
||||||
|
@@ -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.
|
- `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.
|
- `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`.
|
- `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` (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"`. 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`.
|
- `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
|
## Examples
|
||||||
|
|
||||||
@@ -17,11 +17,11 @@ Creates a polyline from a list of `x`, `y` coordinates. It depends on the `line2
|
|||||||

|

|
||||||
|
|
||||||
polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1,
|
polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1,
|
||||||
endingStyle = CAP_ROUND);
|
endingStyle = "CAP_ROUND");
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1,
|
polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1,
|
||||||
startingStyle = CAP_ROUND, endingStyle = CAP_ROUND);
|
startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND");
|
||||||
|
|
||||||

|

|
@@ -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.
|
- `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.
|
- `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`.
|
- `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` (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"`. The default value is `"CAP_CIRCLE"`.
|
||||||
- `fn` : It controlls the `$fn` value used by the `circle` and `sphere` module. The default value is `24`.
|
- `fn` : It controlls the `$fn` value used by the `circle` and `sphere` module. The default value is `24`.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -32,7 +32,7 @@ Creates a polyline from a list of `[x, y, z]` coordinates. It depends on the `li
|
|||||||
[5, 5, 4]
|
[5, 5, 4]
|
||||||
],
|
],
|
||||||
thickness = 1,
|
thickness = 1,
|
||||||
endingStyle = CAP_SPHERE
|
endingStyle = "CAP_SPHERE"
|
||||||
);
|
);
|
||||||
|
|
||||||

|

|
||||||
@@ -45,8 +45,8 @@ Creates a polyline from a list of `[x, y, z]` coordinates. It depends on the `li
|
|||||||
[5, 5, 4]
|
[5, 5, 4]
|
||||||
],
|
],
|
||||||
thickness = 1,
|
thickness = 1,
|
||||||
startingStyle = CAP_SPHERE,
|
startingStyle = "CAP_SPHERE",
|
||||||
endingStyle = CAP_SPHERE
|
endingStyle = "CAP_SPHERE"
|
||||||
);
|
);
|
||||||
|
|
||||||

|

|
||||||
|
11
src/arc.scad
11
src/arc.scad
@@ -12,14 +12,9 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
module arc(radius, angles, width, width_mode = "LINE_CROSS", fn = 24) {
|
||||||
LINE_CROSS = 0;
|
w_offset = width_mode == "LINE_CROSS" ? [width / 2, -width / 2] : (
|
||||||
LINE_OUTWARD = 1;
|
width_mode == "LINE_INWARD" ? [0, -width] : [width, 0]
|
||||||
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]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
difference() {
|
difference() {
|
||||||
|
@@ -10,12 +10,7 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// The end-cap style
|
module line2d(p1, p2, width, p1Style = "CAP_SQUARE", p2Style = "CAP_SQUARE", round_fn = 24) {
|
||||||
CAP_BUTT = 0;
|
|
||||||
CAP_SQUARE = 1;
|
|
||||||
CAP_ROUND = 2;
|
|
||||||
|
|
||||||
module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_fn = 24) {
|
|
||||||
$fn = round_fn;
|
$fn = round_fn;
|
||||||
half_width = 0.5 * width;
|
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);
|
circle(half_width, center = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p1Style == CAP_SQUARE) {
|
if(p1Style == "CAP_SQUARE") {
|
||||||
square_end(p1);
|
square_end(p1);
|
||||||
} else if(p1Style == CAP_ROUND) {
|
} else if(p1Style == "CAP_ROUND") {
|
||||||
round_end(p1);
|
round_end(p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p2Style == CAP_SQUARE) {
|
if(p2Style == "CAP_SQUARE") {
|
||||||
square_end(p2);
|
square_end(p2);
|
||||||
} else if(p2Style == CAP_ROUND) {
|
} else if(p2Style == "CAP_ROUND") {
|
||||||
round_end(p2);
|
round_end(p2);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -10,11 +10,7 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
CAP_BUTT = 0;
|
module line3d(p1, p2, thickness, p1Style = "CAP_CIRCLE", p2Style = "CAP_CIRCLE", fn = 24) {
|
||||||
CAP_CIRCLE = 1;
|
|
||||||
CAP_SPHERE = 2;
|
|
||||||
|
|
||||||
module line3d(p1, p2, thickness, p1Style = CAP_CIRCLE, p2Style = CAP_CIRCLE, fn = 24) {
|
|
||||||
$fn = fn;
|
$fn = fn;
|
||||||
|
|
||||||
r = thickness / 2;
|
r = thickness / 2;
|
||||||
@@ -52,9 +48,9 @@ module line3d(p1, p2, thickness, p1Style = CAP_CIRCLE, p2Style = CAP_CIRCLE, fn
|
|||||||
}
|
}
|
||||||
|
|
||||||
module cap(p, style) {
|
module cap(p, style) {
|
||||||
if(style == CAP_CIRCLE) {
|
if(style == "CAP_CIRCLE") {
|
||||||
capCube(p);
|
capCube(p);
|
||||||
} else if(style == CAP_SPHERE) {
|
} else if(style == "CAP_SPHERE") {
|
||||||
if(fn > 4) {
|
if(fn > 4) {
|
||||||
capSphere(p);
|
capSphere(p);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -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) {
|
module line_segment(index) {
|
||||||
styles = index == 1 ? [startingStyle, CAP_ROUND] : (
|
styles = index == 1 ? [startingStyle, "CAP_ROUND"] : (
|
||||||
index == len(points) - 1 ? [CAP_ROUND, endingStyle] : [
|
index == len(points) - 1 ? ["CAP_ROUND", endingStyle] : [
|
||||||
CAP_ROUND, CAP_ROUND
|
"CAP_ROUND", "CAP_ROUND"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -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) {
|
module line_segment(index) {
|
||||||
styles = index == 1 ? [startingStyle, CAP_BUTT] : (
|
styles = index == 1 ? [startingStyle, "CAP_BUTT"] : (
|
||||||
index == len(points) - 1 ? [CAP_SPHERE, endingStyle] : [
|
index == len(points) - 1 ? ["CAP_SPHERE", endingStyle] : [
|
||||||
CAP_SPHERE, CAP_BUTT
|
"CAP_SPHERE", "CAP_BUTT"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user