{ "nodes": [ { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "5", "name": "N", "type": "int", "uid": 2 }, { "expr": "2", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Y',float('-2.000000'),float('-2.000000'),float('-inf'),float('2.000000'),float('2.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -553.07094874595441, -242.73777479276771 ], "name": "p0", "script": [ "# Neil Gershenfeld 2/14/15", "# Matt Keeter 6/12/15", "", "import fab", "import math", "", "title('Polygon')", "", "input('x', float)", "input('y', float)", "input('N', int)", "input('r', float)", "", "output('shape', fab.shapes.move(fab.shapes.polygon_radius(x, y, r, N), x, y))", "", "# UI", "# (we need to do a bit of work to make the UI work for both even and", "# odd vertex counts; otherwise it will be off for one or the other)", "a_ = 0 if (N % 2) else (math.pi / N)", "sb.ui.wireframe([", " (x + r * math.sin(a_ + a * math.pi * 2/N),", " y + r * math.cos(a_ + a * math.pi * 2/N), 0)", " for a in range(N)], close=True)", "sb.ui.point(x, y)", "sb.ui.point(x + r * math.sin(a_), y + r * math.cos(a_),", " drag=(None, r, None))", "" ], "uid": 0 }, { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "\u0011[__0.__3]", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.40", "name": "width", "type": "float", "uid": 2 }, { "expr": "2.0", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f-0.2X-Xf0.2a-f1Y-Yf3',float('-0.200000'),float('1.000000'),float('-inf'),float('0.200000'),float('3.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -367, -43 ], "name": "r0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/15", "", "import fab", "", "title('Rectangle (center)')", "", "input('x0', float)", "input('y0', float)", "input('width', float)", "input('height', float)", "", "xmin, xmax = x0 - width/2, x0 + width/2", "ymin, ymax = y0 - height/2, y0 + height/2", "", "output('shape', fab.shapes.rectangle(xmin, xmax, ymin, ymax))", "", "def drag_hw(this, x, y, z):", " this.width = abs(2 * (x - this.x0))", " this.height = abs(2 * (y - this.y0))", "", "# UI", "sb.ui.wireframe(", " [(xmin, ymin, 0), (xmax, ymin, 0), (xmax, ymax, 0), (xmin, ymax, 0)],", " close=True)", "sb.ui.point(x0, y0)", "sb.ui.point(xmax, ymax, drag=drag_hw, relative=False)", "" ], "uid": 1 }, { "datums": [ { "expr": "-0.016402363777160645", "name": "x0", "type": "float", "uid": 0 }, { "expr": "1.5924838185310364", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.7511880159378052", "name": "x1", "type": "float", "uid": 2 }, { "expr": "1.9473177194595337", "name": "y1", "type": "float", "uid": 3 }, { "expr": "-0.703569084405899", "name": "x2", "type": "float", "uid": 4 }, { "expr": "2.015152931213379", "name": "y2", "type": "float", "uid": 5 }, { "expr": "\u0012fab.types.Shape('ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515',float('-0.703569'),float('1.592484'),float('-inf'),float('0.751188'),float('2.015153'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ -50, -221 ], "name": "t0", "script": [ "import fab", "", "title('Triangle')", "", "input('x0', float)", "input('y0', float)", "input('x1', float)", "input('y1', float)", "input('x2', float)", "input('y2', float)", "", "output('shape', fab.shapes.triangle(x0, y0, x1, y1, x2, y2))", "", "# UI", "sb.ui.wireframe([(x0, y0, 0), (x1, y1, 0), (x2, y2, 0)], close=True)", "sb.ui.point(x0, y0, 0)", "sb.ui.point(x1, y1, 0)", "sb.ui.point(x2, y2, 0)", "" ], "uid": 2 }, { "datums": [ { "expr": "\u0011[__1.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__2.__6]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515',float('-0.703569'),float('1.000000'),float('-inf'),float('0.751188'),float('3.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 277, -242 ], "name": "u0", "script": [ "import fab.types", "", "title('Union')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a | b)", "" ], "uid": 3 }, { "datums": [ { "expr": "\u0011[__3.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0.0", "name": "x", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 2 }, { "expr": "\u0011[__0.__2]", "name": "n", "type": "int", "uid": 3 }, { "expr": "\u0012fab.types.Shape('iiiim-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515',float('-3.070586'),float('-2.868588'),float('-inf'),float('3.085301'),float('3.000000'),float('inf'))", "name": "array", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 623.6502106228869, -240.66734383241072 ], "name": "a0", "script": [ "import fab", "import math", "", "title('Array (polar)')", "", "input('shape', fab.types.Shape)", "input('x', float)", "input('y', float)", "input('n', int)", "", "output('array', fab.shapes.iterate_polar(shape, x, y, n))", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * 0.3 + x,", " math.sin(i/36. * 2*math.pi) * 0.3 + y, 0)", " for i in range(36)], close=True, color=sb.color.teal)", "", "sb.ui.point(x, y, 0, color=sb.color.teal)", "" ], "uid": 4 }, { "datums": [ { "expr": "\u0011[__0.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__4.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am-Xf0-Yf0-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Yniiiim-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515',float('-2.000000'),float('-2.000000'),float('-inf'),float('2.000000'),float('2.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 846.94532170143293, 17.196859323886962 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 5 }, { "datums": [ { "expr": "\u0011[__5.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('am-Xf0-Yf0-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Yniiiim-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515',float('-2.000000'),float('-2.000000'),float('-inf'),float('2.000000'),float('2.000000'),float('inf'))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 1080.535994184231, 226.42531443117835 ], "name": "h0", "script": [ "import fab", "", "title('Heightmap (.png)')", "", "input('shape', fab.types.Shape)", "output('out', shape)", "", "sb.export.heightmap(shape)", "" ], "uid": 6 }, { "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[__5.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1am-Xf0-Yf0-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-1.61803Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-1.61803Yniiiim-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515m-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf-0-Yf-0-Zf0iaa-f-0.2X-Xf0.2a-f1Y-Yf3ni-*f-0.354834-Xf0.751188*f-0.76759-Yf1.94732i-*f0.422669-Xf-0.0164024*f-0.687167-Yf1.59248-*f-0.0678352-Xf-0.703569*f1.45476-Yf2.01515a-f0Z-Zf1',float('-2.000000'),float('-2.000000'),float('0.000000'),float('2.000000'),float('2.000000'),float('1.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 956.24950461130311, -324.72175740660475 ], "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": 7 } ], "protocol": 6, "type": "sb" }