tentone 5 vuotta sitten
vanhempi
commit
3876141279

+ 1 - 1
examples/node.html

@@ -64,7 +64,7 @@
 
 
 
-		function NodeInput()
+		function NodeHook()
 		{
 			this.inputs = [];
 			this.outputs = [];

+ 1 - 1
source/Escher.js

@@ -29,7 +29,7 @@ export {QuadraticCurve} from "./objects/QuadraticCurve.js";
 
 export {Node} from "./objects/node/Node.js";
 export {NodeConnector} from "./objects/node/NodeConnector.js";
-export {NodeInput} from "./objects/node/NodeInput.js";
+export {NodeHook} from "./objects/node/NodeHook.js";
 export {NodeOutput} from "./objects/node/NodeOutput.js";
 
 export {ViewportControls} from "./controls/ViewportControls.js";

+ 2 - 2
source/math/Box2.js

@@ -181,7 +181,7 @@ Box2.prototype.expandByScalar = function(scalar)
  */
 Box2.prototype.containsPoint = function(point)
 {
-	return point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y ? false : true;
+	return !(point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y);
 };
 
 /**
@@ -205,7 +205,7 @@ Box2.prototype.containsBox = function(box)
  */
 Box2.prototype.intersectsBox = function(box)
 {
-	return box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y ? false : true;
+	return !(box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y);
 };
 
 /**

+ 2 - 4
source/math/UUID.js

@@ -6,16 +6,14 @@
 function UUID(){}
 
 /**
- * Generate new random UUID v4 as string.
- *
- * http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
+ * Generates a new random UUID v4 as string.
  *
  * @static
+ * @return {string} UUID generated as string.
  */
 UUID.generate = (function ()
 {
 	var lut = [];
-
 	for(var i = 0; i < 256; i++)
 	{
 		lut[i] = (i < 16 ? "0" : "") + (i).toString(16);

+ 1 - 1
source/objects/Box.js

@@ -17,7 +17,7 @@ function Box()
 	/**
 	 * Box object containing the size of the object.
 	 */
-	this.box = new Box2(new Vector2(-50, -35), new Vector2(50, 35));
+	this.box = new Box2(new Vector2(-50, -50), new Vector2(50, 50));
 
 	/**
 	 * Style of the object border line.

+ 17 - 1
source/objects/node/Node.js

@@ -13,12 +13,28 @@ function Node()
 {
 	Box.call(this);
 
+	/**
+	 * List of inputs of the node.
+	 *
+	 * @type {NodeHook[]}
+	 */
 	this.inputs = [];
 
+	/**
+	 * List of outputs of the node.
+	 *
+	 * @type {NodeHook[]}
+	 */
 	this.outputs = [];
-
 }
 
 Node.prototype = Object.create(Box.prototype);
 
+Node.prototype.draw = function(context, viewport, canvas)
+{
+	Box.prototype.draw.call(this, context, viewport, canvas);
+
+	// TODO <ADD CODE HERE>
+};
+
 export {Node};

+ 13 - 1
source/objects/node/NodeConnector.js

@@ -11,7 +11,19 @@ function NodeConnector()
 {
 	BezierCurve.call(this);
 
-	// TODO <ADD CODE HERE>
+	/**
+	 * Origin hook that is attached to a node.
+	 *
+	 * @type {NodeHook}
+	 */
+	this.origin = null;
+
+	/**
+	 * Destination hook that is attached to a node.
+	 *
+	 * @type {NodeHook}
+	 */
+	this.destination = null;
 }
 
 NodeConnector.prototype = Object.create(BezierCurve.prototype);

+ 12 - 9
source/objects/node/NodeHook.js

@@ -2,19 +2,21 @@ import {Circle} from "../Circle";
 import {Node} from "./Node";
 
 /**
- * Represents a node input point. Is attached to the node element and represented visually.
+ * Represents a node hook point. Is attached to the node element and represented visually.
  *
- * @class NodeInput
+ * Can be used as a node input, output or as a bidirectional connection.
+ *
+ * @class NodeHook
  */
-function NodeInput(node)
+function NodeHook(node)
 {
 	Circle.call(this);
 
 	/**
 	 * Direction of the node hook.
 	 */
-	this.direction = NodeInput.INPUT;
-	
+	this.direction = NodeHook.INPUT;
+
 	/**
 	 * Node where this input element in attached.
 	 *
@@ -23,9 +25,10 @@ function NodeInput(node)
 	this.node = null;
 }
 
-NodeInput.INPUT = 1;
-NodeInput.OUTPUT = 2;
+NodeHook.INPUT = 1;
+NodeHook.OUTPUT = 2;
+NodeHook.BIDIRECTIONAL = 3;
 
-NodeInput.prototype = Object.create(Circle.prototype);
+NodeHook.prototype = Object.create(Circle.prototype);
 
-export {NodeInput};
+export {NodeHook};