From eb3bd8da0a1a3daaa3d59092912b041ce8a0bec9 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Thu, 18 Nov 2021 19:33:57 -0800 Subject: [PATCH] Enable endcap1 for stroke() with a single-vertex path. --- drawing.scad | 30 ++++++++++++++++++++++++++++-- tutorials/Attachments.md | 8 ++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drawing.scad b/drawing.scad index dea89a6..ea2f070 100644 --- a/drawing.scad +++ b/drawing.scad @@ -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