{ "nodes": [ { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "_y", "type": "float", "uid": 1 }, { "expr": "0", "name": "zmin", "type": "float", "uid": 2 }, { "expr": "1", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "\u0011[__0.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1iiiiiaa-f-1X-Xf1a-f-0.75Y-Yf0.75aa-f-0.75X-Xf0.75a-f-1Y-Yf1-r+q-Xf-0.75q-Yf-0.75f0.25-r+q-Xf-0.75q-Yf0.75f0.25-r+q-Xf0.75q-Yf-0.75f0.25-r+q-Xf0.75q-Yf0.75f0.25a-f0Z-Zf1',float('-1.000000'),float('-1.000000'),float('0.000000'),float('1.000000'),float('1.000000'),float('1.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 636.0577642938347, 113.68900838404616 ], "name": "e0", "script": [ "import fab", "", "title('Extrude')", "", "input('_x', float)", "input('_y', float)", "input('zmin', float)", "input('zmax', float)", "", "input('shape', fab.types.Shape)", "output('out', fab.shapes.extrude_z(shape, zmin, zmax))", "", "# UI", "sb.ui.wireframe([(_x, _y, zmin), (_x, _y, zmax)], color=sb.color.green)", "sb.ui.point(_x, _y, zmin, color=sb.color.green)", "sb.ui.point(_x, _y, zmax, color=sb.color.green)", "", "" ], "uid": 2 }, { "datums": [ { "expr": "\u0011[__2.__5]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__9.__2]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": ".61", "name": "weight", "type": "float", "uid": 2 }, { "expr": "\u0012fab.types.Shape('+*f0.61am__f1iiiiiaa-f-1X-Xf1a-f-0.75Y-Yf0.75aa-f-0.75X-Xf0.75a-f-1Y-Yf1-r+q-Xf-0.75q-Yf-0.75f0.25-r+q-Xf-0.75q-Yf0.75f0.25-r+q-Xf0.75q-Yf-0.75f0.25-r+q-Xf0.75q-Yf0.75f0.25a-f0Z-Zf1*f0.39am-Xf0-Yf0-Zf1m-Xf0-Yf0-Zf0m_+*f-1Y*f1.22465e-16Z+*f-1.22465e-16Y*f-1Zm-Xf0-Yf-0-Zf-0m+f0/*-Xf0f4+*f0-Zf0*f1-f4Z+f0/*-Yf0f4+*f0-Zf0*f1-f4Z_am__f1-r+qXqYf1.61a-f0Z-Zf4nam__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f-4Z-Zf0',float('-1.610000'),float('-1.610000'),float('-3.000000'),float('1.610000'),float('1.610000'),float('1.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 3 } ], "inspector": [ 976.6297436615957, 151.06776634863013 ], "name": "m1", "script": [ "# Neil Gershenfeld 2/1/15", "# Matt Keeter 6/13/15", "", "import fab", "", "title('Morph')", "", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "input('weight', float)", "", "output('out', fab.shapes.morph(a, b, weight))", "", "" ], "uid": 4 }, { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "z0", "type": "float", "uid": 2 }, { "expr": "4", "name": "z1", "type": "float", "uid": 3 }, { "expr": "1.61", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m+f0/*-Xf0f4+*f0-Zf0*f1-f4Z+f0/*-Yf0f4+*f0-Zf0*f1-f4Z_am__f1-r+qXqYf1.61a-f0Z-Zf4',float('-1.610000'),float('-1.610000'),float('0.000000'),float('1.610000'),float('1.610000'),float('4.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 37.41615595812755, 514.5137118300318 ], "name": "c1", "script": [ "import fab", "import math", "", "title('Cone (center)')", "", "input('x', float)", "input('y', float)", "input('z0', float)", "input('z1', float)", "input('r', float)", "", "output('shape', fab.shapes.cone(x, y, z0, z1, r))", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, z0)", " for i in range(36)], close=True)", "sb.ui.wireframe([(x,y,z0), (x+r,y,z0)])", "sb.ui.wireframe([(x,y,z0), (x,y,z1)])", "", "sb.ui.point(x, y, z0)", "sb.ui.point(x, y, z1)", "sb.ui.point(x + r, y, z0, drag=(r, None, None))", "" ], "uid": 5 }, { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "z", "type": "float", "uid": 2 }, { "expr": "180", "name": "a", "type": "float", "uid": 3 }, { "expr": "\u0011[__5.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m_+*f-1Y*f1.22465e-16Z+*f-1.22465e-16Y*f-1Zm-Xf0-Yf-0-Zf-0m+f0/*-Xf0f4+*f0-Zf0*f1-f4Z+f0/*-Yf0f4+*f0-Zf0*f1-f4Z_am__f1-r+qXqYf1.61a-f0Z-Zf4',float('-1.610000'),float('-1.610000'),float('-4.000000'),float('1.610000'),float('1.610000'),float('0.000000'))", "name": "rotated", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 38.16259832666669, 287.5290535782439 ], "name": "r1", "script": [ "import fab", "import math", "", "title('Rotate (X)')", "", "input('_x', float)", "input('y', float)", "input('z', float)", "input('a', float)", "", "input('shape', fab.types.Shape)", "output('rotated', fab.shapes.rotate_x(shape, a, y, z))", "", "# UI", "rad = math.radians(a)", "sb.ui.wireframe([(_x, y + math.cos(rad), z + math.sin(rad)),", " (_x, y, z),", " (_x, y + 1, z)], color=sb.color.teal)", "", "# Draw a semi-circular arc showing the rotation", "if int(a) % 360 != 0:", " sb.ui.wireframe([", " (_x, y + math.cos(math.radians(a_)) * 0.3,", " z + math.sin(math.radians(a_)) * 0.3)", " for a_ in range(int(a) % 360)], color=sb.color.teal)", "", "sb.ui.point(_x, y, z, color=sb.color.teal)", "", "def drag_pt(this, x, y, z):", " this.a = math.degrees(math.atan2(z - this.z, y - this.y))", "sb.ui.point(_x, y + math.cos(rad), z + math.sin(rad),", " color=sb.color.teal, drag=drag_pt, relative=False)", "", "" ], "uid": 6 }, { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "_y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "_z", "type": "float", "uid": 2 }, { "expr": "0", "name": "dx", "type": "float", "uid": 3 }, { "expr": "0", "name": "dy", "type": "float", "uid": 4 }, { "expr": "1", "name": "dz", "type": "float", "uid": 5 }, { "expr": "\u0011[__6.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 6 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf1m-Xf0-Yf0-Zf0m_+*f-1Y*f1.22465e-16Z+*f-1.22465e-16Y*f-1Zm-Xf0-Yf-0-Zf-0m+f0/*-Xf0f4+*f0-Zf0*f1-f4Z+f0/*-Yf0f4+*f0-Zf0*f1-f4Z_am__f1-r+qXqYf1.61a-f0Z-Zf4',float('-1.610000'),float('-1.610000'),float('-3.000000'),float('1.610000'),float('1.610000'),float('1.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 7 } ], "inspector": [ 348.42481622575394, 284.7733640498611 ], "name": "t0", "script": [ "import fab", "", "title('Translate')", "", "input('_x', float)", "input('_y', float)", "input('_z', float)", "input('dx', float)", "input('dy', float)", "input('dz', float)", "", "input('shape', fab.types.Shape)", "output('out', fab.shapes.translate(shape, dx, dy, dz))", "", "# UI", "sb.ui.wireframe([(_x, _y, _z),", " (_x + dx, _y + dy, _z + dz)], color=sb.color.teal)", "sb.ui.wireframe([(_x, _y - 0.3, _z),", " (_x, _y + 0.3, _z)], color=sb.color.teal)", "sb.ui.wireframe([(_x - 0.3, _y, _z),", " (_x + 0.3, _y, _z)], color=sb.color.teal)", "sb.ui.wireframe([(_x, _y, _z - 0.3),", " (_x, _y, _z + 0.3)], color=sb.color.teal)", "", "sb.ui.point(_x, _y, _z, color=sb.color.teal)", "sb.ui.point(_x + dx, _y + dy, _z + dz, color=sb.color.teal, drag=(dx, dy, dz))", "" ], "uid": 7 }, { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "-2\n", "name": "z", "type": "float", "uid": 2 }, { "expr": "4", "name": "width", "type": "float", "uid": 3 }, { "expr": "4", "name": "height", "type": "float", "uid": 4 }, { "expr": "4", "name": "depth", "type": "float", "uid": 5 }, { "expr": "\u0012fab.types.Shape('am__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f-4Z-Zf0',float('-2.000000'),float('-2.000000'),float('-4.000000'),float('2.000000'),float('2.000000'),float('0.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ 359.47247992516657, 597.9394316950761 ], "name": "c2", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 5/22/15", "", "import fab", "", "title('Cube (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('width', float)", "input('height', float)", "input('depth', float)", "", "xmin, xmax = x - width/2, x + width/2", "ymin, ymax = y - height/2, y + height/2", "zmin, zmax = z - depth/2, z + depth/2", "", "output('shape', fab.shapes.cube(xmin, xmax, ymin, ymax, zmin, zmax))", "", "# UI", "sb.ui.wireframe([(xmin, ymin, zmin), (xmax, ymin, zmin),", " (xmax, ymax, zmin), (xmin, ymax, zmin)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmax), (xmax, ymin, zmax),", " (xmax, ymax, zmax), (xmin, ymax, zmax)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmin), (xmin, ymax, zmin),", " (xmin, ymax, zmax), (xmin, ymin, zmax)], close=True)", "sb.ui.wireframe([(xmax, ymin, zmin), (xmax, ymax, zmin),", " (xmax, ymax, zmax), (xmax, ymin, zmax)], close=True)", "", "def drag_hwd(this, dx,dy,dz):", " this.width += 2*dx", " this.height += 2*dy", " this.depth += 2*dz", "", "sb.ui.point(x, y, z)", "sb.ui.point(x + width/2.0, y + height/2.0, z + depth/2.0,", " drag=drag_hwd)", "", "" ], "uid": 8 }, { "datums": [ { "expr": "\u0011[__7.__7]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__8.__6]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am-Xf0-Yf0-Zf1m-Xf0-Yf0-Zf0m_+*f-1Y*f1.22465e-16Z+*f-1.22465e-16Y*f-1Zm-Xf0-Yf-0-Zf-0m+f0/*-Xf0f4+*f0-Zf0*f1-f4Z+f0/*-Yf0f4+*f0-Zf0*f1-f4Z_am__f1-r+qXqYf1.61a-f0Z-Zf4nam__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f-4Z-Zf0',float('-1.610000'),float('-1.610000'),float('-3.000000'),float('1.610000'),float('1.610000'),float('1.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 638.8889505645302, 475.5610453547827 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 9 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "2", "name": "width", "type": "float", "uid": 2 }, { "expr": "2", "name": "height", "type": "float", "uid": 3 }, { "expr": "0.25", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('iiiiiaa-f-1X-Xf1a-f-0.75Y-Yf0.75aa-f-0.75X-Xf0.75a-f-1Y-Yf1-r+q-Xf-0.75q-Yf-0.75f0.25-r+q-Xf-0.75q-Yf0.75f0.25-r+q-Xf0.75q-Yf-0.75f0.25-r+q-Xf0.75q-Yf0.75f0.25',float('-1.000000'),float('-1.000000'),float('-inf'),float('1.000000'),float('1.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 266.30626546834134, 22.878566181872564 ], "name": "r2", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/15", "", "import fab", "", "title('Rounded rectangle (center)')", "", "input('x', float)", "input('y', float)", "input('width', float)", "input('height', float)", "input('r', float)", "", "xmin, xmax = x - width/2, x + width/2", "ymin, ymax = y - height/2, y + height/2", "", "# This is the circle's radius in actual units (not a 0-1 fraction)", "r_ = r * min(width, height)/2", "", "output('shape', fab.shapes.rounded_rectangle(xmin, xmax, ymin, ymax, r))", "", "def drag_r(this, x, y, z):", " if abs(this.width) < abs(this.height):", " d = abs(this.width)", " mid = this.y + this.height/2 - d/2", " else:", " d = abs(this.width)", " mid = this.y", " r = 1 - (y - mid) / (d/2)", " this.r = float(min(1, max(0, r)))", "", "def drag_hw(this, x, y, z):", " this.height = abs(2 * (y - this.y))", " this.width = abs(2 * (x - this.x))", "", "# UI", "sb.ui.wireframe(", " [(xmin, ymin, 0), (xmax, ymin, 0), (xmax, ymax, 0), (xmin, ymax, 0)],", " close=True)", "sb.ui.wireframe([(xmax - r_, ymax, 0), (xmax, ymax - r_, 0)])", "sb.ui.point(x, y)", "sb.ui.point(xmax, ymax, drag=drag_hw, relative=False)", "sb.ui.point(xmax, ymax - r_, drag=drag_r, relative=False)", "", "" ], "uid": 0 }, { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "_z", "type": "float", "uid": 2 }, { "expr": "1.61", "name": "sx", "type": "float", "uid": 3 }, { "expr": "1", "name": "sy", "type": "float", "uid": 4 }, { "expr": "\u0011[__4.__3]", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 }, { "expr": "\u0012fab.types.Shape('m+f0/-Xf0f1.61+f0/-Yf0f1_+*f0.61am__f1iiiiiaa-f-1X-Xf1a-f-0.75Y-Yf0.75aa-f-0.75X-Xf0.75a-f-1Y-Yf1-r+q-Xf-0.75q-Yf-0.75f0.25-r+q-Xf-0.75q-Yf0.75f0.25-r+q-Xf0.75q-Yf-0.75f0.25-r+q-Xf0.75q-Yf0.75f0.25a-f0Z-Zf1*f0.39am-Xf0-Yf0-Zf1m-Xf0-Yf0-Zf0m_+*f-1Y*f1.22465e-16Z+*f-1.22465e-16Y*f-1Zm-Xf0-Yf-0-Zf-0m+f0/*-Xf0f4+*f0-Zf0*f1-f4Z+f0/*-Yf0f4+*f0-Zf0*f1-f4Z_am__f1-r+qXqYf1.61a-f0Z-Zf4nam__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f-4Z-Zf0',float('-2.592100'),float('-1.610000'),float('-3.000000'),float('2.592100'),float('1.610000'),float('1.000000'))", "name": "scaled", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ 1012.2896905378079, 369.5160972276692 ], "name": "s0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 5/31/15", "", "import fab", "", "title('Scale (2D)')", "", "input('x0', float)", "input('y0', float)", "input('_z', float)", "input('sx', float)", "input('sy', float)", "", "input('shape', fab.types.Shape)", "output('scaled', fab.shapes.scale_xy(shape, x0, y0, sx, sy))", "", "# UI", "sb.ui.wireframe([(x0 + sx, y0, _z), (x0, y0, _z), (x0, y0 + sy, _z)],", " color=sb.color.teal)", "sb.ui.wireframe([(x0 + sx, y0 + sx/10, _z), (x0 + sx, y0 - sx/10, _z)],", " color=sb.color.teal)", "sb.ui.wireframe([(x0 + sy/10, y0 + sy, _z), (x0 - sy/10, y0 + sy, _z)],", " color=sb.color.teal)", "sb.ui.point(x0, y0, _z, color=sb.color.teal)", "sb.ui.point(x0 + sx, y0, _z, color=sb.color.teal, drag=(sx, None, None))", "sb.ui.point(x0, y0 + sy, _z, color=sb.color.teal, drag=(None, sy, None))", "" ], "uid": 3 } ], "protocol": 6, "type": "sb" }