From 3eb39d0018ed0b88cfc44898bc078da9c4f804e9 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Fri, 12 Jul 2019 13:11:13 -0700 Subject: [PATCH] Changed close argument of stroke() to closed. --- examples/boolean_geometry.scad | 2 +- geometry.scad | 38 +++++++++++++++++----------------- paths.scad | 10 ++++----- shapes2d.scad | 28 ++++++++++++------------- transforms.scad | 2 +- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/examples/boolean_geometry.scad b/examples/boolean_geometry.scad index 27d00b5..23615d6 100644 --- a/examples/boolean_geometry.scad +++ b/examples/boolean_geometry.scad @@ -22,7 +22,7 @@ outlinecolor="black"; module showit(label, rgn, poly=polycolor, outline=outlinecolor, width=0.5) { move([-50,-50]) { - if(outline) color(outline) linear_extrude(height=max(0.1,1-width)) for(path=rgn) stroke(path, width=width, close=true); + if(outline) color(outline) linear_extrude(height=max(0.1,1-width)) for(path=rgn) stroke(path, width=width, closed=true); if(poly) color(poly) linear_extrude(height=0.1) region(rgn); color("black") right(50) fwd(7) linear_extrude(height=0.1) text(text=label, size=8, halign="center", valign="center"); } diff --git a/geometry.scad b/geometry.scad index 55bc01f..f4e7aaa 100644 --- a/geometry.scad +++ b/geometry.scad @@ -789,39 +789,39 @@ function _offset_region( // %down(.1)polygon(test); // Example(2D): // star = star(5, r=100, ir=30); -// #stroke(close=true, star); -// stroke(close=true, offset(star, delta=-10, closed=true)); +// #stroke(closed=true, star); +// stroke(closed=true, offset(star, delta=-10, closed=true)); // Example(2D): // star = star(5, r=100, ir=30); -// #stroke(close=true, star); -// stroke(close=true, offset(star, delta=-10, chamfer=true, closed=true)); +// #stroke(closed=true, star); +// stroke(closed=true, offset(star, delta=-10, chamfer=true, closed=true)); // Example(2D): // star = star(5, r=100, ir=30); -// #stroke(close=true, star); -// stroke(close=true, offset(star, r=-10, closed=true)); +// #stroke(closed=true, star); +// stroke(closed=true, offset(star, r=-10, closed=true)); // Example(2D): // star = star(5, r=100, ir=30); -// #stroke(close=true, star); -// stroke(close=true, offset(star, delta=10, closed=true)); +// #stroke(closed=true, star); +// stroke(closed=true, offset(star, delta=10, closed=true)); // Example(2D): // star = star(5, r=100, ir=30); -// #stroke(close=true, star); -// stroke(close=true, offset(star, delta=-10, chamfer=true, closed=true)); +// #stroke(closed=true, star); +// stroke(closed=true, offset(star, delta=-10, chamfer=true, closed=true)); // Example(2D): // star = star(5, r=100, ir=30); -// #stroke(close=true, star); -// stroke(close=true, offset(star, r=10, closed=true)); +// #stroke(closed=true, star); +// stroke(closed=true, offset(star, r=10, closed=true)); // Example(2D): // ellipse = scale([1,0.3,1], p=circle(r=100)); -// #stroke(close=true, ellipse); -// stroke(close=true, offset(ellipse, r=-15, check_valid=true, closed=true)); +// #stroke(closed=true, ellipse); +// stroke(closed=true, offset(ellipse, r=-15, check_valid=true, closed=true)); // Example(2D): // sinpath = 2*[for(theta=[-180:5:180]) [theta/4,45*sin(theta)]]; // #stroke(sinpath); // stroke(offset(sinpath, r=17.5)); // Example(2D): Region // rgn = difference(circle(d=100), union(square([20,40], center=true), square([40,20], center=true))); -// #linear_extrude(height=1.1) for (p=rgn) stroke(close=true, width=0.5, p); +// #linear_extrude(height=1.1) for (p=rgn) stroke(closed=true, width=0.5, p); // region(offset(rgn, r=-5)); function offset( path, r=undef, delta=undef, chamfer=false, @@ -1017,7 +1017,7 @@ function _tagged_region(region1,region2,keep1,keep2,eps=EPSILON) = // Example(2D): // shape1 = move([-8,-8,0], p=circle(d=50)); // shape2 = move([ 8, 8,0], p=circle(d=50)); -// for (shape = [shape1,shape2]) color("red") stroke(shape, width=0.5, close=true); +// for (shape = [shape1,shape2]) color("red") stroke(shape, width=0.5, closed=true); // color("green") region(union(shape1,shape2)); function union(regions=[],b=undef,c=undef,eps=EPSILON) = b!=undef? union(concat([regions],[b],c==undef?[]:[c]), eps=eps) : @@ -1048,7 +1048,7 @@ function union(regions=[],b=undef,c=undef,eps=EPSILON) = // Example(2D): // shape1 = move([-8,-8,0], p=circle(d=50)); // shape2 = move([ 8, 8,0], p=circle(d=50)); -// for (shape = [shape1,shape2]) color("red") stroke(shape, width=0.5, close=true); +// for (shape = [shape1,shape2]) color("red") stroke(shape, width=0.5, closed=true); // color("green") region(difference(shape1,shape2)); function difference(regions=[],b=undef,c=undef,eps=EPSILON) = b!=undef? difference(concat([regions],[b],c==undef?[]:[c]), eps=eps) : @@ -1078,7 +1078,7 @@ function difference(regions=[],b=undef,c=undef,eps=EPSILON) = // Example(2D): // shape1 = move([-8,-8,0], p=circle(d=50)); // shape2 = move([ 8, 8,0], p=circle(d=50)); -// for (shape = [shape1,shape2]) color("red") stroke(shape, width=0.5, close=true); +// for (shape = [shape1,shape2]) color("red") stroke(shape, width=0.5, closed=true); // color("green") region(intersection(shape1,shape2)); function intersection(regions=[],b=undef,c=undef,eps=EPSILON) = b!=undef? intersection(concat([regions],[b],c==undef?[]:[c]),eps=eps) : @@ -1109,7 +1109,7 @@ function intersection(regions=[],b=undef,c=undef,eps=EPSILON) = // shape1 = move([-8,-8,0], p=circle(d=50)); // shape2 = move([ 8, 8,0], p=circle(d=50)); // for (shape = [shape1,shape2]) -// color("red") stroke(shape, width=0.5, close=true); +// color("red") stroke(shape, width=0.5, closed=true); // color("green") region(exclusive_or(shape1,shape2)); // Example(2D): As Module // exclusive_or() { diff --git a/paths.scad b/paths.scad index 0399a09..5be9093 100644 --- a/paths.scad +++ b/paths.scad @@ -464,19 +464,19 @@ module debug_polygon(points, paths=undef, convexity=2, size=1) // color("red") path_spread(spiral, n=100) circle(r=1); // Example(2D): // circle = regular_ngon(n=64, or=10); -// stroke(circle,width=1,close=true); +// stroke(circle,width=1,closed=true); // color("green")path_spread(circle, n=7, closed=true) circle(r=1+$idx/3); // Example(2D): // heptagon = regular_ngon(n=7, or=10); -// stroke(heptagon, width=1, close=true); +// stroke(heptagon, width=1, closed=true); // color("purple") path_spread(heptagon, n=9, closed=true) square([0.5,3],anchor=FRONT); // Example(2D): Direction at the corners is the average of the two adjacent edges // heptagon = regular_ngon(n=7, or=10); -// stroke(heptagon, width=1, close=true); +// stroke(heptagon, width=1, closed=true); // color("purple") path_spread(heptagon, n=7, closed=true) square([0.5,3],anchor=FRONT); // Example(2D): Don't rotate the children // heptagon = regular_ngon(n=7, or=10); -// stroke(heptagon, width=1, close=true); +// stroke(heptagon, width=1, closed=true); // color("red") path_spread(heptagon, n=9, closed=true, rotate_children=false) square([0.5,3],anchor=FRONT); // Example(2D): Open path, specify `n` // sinwav = [for(theta=[0:360]) 5*[theta/180, sin(theta)]]; @@ -488,7 +488,7 @@ module debug_polygon(points, paths=undef, convexity=2, size=1) // color("red")path_spread(sinwav, n=5, spacing=1) square([.2,1.5],anchor=FRONT); // Example(2D)): Closed path, specify `n` and `spacing`, copies centered around circle[0] // circle = regular_ngon(n=64,or=10); -// stroke(circle,width=.1,close=true); +// stroke(circle,width=.1,closed=true); // color("red")path_spread(circle, n=10, spacing=1, closed=true) square([.2,1.5],anchor=FRONT); // Example(2D): Open path, specify `spacing` // sinwav = [for(theta=[0:360]) 5*[theta/180, sin(theta)]]; diff --git a/shapes2d.scad b/shapes2d.scad index 3843430..899c43d 100644 --- a/shapes2d.scad +++ b/shapes2d.scad @@ -12,14 +12,14 @@ // Module: stroke() // Usage: -// stroke(path, width, [endcap], [close]); +// stroke(path, width, [endcap], [closed]); // Description: // Draws a 2D line path with a given line thickness. // Arguments: // path = The 2D path to draw along. // width = The width of the line to draw. // endcaps = If true, draw round endcaps at the ends of the line. -// close = If true, draw an additional line from the end of the path to the start. +// closed = If true, draw an additional line from the end of the path to the start. // Example(2D): // path = [[0,100], [100,100], [200,0], [100,-100], [100,0]]; // stroke(path, width=10, endcaps=false); @@ -28,11 +28,11 @@ // stroke(path, width=20, endcaps=true); // Example(2D): // path = [[0,100], [100,100], [200,0], [100,-100], [100,0]]; -// stroke(path, width=20, endcaps=true, close=true); -module stroke(path, width=1, endcaps=true, close=false) +// stroke(path, width=20, endcaps=true, closed=true); +module stroke(path, width=1, endcaps=true, closed=false) { $fn = quantup(segs(width/2),4); - path = close? concat(path,[path[0]]) : path; + path = closed? concat(path,[path[0]]) : path; assert(is_list(path) && is_vector(path[0]) && len(path[0])==2, "path must be a 2D list of points."); segments = pair(path); segpairs = pair(segments); @@ -122,7 +122,7 @@ module stroke(path, width=1, endcaps=true, close=false) // arc(points=[[5,30],[-10,-10],[30,5]], wedge=true); // Example(2D): // path = arc(points=[[5,30],[-10,-10],[30,5]], wedge=true); -// stroke(close=true, path); +// stroke(closed=true, path); // Example(FlatSpin): // include // path = arc(points=[[0,30,0],[0,0,30],[30,0,0]]); @@ -217,7 +217,7 @@ function _normal_segment(p1,p2) = // trapezoid(h=25, w1=20, w2=35); // trapezoid(h=20, w1=40, w2=0); // Example(2D): Called as Function -// stroke(close=true, trapezoid(h=30, w1=40, w2=20)); +// stroke(closed=true, trapezoid(h=30, w1=40, w2=20)); function trapezoid(h, w1, w2, anchor=CENTER, spin=0) = let( s = anchor.y>0? [w2,h] : anchor.y<0? [w1,h] : [(w1+w2)/2,h], @@ -259,7 +259,7 @@ module trapezoid(h, w1, w2, anchor=CENTER, spin=0) // Example(2D): Realigned // regular_ngon(n=8, side=20, realign=true); // Example(2D): Called as Function -// stroke(close=true, regular_ngon(n=6, or=30)); +// stroke(closed=true, regular_ngon(n=6, or=30)); function regular_ngon(n=6, or=undef, od=undef, ir=undef, id=undef, side=undef, realign=false, anchor=CENTER, spin=0) = let( sc = 1/cos(180/n), @@ -301,7 +301,7 @@ module regular_ngon(n=6, or=undef, od=undef, ir=undef, id=undef, side=undef, rea // Example(2D): Realigned // pentagon(side=20, realign=true); // Example(2D): Called as Function -// stroke(close=true, pentagon(or=30)); +// stroke(closed=true, pentagon(or=30)); function pentagon(or=undef, od=undef, ir=undef, id=undef, side=undef, realign=false, anchor=CENTER, spin=0) = regular_ngon(n=5, or=or, od=od, ir=ir, id=id, side=side, realign=realign, anchor=anchor, spin=spin); @@ -336,7 +336,7 @@ module pentagon(or=undef, od=undef, ir=undef, id=undef, side=undef, realign=fals // Example(2D): Realigned // hexagon(side=20, realign=true); // Example(2D): Called as Function -// stroke(close=true, hexagon(or=30)); +// stroke(closed=true, hexagon(or=30)); function hexagon(or=undef, od=undef, ir=undef, id=undef, side=undef, realign=false, anchor=CENTER, spin=0) = regular_ngon(n=6, or=or, od=od, ir=ir, id=id, side=side, realign=realign, anchor=anchor, spin=spin); @@ -371,7 +371,7 @@ module hexagon(or=undef, od=undef, ir=undef, id=undef, side=undef, realign=false // Example(2D): Realigned // octagon(side=20, realign=true); // Example(2D): Called as Function -// stroke(close=true, octagon(or=30)); +// stroke(closed=true, octagon(or=30)); function octagon(or=undef, od=undef, ir=undef, id=undef, side=undef, realign=false, anchor=CENTER, spin=0) = regular_ngon(n=8, or=or, od=od, ir=ir, id=id, side=side, realign=realign, anchor=anchor, spin=spin); @@ -399,7 +399,7 @@ module octagon(or=undef, od=undef, ir=undef, id=undef, side=undef, realign=false // glued_circles(d=30, spread=30, tangent=15); // glued_circles(d=30, spread=30, tangent=-30); // Example(2D): Called as Function -// stroke(close=true, glued_circles(r=15, spread=40, tangent=45)); +// stroke(closed=true, glued_circles(r=15, spread=40, tangent=45)); function glued_circles(r=undef, d=undef, spread=10, tangent=30, anchor=CENTER, spin=0) = let( r = get_radius(r=r, d=d, dflt=10), @@ -454,7 +454,7 @@ module glued_circles(r=undef, d=undef, spread=10, tangent=30, anchor=CENTER, spi // Example(2D): Realigned // star(n=7, r=50, step=3, realign=true); // Example(2D): Called as Function -// stroke(close=true, star(n=5, r=50, ir=25)); +// stroke(closed=true, star(n=5, r=50, ir=25)); function star(n, r, d, ir, id, step, realign=false, anchor=CENTER, spin=0) = let( r = get_radius(r=r, d=d), @@ -500,7 +500,7 @@ function _superformula(theta,m1,m2,n1,n2=1,n3=1,a=1,b=1) = // Example(2D): // supershape(step=0.5,m1=16,m2=16,n1=0.5,n2=0.5,n3=16,r=50); // Example(2D): Called as Function -// stroke(close=true, supershape(step=0.5,m1=16,m2=16,n1=0.5,n2=0.5,n3=16,d=100)); +// stroke(closed=true, supershape(step=0.5,m1=16,m2=16,n1=0.5,n2=0.5,n3=16,d=100)); // Examples(2D,Med): // for(n=[2:5]) right(2.5*(n-2)) supershape(m1=4,m2=4,n1=n,a=1,b=2); // Superellipses // m=[2,3,5,7]; for(i=[0:3]) right(2.5*i) supershape(.5,m1=m[i],n1=1); diff --git a/transforms.scad b/transforms.scad index 644fa20..825947e 100644 --- a/transforms.scad +++ b/transforms.scad @@ -2274,7 +2274,7 @@ module HSV(h,s=1,v=1,a=1) color(HSV(h,s,v),a) children(); // rainbow(["Foo","Bar","Baz"]) fwd($idx*10) text(text=$item,size=8,halign="center",valign="center"); // Example(2D): // rgn = [circle(d=45,$fn=3), circle(d=75,$fn=4), circle(d=50)]; -// rainbow(rgn) stroke($item, close=true); +// rainbow(rgn) stroke($item, closed=true); module rainbow(list) for($idx=[0:1:len(list)-1],$item=[list[$idx]]) HSV(h=360*$idx/len(list))