{ "nodes": [ { "datums": [ { "expr": "0.036287784576416016", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.021162033081054688", "name": "y", "type": "float", "uid": 1 }, { "expr": "4", "name": "N", "type": "int", "uid": 2 }, { "expr": "1.", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf0.0362878-Yf0.021162-Zf0aaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f6.12323e-17X*f1Y+*f-1X*f6.12323e-17Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16Y+*f-1.22465e-16X*f-1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1.83697e-16X*f-1Y+*f1X*f-1.83697e-16Y_m-Xf0-Yf0-Zf0-f-0.707107Y',float('-0.963712'),float('-0.978838'),float('-inf'),float('1.036288'),float('1.021162'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -271, 167 ], "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.7109745740890503", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.008405447006225586", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.5421130657196045", "name": "width", "type": "float", "uid": 2 }, { "expr": "0.506455659866333", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f0.439918X-Xf0.982031a-f-0.261633Y-Yf0.244822',float('0.439918'),float('-0.261633'),float('-inf'),float('0.982031'),float('0.244822'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -278.65721722828886, -218.7683864615372 ], "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.013067960739135742", "name": "x0", "type": "float", "uid": 0 }, { "expr": "0.6996389627456665", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__1.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__1.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f-0.257989X-Xf0.284124a-f0.446411Y-Yf0.952867',float('-0.257989'),float('0.446411'),float('-inf'),float('0.284124'),float('0.952867'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -279, -33 ], "name": "r1", "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": 2 }, { "datums": [ { "expr": "-0.7101491689682007", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.005732297897338867", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__1.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__1.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f-0.981206X-Xf-0.439093a-f-0.25896Y-Yf0.247496',float('-0.981206'),float('-0.258960'),float('-inf'),float('-0.439093'),float('0.247496'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 40.407830652034363, -229.20195672209576 ], "name": "r2", "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": 3 }, { "datums": [ { "expr": "0.03678792715072632", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.7144930958747864", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__1.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__1.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f-0.234269X-Xf0.307844a-f-0.967721Y-Yf-0.461265',float('-0.234269'),float('-0.967721'),float('-inf'),float('0.307844'),float('-0.461265'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 44, -20 ], "name": "r3", "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": 4 }, { "datums": [ { "expr": "\u0011[__0.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__3.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am-Xf0.0362878-Yf0.021162-Zf0aaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f6.12323e-17X*f1Y+*f-1X*f6.12323e-17Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16Y+*f-1.22465e-16X*f-1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1.83697e-16X*f-1Y+*f1X*f-1.83697e-16Y_m-Xf0-Yf0-Zf0-f-0.707107Ynaa-f-0.981206X-Xf-0.439093a-f-0.25896Y-Yf0.247496',float('-0.963712'),float('-0.978838'),float('-inf'),float('1.036288'),float('1.021162'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 375.46476190486572, -189.16545256275677 ], "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": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__1.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aam-Xf0.0362878-Yf0.021162-Zf0aaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f6.12323e-17X*f1Y+*f-1X*f6.12323e-17Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16Y+*f-1.22465e-16X*f-1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1.83697e-16X*f-1Y+*f1X*f-1.83697e-16Y_m-Xf0-Yf0-Zf0-f-0.707107Ynaa-f-0.981206X-Xf-0.439093a-f-0.25896Y-Yf0.247496naa-f0.439918X-Xf0.982031a-f-0.261633Y-Yf0.244822',float('-0.963712'),float('-0.978838'),float('-inf'),float('1.036288'),float('1.021162'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 376.86633224292234, -28.692933478745687 ], "name": "d1", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 6 }, { "datums": [ { "expr": "\u0011[__6.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__2.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aaam-Xf0.0362878-Yf0.021162-Zf0aaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f6.12323e-17X*f1Y+*f-1X*f6.12323e-17Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16Y+*f-1.22465e-16X*f-1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1.83697e-16X*f-1Y+*f1X*f-1.83697e-16Y_m-Xf0-Yf0-Zf0-f-0.707107Ynaa-f-0.981206X-Xf-0.439093a-f-0.25896Y-Yf0.247496naa-f0.439918X-Xf0.982031a-f-0.261633Y-Yf0.244822naa-f-0.257989X-Xf0.284124a-f0.446411Y-Yf0.952867',float('-0.963712'),float('-0.978838'),float('-inf'),float('1.036288'),float('1.021162'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 385.4647619048659, 123.2126572155893 ], "name": "d2", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 7 }, { "datums": [ { "expr": "\u0011[__7.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__4.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aaaam-Xf0.0362878-Yf0.021162-Zf0aaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f6.12323e-17X*f1Y+*f-1X*f6.12323e-17Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16Y+*f-1.22465e-16X*f-1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1.83697e-16X*f-1Y+*f1X*f-1.83697e-16Y_m-Xf0-Yf0-Zf0-f-0.707107Ynaa-f-0.981206X-Xf-0.439093a-f-0.25896Y-Yf0.247496naa-f0.439918X-Xf0.982031a-f-0.261633Y-Yf0.244822naa-f-0.257989X-Xf0.284124a-f0.446411Y-Yf0.952867naa-f-0.234269X-Xf0.307844a-f-0.967721Y-Yf-0.461265',float('-0.963712'),float('-0.978838'),float('-inf'),float('1.036288'),float('1.021162'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 394.97626776114782, 279.99633532781922 ], "name": "d3", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 8 }, { "datums": [ { "expr": "\u0011[__8.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0", "name": "hue", "type": "float", "uid": 1 }, { "expr": "1", "name": "saturation", "type": "float", "uid": 2 }, { "expr": "1", "name": "brightness", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aaaam-Xf0.0362878-Yf0.021162-Zf0aaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f6.12323e-17X*f1Y+*f-1X*f6.12323e-17Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16Y+*f-1.22465e-16X*f-1Y_m-Xf0-Yf0-Zf0-f-0.707107Ym-Xf0-Yf0-Zf0m+*f-1.83697e-16X*f-1Y+*f1X*f-1.83697e-16Y_m-Xf0-Yf0-Zf0-f-0.707107Ynaa-f-0.981206X-Xf-0.439093a-f-0.25896Y-Yf0.247496naa-f0.439918X-Xf0.982031a-f-0.261633Y-Yf0.244822naa-f-0.257989X-Xf0.284124a-f0.446411Y-Yf0.952867naa-f-0.234269X-Xf0.307844a-f-0.967721Y-Yf-0.461265',float('-0.963712'),float('-0.978838'),float('-inf'),float('1.036288'),float('1.021162'),float('inf'),color=(255,0,0))", "name": "out", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 395.22803106109473, 419.94349788693773 ], "name": "s0", "script": [ "import math", "import fab", "", "title('Set color (HSB)')", "", "input(\"shape\", fab.types.Shape)", "input(\"hue\", float)", "input(\"saturation\", float)", "input(\"brightness\", float)", "", "# copied from Java's HSBtoRGB", "# http://www.docjar.com/html/api/java/awt/Color.java.html", "", "r = 0", "g = 0", "b = 0", "", "if saturation == 0:", " r = g = b = int(brightness * 255.0 + 0.5)", "else:", " h = (hue - float(math.floor(hue))) * 6.0", " f = h - float(math.floor(h))", " p = brightness * (1-saturation)", " q = brightness * (1-saturation*f)", " t = brightness * (1-(saturation*(1-f)))", "", " h = int(h)", "", " if(h==0):", " r = int(brightness * 255.0 + 0.5)", " g = int(t * 255.0 + 0.5)", " b = int(p * 255.0 + 0.5)", " elif(h==1):", " r = int(q * 255.0 + 0.5)", " g = int(brightness * 255.0 + 0.5)", " b = int(p * 255.0 + 0.5)", " elif(h==2):", " r = int(p * 255.0 + 0.5)", " g = int(brightness * 255.0 + 0.5)", " b = int(t * 255.0 + 0.5)", " elif(h==3):", " r = int(p * 255.0 + 0.5)", " g = int(q * 255.0 + 0.5)", " b = int(brightness * 255.0 + 0.5)", " elif(h==4):", " r = int(t * 255.0 + 0.5)", " g = int(p * 255.0 + 0.5)", " b = int(brightness * 255.0 + 0.5)", " elif(h==5):", " r = int(brightness * 255.0 + 0.5)", " g = int(p * 255.0 + 0.5)", " b = int(q * 255.0 + 0.5)", "", "output(\"out\", fab.shapes.set_color(shape, r, g, b))", "" ], "uid": 9 }, { "datums": [ { "expr": "0.8276477456092834", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-2.699838638305664", "name": "y0", "type": "float", "uid": 1 }, { "expr": "1", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf0.827648q-Yf-2.69984f1',float('-0.172352'),float('-3.699839'),float('-inf'),float('1.827648'),float('-1.699839'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -289.14631554785825, 965.54388575501468 ], "name": "c0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 10 }, { "datums": [ { "expr": "0.8443023854942322", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-3.694363671005249", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.58", "name": "width", "type": "float", "uid": 2 }, { "expr": ".58", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f0.554302X-Xf1.1343a-f-3.98436Y-Yf-3.40436',float('0.554302'),float('-3.984364'),float('-inf'),float('1.134302'),float('-3.404364'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -272.52250436380274, 536.35591868280017 ], "name": "r4", "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": 11 }, { "datums": [ { "expr": "0.8199466759414673", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-1.6968304688339235", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__11.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__11.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f0.529947X-Xf1.10995a-f-1.98683Y-Yf-1.40683',float('0.529947'),float('-1.986830'),float('-inf'),float('1.109947'),float('-1.406830'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -274.96835377798732, 731.75990176229436 ], "name": "r5", "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": 12 }, { "datums": [ { "expr": "1.8297910386772156", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-2.718441563308716", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__11.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__11.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f1.53979X-Xf2.11979a-f-3.00844Y-Yf-2.42844',float('1.539791'),float('-3.008441'),float('-inf'),float('2.119791'),float('-2.428442'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 47.985135547792538, 540.27861667348702 ], "name": "r6", "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": 13 }, { "datums": [ { "expr": "-0.1570159500389099", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-2.7071257407073976", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__11.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__11.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f-0.447016X-Xf0.132984a-f-2.99713Y-Yf-2.41713',float('-0.447016'),float('-2.997126'),float('-inf'),float('0.132984'),float('-2.417126'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 43.9277854998127, 735.01454598339717 ], "name": "r7", "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": 14 }, { "datums": [ { "expr": "\u0011[__10.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__13.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('a-r+q-Xf0.827648q-Yf-2.69984f1naa-f1.53979X-Xf2.11979a-f-3.00844Y-Yf-2.42844',float('-0.172352'),float('-3.699839'),float('-inf'),float('1.827648'),float('-1.699839'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 439.75081064864105, 641.19355899416621 ], "name": "d4", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 15 }, { "datums": [ { "expr": "\u0011[__15.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__11.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aa-r+q-Xf0.827648q-Yf-2.69984f1naa-f1.53979X-Xf2.11979a-f-3.00844Y-Yf-2.42844naa-f0.554302X-Xf1.1343a-f-3.98436Y-Yf-3.40436',float('-0.172352'),float('-3.699839'),float('-inf'),float('1.827648'),float('-1.699839'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 438.58063688414472, 900.26802263872491 ], "name": "d5", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 16 }, { "datums": [ { "expr": "\u0011[__16.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__12.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aaa-r+q-Xf0.827648q-Yf-2.69984f1naa-f1.53979X-Xf2.11979a-f-3.00844Y-Yf-2.42844naa-f0.554302X-Xf1.1343a-f-3.98436Y-Yf-3.40436naa-f0.529947X-Xf1.10995a-f-1.98683Y-Yf-1.40683',float('-0.172352'),float('-3.699839'),float('-inf'),float('1.827648'),float('-1.699839'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 445.66634907392393, 1038.5551342494978 ], "name": "d6", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 17 }, { "datums": [ { "expr": "\u0011[__17.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__14.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aaaa-r+q-Xf0.827648q-Yf-2.69984f1naa-f1.53979X-Xf2.11979a-f-3.00844Y-Yf-2.42844naa-f0.554302X-Xf1.1343a-f-3.98436Y-Yf-3.40436naa-f0.529947X-Xf1.10995a-f-1.98683Y-Yf-1.40683naa-f-0.447016X-Xf0.132984a-f-2.99713Y-Yf-2.41713',float('-0.172352'),float('-3.699839'),float('-inf'),float('1.827648'),float('-1.699839'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 454.27930796312558, 1175.5446474035843 ], "name": "d7", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 18 }, { "datums": [ { "expr": "12.659383992858887", "name": "x", "type": "float", "uid": 0 }, { "expr": "-3.5366783045425416", "name": "y", "type": "float", "uid": 1 }, { "expr": "\u0011[__21.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__21.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "0.06482583489911298", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('iiiiiaa-f12.3694X-Xf12.9494a-f-3.80788Y-Yf-3.26548aa-f12.3882X-Xf12.9306a-f-3.82668Y-Yf-3.24668-r+q-Xf12.3882q-Yf-3.80788f0.0187995-r+q-Xf12.3882q-Yf-3.26548f0.0187995-r+q-Xf12.9306q-Yf-3.80788f0.0187995-r+q-Xf12.9306q-Yf-3.26548f0.0187995',float('12.369384'),float('-3.826678'),float('-inf'),float('12.949384'),float('-3.246678'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 821.24229125731131, -112.16529630304883 ], "name": "r9", "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": 20 }, { "datums": [ { "expr": "10.608930826187134", "name": "x", "type": "float", "uid": 0 }, { "expr": "-3.1107529401779175", "name": "y", "type": "float", "uid": 1 }, { "expr": "5", "name": "N", "type": "int", "uid": 2 }, { "expr": "2.75", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf10.6089-Yf-3.11075-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Y',float('7.858900'),float('-5.860750'),float('-inf'),float('13.358900'),float('-0.360750'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 827.82012150651576, 138.21432843871617 ], "name": "p1", "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": 19 }, { "datums": [ { "expr": "8.55993841142273", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-3.6425855063095094", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__21.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__21.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f8.26994X-Xf8.84994a-f-3.93259Y-Yf-3.35259',float('8.269938'),float('-3.932585'),float('-inf'),float('8.849938'),float('-3.352586'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 1221.6584221819596, -353.47187447513113 ], "name": "r10", "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": 22 }, { "datums": [ { "expr": "11.852451066680908", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-1.2426074646606446", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__21.__2]", "name": "width", "type": "float", "uid": 2 }, { "expr": "\u0011[__21.__3]", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f11.5625X-Xf12.1425a-f-1.53261Y-Yf-0.952607',float('11.562451'),float('-1.532607'),float('-inf'),float('12.142451'),float('-0.952607'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 1229.4539453547382, -130.49982381687465 ], "name": "r11", "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": 23 }, { "datums": [ { "expr": "\u0011[__19.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__22.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am-Xf10.6089-Yf-3.11075-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Ynaa-f8.26994X-Xf8.84994a-f-3.93259Y-Yf-3.35259',float('7.858900'),float('-5.860750'),float('-inf'),float('13.358900'),float('-0.360750'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 1703.3507916873671, -272.07619235042262 ], "name": "d8", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 24 }, { "datums": [ { "expr": "\u0011[__24.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__21.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aam-Xf10.6089-Yf-3.11075-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Ynaa-f8.26994X-Xf8.84994a-f-3.93259Y-Yf-3.35259naa-f9.06634X-Xf9.64634a-f-1.63113Y-Yf-1.05113',float('7.858900'),float('-5.860750'),float('-inf'),float('13.358900'),float('-0.360750'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 1708.3395210064491, -105.81810585748077 ], "name": "d9", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 25 }, { "datums": [ { "expr": "\u0011[__25.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__20.__5]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aaam-Xf10.6089-Yf-3.11075-Zf0aaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f0.951057Y+*f-0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f0.587785Y+*f-0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f-0.809017X*f-0.587785Y+*f0.587785X*f-0.809017Y_m-Xf0-Yf0-Zf0-f-2.2248Ym-Xf0-Yf0-Zf0m+*f0.309017X*f-0.951057Y+*f0.951057X*f0.309017Y_m-Xf0-Yf0-Zf0-f-2.2248Ynaa-f8.26994X-Xf8.84994a-f-3.93259Y-Yf-3.35259naa-f9.06634X-Xf9.64634a-f-1.63113Y-Yf-1.05113niiiiiaa-f12.3694X-Xf12.9494a-f-3.80788Y-Yf-3.26548aa-f12.3882X-Xf12.9306a-f-3.82668Y-Yf-3.24668-r+q-Xf12.3882q-Yf-3.80788f0.0187995-r+q-Xf12.3882q-Yf-3.26548f0.0187995-r+q-Xf12.9306q-Yf-3.80788f0.0187995-r+q-Xf12.9306q-Yf-3.26548f0.0187995',float('7.858900'),float('-5.860750'),float('-inf'),float('13.358900'),float('-0.360750'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 1711.5561725278701, 41.489656447431656 ], "name": "d10", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 26 }, { "datums": [ { "expr": "9.35634348840332", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-1.3411284886493684", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.58", "name": "width", "type": "float", "uid": 2 }, { "expr": "0.58", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f9.06634X-Xf9.64634a-f-1.63113Y-Yf-1.05113',float('9.066343'),float('-1.631128'),float('-inf'),float('9.646343'),float('-1.051129'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 785.98400042913545, -426.93601665735866 ], "name": "r8", "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": 21 }, { "datums": [ { "expr": "\u0011[__18.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0", "name": "hue", "type": "float", "uid": 1 }, { "expr": "1", "name": "saturation", "type": "float", "uid": 2 }, { "expr": "1", "name": "brightness", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aaaa-r+q-Xf0.827648q-Yf-2.69984f1naa-f1.53979X-Xf2.11979a-f-3.00844Y-Yf-2.42844naa-f0.554302X-Xf1.1343a-f-3.98436Y-Yf-3.40436naa-f0.529947X-Xf1.10995a-f-1.98683Y-Yf-1.40683naa-f-0.447016X-Xf0.132984a-f-2.99713Y-Yf-2.41713',float('-0.172352'),float('-3.699839'),float('-inf'),float('1.827648'),float('-1.699839'),float('inf'),color=(255,0,0))", "name": "out", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 620.13408527467777, 1449.2977641574364 ], "name": "s1", "script": [ "import math", "import fab", "", "title('Set color (HSB)')", "", "input(\"shape\", fab.types.Shape)", "input(\"hue\", float)", "input(\"saturation\", float)", "input(\"brightness\", float)", "", "# copied from Java's HSBtoRGB", "# http://www.docjar.com/html/api/java/awt/Color.java.html", "", "r = 0", "g = 0", "b = 0", "", "if saturation == 0:", " r = g = b = int(brightness * 255.0 + 0.5)", "else:", " h = (hue - float(math.floor(hue))) * 6.0", " f = h - float(math.floor(h))", " p = brightness * (1-saturation)", " q = brightness * (1-saturation*f)", " t = brightness * (1-(saturation*(1-f)))", "", " h = int(h)", "", " if(h==0):", " r = int(brightness * 255.0 + 0.5)", " g = int(t * 255.0 + 0.5)", " b = int(p * 255.0 + 0.5)", " elif(h==1):", " r = int(q * 255.0 + 0.5)", " g = int(brightness * 255.0 + 0.5)", " b = int(p * 255.0 + 0.5)", " elif(h==2):", " r = int(p * 255.0 + 0.5)", " g = int(brightness * 255.0 + 0.5)", " b = int(t * 255.0 + 0.5)", " elif(h==3):", " r = int(p * 255.0 + 0.5)", " g = int(q * 255.0 + 0.5)", " b = int(brightness * 255.0 + 0.5)", " elif(h==4):", " r = int(t * 255.0 + 0.5)", " g = int(p * 255.0 + 0.5)", " b = int(brightness * 255.0 + 0.5)", " elif(h==5):", " r = int(brightness * 255.0 + 0.5)", " g = int(p * 255.0 + 0.5)", " b = int(q * 255.0 + 0.5)", "", "output(\"out\", fab.shapes.set_color(shape, r, g, b))", "" ], "uid": 27 }, { "datums": [ { "expr": "\u0011[__27.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('aaaa-r+q-Xf0.827648q-Yf-2.69984f1naa-f1.53979X-Xf2.11979a-f-3.00844Y-Yf-2.42844naa-f0.554302X-Xf1.1343a-f-3.98436Y-Yf-3.40436naa-f0.529947X-Xf1.10995a-f-1.98683Y-Yf-1.40683naa-f-0.447016X-Xf0.132984a-f-2.99713Y-Yf-2.41713',float('-0.172352'),float('-3.699839'),float('-inf'),float('1.827648'),float('-1.699839'),float('inf'),color=(255,0,0))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 1185.7087057622975, 1533.2440160719366 ], "name": "h0", "script": [ "import fab", "", "title('Heightmap (.png)')", "", "input('shape', fab.types.Shape)", "output('out', shape)", "", "sb.export.heightmap(shape)", "" ], "uid": 28 } ], "protocol": 6, "type": "sb" }