Merge pull request #736 from revarbat/revarbat_dev

Enable endcap1 for stroke() with a single-vertex path.
This commit is contained in:
Revar Desmera 2021-11-18 19:56:14 -08:00 committed by GitHub
commit 220af82d31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 6 deletions

View file

@ -156,6 +156,8 @@ function stroke(
trim, trim1, trim2,
convexity=10, hull=true
) = no_function("stroke");
module stroke(
path, width=1, closed,
endcaps, endcap1, endcap2, joints, dots,
@ -297,9 +299,33 @@ module stroke(
if (len(path) == 1) {
if (len(path[0]) == 2) {
translate(path[0]) circle(d=width[0]);
// Endcap1
setcolor(endcap_color1) {
translate(path[0]) {
mat = is_undef(endcap_angle1)? ident(3) : zrot(endcap_angle1);
multmatrix(mat) polygon(endcap_shape1);
}
}
} else {
translate(path[0]) sphere(d=width[0]);
// Endcap1
setcolor(endcap_color1) {
translate(path[0]) {
$fn = segs(width[0]/2);
if (is_undef(endcap_angle1)) {
rotate_extrude(convexity=convexity) {
right_half(planar=true) {
polygon(endcap_shape1);
}
}
} else {
rotate([90,0,endcap_angle1]) {
linear_extrude(height=max(widths[0],0.001), center=true, convexity=convexity) {
polygon(endcap_shape1);
}
}
}
}
}
}
} else {
dummy=assert(trim1<path_length(path)-trim2, "Path is too short for endcap(s). Try a smaller width, or set endcap_length to a smaller value.");

View file

@ -137,7 +137,7 @@ hexagon(d=50, anchor=LEFT);
```
```openscad-2D
oval(d=[50,30], anchor=FRONT);
ellipse(d=[50,30], anchor=FRONT);
```
@ -166,7 +166,7 @@ square([40,30], spin=30);
```
```openscad-2D
oval(d=[40,30], spin=30);
ellipse(d=[40,30], spin=30);
```
@ -821,10 +821,10 @@ module ovalish(l,rx1,ry1,rx2,ry2, anchor=CENTER, spin=0, orient=UP) {
hull() {
up(l/2-0.005)
linear_extrude(height=0.01, center=true)
oval([rx2,ry2]);
ellipse([rx2,ry2]);
down(l/2-0.005)
linear_extrude(height=0.01, center=true)
oval([rx1,ry1]);
ellipse([rx1,ry1]);
}
children();
}