tentone 6 years ago
parent
commit
7e9c711911
2 changed files with 16 additions and 1 deletions
  1. 4 0
      index.html
  2. 12 1
      source/objects/ConnectionLine.js

+ 4 - 0
index.html

@@ -54,6 +54,10 @@
 		rb.position.set(50, 300);
 		rb.position.set(50, 300);
 		o.add(rb);
 		o.add(rb);
 
 
+		var l = new ConnectionLine();
+		l.to.set(-500, 0);
+		o.add(l);
+
 		var v = new Viewport();
 		var v = new Viewport();
 
 
 		var r = new Renderer(canvas);
 		var r = new Renderer(canvas);

+ 12 - 1
source/objects/ConnectionLine.js

@@ -13,11 +13,22 @@ function ConnectionLine(src)
 	 * Final point of the line.
 	 * Final point of the line.
 	 */
 	 */
 	this.to = new Vector2();
 	this.to = new Vector2();
+
+	/**
+	 * Color of the line.
+	 */
+	this.color = "#000000";
 }
 }
 
 
 ConnectionLine.prototype = Object.create(Object2D.prototype);
 ConnectionLine.prototype = Object.create(Object2D.prototype);
 
 
 ConnectionLine.prototype.draw = function(context)
 ConnectionLine.prototype.draw = function(context)
 {
 {
-	//TODO
+	context.lineWidth = 2;
+	context.strokeStyle = this.color;
+
+	context.beginPath();
+	context.moveTo(this.from.x, this.from.y);
+	context.lineTo(this.to.x, this.to.y);
+	context.stroke();
 };
 };