1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 09:33:26 +01:00
This commit is contained in:
Justin Lin 2019-06-16 16:47:44 +08:00
parent 61c6e9f70d
commit 323e81a82c

View File

@ -41,32 +41,23 @@ function _shape_path_extend_stroke(stroke_pts, p1, p2, scale_step, i) =
rotate_p(p * (1 + scale_step * i) + [0, leng], a) + p1 rotate_p(p * (1 + scale_step * i) + [0, leng], a) + p1
]; ];
function _shape_path_extend_inner(stroke_pts, path_pts, leng_path_pts, scale_step, index) = function _shape_path_extend_inner(stroke_pts, path_pts, leng_path_pts, scale_step) =
index == leng_path_pts ? [] : [
concat( for(i = 1; i < leng_path_pts; i = i + 1)
[ _shape_path_extend_stroke(
_shape_path_extend_stroke(
stroke_pts,
path_pts[index - 1],
path_pts[index],
scale_step,
index
)
],
_shape_path_extend_inner(
stroke_pts, stroke_pts,
path_pts, path_pts[i - 1],
leng_path_pts, path_pts[i ],
scale_step, scale_step,
index + 1 i
) )
); ];
function shape_path_extend(stroke_pts, path_pts, scale = 1.0, closed = false) = function shape_path_extend(stroke_pts, path_pts, scale = 1.0, closed = false) =
let( let(
leng_path_pts = len(path_pts), leng_path_pts = len(path_pts),
scale_step = (scale - 1) / (leng_path_pts - 1), scale_step = (scale - 1) / (leng_path_pts - 1),
strokes = _shape_path_extend_inner(stroke_pts, path_pts, leng_path_pts, scale_step, 1) strokes = _shape_path_extend_inner(stroke_pts, path_pts, leng_path_pts, scale_step)
) )
closed && path_pts[0] == path_pts[leng_path_pts - 1] ? closed && path_pts[0] == path_pts[leng_path_pts - 1] ?
__polytransversals(concat(strokes, [strokes[0]])) : __polytransversals(concat(strokes, [strokes[0]])) :