mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-01-16 21:58:27 +01:00
Fix stroke() for 1 point paths.
This commit is contained in:
parent
527fea1cf3
commit
620a536dbc
@ -114,7 +114,10 @@ module stroke(
|
|||||||
) * linewidth;
|
) * linewidth;
|
||||||
|
|
||||||
assert(is_bool(closed));
|
assert(is_bool(closed));
|
||||||
assert(is_path(path,[2,3]), "The path argument must be a list of 2D or 3D points.");
|
assert(is_list(path));
|
||||||
|
if (len(path) > 1) {
|
||||||
|
assert(is_path(path,[2,3]), "The path argument must be a list of 2D or 3D points.");
|
||||||
|
}
|
||||||
path = deduplicate( closed? close_path(path) : path );
|
path = deduplicate( closed? close_path(path) : path );
|
||||||
|
|
||||||
assert(is_num(width) || (is_vector(width) && len(width)==len(path)));
|
assert(is_num(width) || (is_vector(width) && len(width)==len(path)));
|
||||||
@ -164,18 +167,24 @@ module stroke(
|
|||||||
]);
|
]);
|
||||||
assert(is_num(trim2));
|
assert(is_num(trim2));
|
||||||
|
|
||||||
spos = path_pos_from_start(path,trim1,closed=false);
|
if (len(path) == 1) {
|
||||||
epos = path_pos_from_end(path,trim2,closed=false);
|
if (len(path[0]) == 2) {
|
||||||
path2 = path_subselect(path, spos[0], spos[1], epos[0], epos[1]);
|
translate(path[0]) circle(d=width[0]);
|
||||||
widths = concat(
|
} else {
|
||||||
[lerp(width[spos[0]], width[(spos[0]+1)%len(width)], spos[1])],
|
translate(path[0]) sphere(d=width[0]);
|
||||||
[for (i = [spos[0]+1:1:epos[0]]) width[i]],
|
}
|
||||||
[lerp(width[epos[0]], width[(epos[0]+1)%len(width)], epos[1])]
|
} else if (len(path[0]) == 2) {
|
||||||
);
|
spos = path_pos_from_start(path,trim1,closed=false);
|
||||||
|
epos = path_pos_from_end(path,trim2,closed=false);
|
||||||
|
path2 = path_subselect(path, spos[0], spos[1], epos[0], epos[1]);
|
||||||
|
widths = concat(
|
||||||
|
[lerp(width[spos[0]], width[(spos[0]+1)%len(width)], spos[1])],
|
||||||
|
[for (i = [spos[0]+1:1:epos[0]]) width[i]],
|
||||||
|
[lerp(width[epos[0]], width[(epos[0]+1)%len(width)], epos[1])]
|
||||||
|
);
|
||||||
|
|
||||||
start_vec = select(path,0) - select(path,1);
|
start_vec = select(path,0) - select(path,1);
|
||||||
end_vec = select(path,-1) - select(path,-2);
|
end_vec = select(path,-1) - select(path,-2);
|
||||||
if (len(path[0]) == 2) {
|
|
||||||
// Straight segments
|
// Straight segments
|
||||||
for (i = idx(path2,end=-2)) {
|
for (i = idx(path2,end=-2)) {
|
||||||
seg = select(path2,i,i+1);
|
seg = select(path2,i,i+1);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,332];
|
BOSL_VERSION = [2,0,333];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user