diff --git a/shapes.scad b/shapes.scad index 054053f..f695ff2 100644 --- a/shapes.scad +++ b/shapes.scad @@ -78,14 +78,15 @@ module cuboid( cnt = sum(e); r = first_defined([chamfer, rounding, 0]); c = [min(r,size.x/2), min(r,size.y/2), min(r,size.z/2)]; + c2 = vmul(corner,c/2); $fn = is_finite(chamfer)? 4 : segs(r); - translate(vmul(corner,size/2-c)) { + translate(vmul(corner, size/2-c)) { if (cnt == 0) { - cube(c*2, center=true); + translate(c2) cube(c, center=true); } else if (cnt == 1) { - if (e.x) xcyl(l=c.x*2, r=r); - if (e.y) ycyl(l=c.y*2, r=r); - if (e.z) zcyl(l=c.z*2, r=r); + if (e.x) right(c2.x) xcyl(l=c.x, r=r); + if (e.y) back (c2.y) ycyl(l=c.y, r=r); + if (e.z) up (c2.z) zcyl(l=c.z, r=r); } else if (cnt == 2) { if (!e.x) { intersection() { @@ -152,9 +153,9 @@ module cuboid( } else { isize = [for (v = size) max(0.001, v-2*chamfer)]; hull() { - cube([size.x, isize.y, isize.z], center=true); - cube([isize.x, size.y, isize.z], center=true); - cube([isize.x, isize.y, size.z], center=true); + cube([ size.x, isize.y, isize.z], center=true); + cube([isize.x, size.y, isize.z], center=true); + cube([isize.x, isize.y, size.z], center=true); } } } else if (chamfer<0) { diff --git a/strings.scad b/strings.scad index 26df2b7..6b7053d 100644 --- a/strings.scad +++ b/strings.scad @@ -626,7 +626,6 @@ function is_letter(s) = // Arguments: // fmt = The formatting string, with placeholders to format the values into. // vals = The list of values to format. -// use_nbsp = Pad fields with HTML entity ` ` instead of spaces. // Example(NORENDER): // str_format("The value of {} is {:.14f}.", ["pi", PI]); // Returns: "The value of pi is 3.14159265358979." // str_format("The value {1:f} is known as {0}.", ["pi", PI]); // Returns: "The value 3.141593 is known as pi." @@ -634,7 +633,7 @@ function is_letter(s) = // str_format("{:-5s}{:i}{:b}", ["foo", 12e3, 5]); // Returns: "foo 12000true" // str_format("{:-10s}{:.3f}", ["plecostamus",27.43982]); // Returns: "plecostamus27.440" // str_format("{:-10.9s}{:.3f}", ["plecostamus",27.43982]); // Returns: "plecostam 27.440" -function str_format(fmt, vals, use_nbsp=false) = +function str_format(fmt, vals) = let( parts = str_split(fmt,"{") ) str_join([ @@ -676,7 +675,7 @@ function str_format(fmt, vals, use_nbsp=false) = typ=="G"? upcase(fmt_float(val,default(prec,6))) : assert(false,str("Unknown format type: ",typ)), padlen = max(0,wid-len(unpad)), - padfill = str_join([for (i=[0:1:padlen-1]) zero? "0" : use_nbsp? " " : " "]), + padfill = str_join([for (i=[0:1:padlen-1]) zero? "0" : " "]), out = left? str(unpad, padfill) : str(padfill, unpad) ) out, raw @@ -692,7 +691,6 @@ function str_format(fmt, vals, use_nbsp=false) = // Arguments: // fmt = The formatting string, with placeholders to format the values into. // vals = The list of values to format. -// use_nbsp = Pad fields with HTML entity ` ` instead of spaces. // Example(NORENDER): // echofmt("The value of {} is {:.14f}.", ["pi", PI]); // ECHO: "The value of pi is 3.14159265358979." // echofmt("The value {1:f} is known as {0}.", ["pi", PI]); // ECHO: "The value 3.141593 is known as pi." @@ -700,10 +698,10 @@ function str_format(fmt, vals, use_nbsp=false) = // echofmt("{:-5s}{:i}{:b}", ["foo", 12e3, 5]); // ECHO: "foo 12000true" // echofmt("{:-10s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostamus27.440" // echofmt("{:-10.9s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostam 27.440" -function echofmt(fmt, vals, use_nbsp=false) = echo(str_format(fmt,vals,use_nbsp)); -module echofmt(fmt, vals, use_nbsp=false) { +function echofmt(fmt, vals) = echo(str_format(fmt,vals)); +module echofmt(fmt, vals) { no_children($children); - echo(str_format(fmt,vals,use_nbsp)); + echo(str_format(fmt,vals)); } // vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/structs.scad b/structs.scad index 1e9f321..15831ce 100644 --- a/structs.scad +++ b/structs.scad @@ -96,7 +96,7 @@ function struct_keys(struct) = // struct = input structure // name = optional structure name to list at the top of the output. Default: "" function struct_echo(struct,name="") = - let( keylist = [for(entry=struct) str("  ",entry[0],": ",entry[1],"\n")]) + let( keylist = [for(entry=struct) str(" ",entry[0],": ",entry[1],"\n")]) echo(str("\nStructure ",name,"\n",str_join(keylist))) undef; diff --git a/version.scad b/version.scad index b3a3b8b..ea08daa 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,459]; +BOSL_VERSION = [2,0,461]; // Section: BOSL Library Version Functions