mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Merge branch 'master' into dev
This commit is contained in:
commit
1959b86dbe
4 changed files with 44 additions and 19 deletions
|
@ -41,10 +41,10 @@ A lot of the features of this library are to allow shorter, easier-to-read, inte
|
|||
[`BOSL/shapes.scad`](https://github.com/revarbat/BOSL/wiki/shapes.scad) Examples | Raw OpenSCAD Equivalent
|
||||
---------------------------------- | -------------------------------
|
||||
`upcube([10,20,30]);` | `translate([0,0,15]) cube([10,20,30], center=true);`
|
||||
`rcube([20,20,30],r=5,$fn=32);` | `minkowski() {cube([10,10,20], center=true); sphere(r=5, $fn=32);}`
|
||||
`cuboid([20,20,30], fillet=5, edges=EDGES_Z_ALL);` | `minkowski() {cube([10,10,20], center=true); sphere(r=5, $fn=32);}`
|
||||
`prismoid([30,40],[20,30],h=10);` | `hull() {translate([0,0,0.005]) cube([30,40,0.01], center=true); translate([0,0,9.995]) cube([20,30,0.01],center=true);}`
|
||||
`xcyl(l=20,d=4);` | `rotate([0,90,0]) cylinder(h=20, d=4, center=true);`
|
||||
`rcylinder(h=100,d=40,fillet=5);` | `translate([0,0,50]) minkowski() {cylinder(h=90, d=30, center=true); sphere(r=5);}`
|
||||
`cyl(l=100, d=40, fillet=5);` | `translate([0,0,50]) minkowski() {cylinder(h=90, d=30, center=true); sphere(r=5);}`
|
||||
|
||||
[`BOSL/masks.scad`](https://github.com/revarbat/BOSL/wiki/masks.scad) Examples | Raw Openscad Equivalent
|
||||
----------------------------------- | -------------------------------
|
||||
|
|
|
@ -182,8 +182,8 @@ ALIGN_NEG = -1;
|
|||
// idx = axis + 3*neg + 6*ang/90;
|
||||
// rotate(orientations[idx]) {
|
||||
// up(10) {
|
||||
// back(4) color("black") text3d(text=str(ang), size=4);
|
||||
// fwd(4) color(axiscolors[axis]) text3d(text=str(["X","Y","Z"][axis], ["+","NEG"][neg]), size=4);
|
||||
// fwd(4) color("black") text3d(text=str(ang), size=4);
|
||||
// back(4) color(axiscolors[axis]) text3d(text=str(["X","Y","Z"][axis], ["+","NEG"][neg]), size=4);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
@ -195,6 +195,7 @@ ALIGN_NEG = -1;
|
|||
// rotation angles for rotating a vertical shape into the given orientations.
|
||||
// Figure(Spin): Standard Orientations
|
||||
// orient_cube(0);
|
||||
|
||||
ORIENT_X = [ 90, 0, 90]; // Orient along the X axis.
|
||||
ORIENT_Y = [ 90, 0, 180]; // Orient along the Y axis.
|
||||
ORIENT_Z = [ 0, 0, 0]; // Orient along the Z axis.
|
||||
|
@ -202,11 +203,13 @@ ORIENT_XNEG = [ 90, 0, -90]; // Orient reversed along the X axis.
|
|||
ORIENT_YNEG = [ 90, 0, 0]; // Orient reversed along the Y axis.
|
||||
ORIENT_ZNEG = [ 0, 180, 0]; // Orient reversed along the Z axis.
|
||||
|
||||
|
||||
// Section: Orientations Rotated 90º
|
||||
// Orientations for `cyl()`, `prismoid()`, etc. They take the form of standard [X,Y,Z]
|
||||
// rotation angles for rotating a vertical shape into the given orientations.
|
||||
// Figure(Spin): Orientations Rotated 90º
|
||||
// orient_cube(90);
|
||||
|
||||
ORIENT_X_90 = [ 90, -90, 90]; // Orient along the X axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_Y_90 = [ 90, -90, 180]; // Orient along the Y axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_Z_90 = [ 0, 0, 90]; // Orient along the Z axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
|
@ -214,11 +217,13 @@ ORIENT_XNEG_90 = [ 0, -90, 0]; // Orient reversed along the X axis, then ro
|
|||
ORIENT_YNEG_90 = [ 90, -90, 0]; // Orient reversed along the Y axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_ZNEG_90 = [ 0, 180, -90]; // Orient reversed along the Z axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
|
||||
|
||||
// Section: Orientations Rotated 180º
|
||||
// Orientations for `cyl()`, `prismoid()`, etc. They take the form of standard [X,Y,Z]
|
||||
// rotation angles for rotating a vertical shape into the given orientations.
|
||||
// Figure(Spin): Orientations Rotated 180º
|
||||
// orient_cube(180);
|
||||
|
||||
ORIENT_X_180 = [-90, 0, -90]; // Orient along the X axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_Y_180 = [-90, 0, 0]; // Orient along the Y axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_Z_180 = [ 0, 0, 180]; // Orient along the Z axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
|
@ -226,11 +231,13 @@ ORIENT_XNEG_180 = [-90, 0, 90]; // Orient reversed along the X axis, then ro
|
|||
ORIENT_YNEG_180 = [-90, 0, 180]; // Orient reversed along the Y axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_ZNEG_180 = [ 0, 180, 180]; // Orient reversed along the Z axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
|
||||
|
||||
// Section: Orientations Rotated 270º
|
||||
// Orientations for `cyl()`, `prismoid()`, etc. They take the form of standard [X,Y,Z]
|
||||
// rotation angles for rotating a vertical shape into the given orientations.
|
||||
// Figure(Spin): Orientations Rotated 270º
|
||||
// orient_cube(270);
|
||||
|
||||
ORIENT_X_270 = [ 90, 90, 90]; // Orient along the X axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_Y_270 = [ 90, 90, 180]; // Orient along the Y axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
ORIENT_Z_270 = [ 0, 0, -90]; // Orient along the Z axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"parameterSets": {
|
||||
"design default values": {
|
||||
"axiscolors": "[\"red\", \"forestgreen\", \"dodgerblue\"]",
|
||||
"axisdiam": "0.5",
|
||||
"axislbllen": "15",
|
||||
"axislen": "9"
|
||||
}
|
||||
},
|
||||
"fileFormatVersion": "1"
|
||||
}
|
|
@ -19,7 +19,11 @@ def get_header_link(name):
|
|||
|
||||
|
||||
def toc_entry(name, indent, count=None):
|
||||
ref = get_header_link(name)
|
||||
lname = "{0}{1}".format(
|
||||
("%d. " % count) if count else "",
|
||||
name
|
||||
)
|
||||
ref = get_header_link(lname)
|
||||
if name.endswith( (")", "}", "]") ):
|
||||
name = "`" + name.replace("\\", "") + "`"
|
||||
return "{0}{1} [{2}](#{3})".format(
|
||||
|
@ -87,6 +91,7 @@ class ImageProcessing(object):
|
|||
def gen_example_image(self, libfile, imgfile, code, extype):
|
||||
OPENSCAD = "/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD"
|
||||
CONVERT = "/usr/local/bin/convert"
|
||||
COMPARE = "/usr/local/bin/compare"
|
||||
|
||||
if extype == "NORENDER":
|
||||
return
|
||||
|
@ -177,9 +182,10 @@ class ImageProcessing(object):
|
|||
|
||||
if not self.keep_scripts:
|
||||
os.unlink(scriptfile)
|
||||
outimgfile = self.imgroot + imgfile
|
||||
targimgfile = self.imgroot + imgfile
|
||||
newimgfile = self.imgroot + "_new_" + imgfile
|
||||
if len(tmpimgs) == 1:
|
||||
cnvcmd = [CONVERT, tmpimgfile, "-resize", imgsizes[1], outimgfile]
|
||||
cnvcmd = [CONVERT, tmpimgfile, "-resize", imgsizes[1], newimgfile]
|
||||
print(" ".join(cnvcmd))
|
||||
res = subprocess.call(cnvcmd)
|
||||
if res != 0:
|
||||
|
@ -198,7 +204,7 @@ class ImageProcessing(object):
|
|||
"+map"
|
||||
]
|
||||
cnvcmd.extend(tmpimgs)
|
||||
cnvcmd.append(outimgfile)
|
||||
cnvcmd.append(newimgfile)
|
||||
print(" ".join(cnvcmd))
|
||||
res = subprocess.call(cnvcmd)
|
||||
if res != 0:
|
||||
|
@ -206,6 +212,29 @@ class ImageProcessing(object):
|
|||
for tmpimg in tmpimgs:
|
||||
os.unlink(tmpimg)
|
||||
|
||||
# Time to compare image.
|
||||
if not os.path.isfile(targimgfile):
|
||||
print("NEW IMAGE installed.")
|
||||
os.rename(newimgfile, targimgfile)
|
||||
else:
|
||||
if targimgfile.endswith(".gif"):
|
||||
cmpcmd = ["cmp", newimgfile, targimgfile]
|
||||
print(" ".join(cmpcmd))
|
||||
res = subprocess.call(cmpcmd)
|
||||
issame = res == 0
|
||||
else:
|
||||
cmpcmd = [COMPARE, "-metric", "MAE", newimgfile, targimgfile, "null:"]
|
||||
print(" ".join(cmpcmd))
|
||||
p = subprocess.Popen(cmpcmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
|
||||
issame = p.stdout.read().strip() == "0 (0)"
|
||||
if issame:
|
||||
print("Image unchanged.")
|
||||
os.unlink(newimgfile)
|
||||
else:
|
||||
print("Image UPDATED.")
|
||||
os.unlink(targimgfile)
|
||||
os.rename(newimgfile, targimgfile)
|
||||
|
||||
|
||||
imgprc = ImageProcessing()
|
||||
|
||||
|
|
Loading…
Reference in a new issue