ConnectionLine.js 597 B

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. function ConnectionLine()
  3. {
  4. Object2D.call(this);
  5. /**
  6. * Initial point of the line.
  7. */
  8. this.from = new Vector2();
  9. /**
  10. * Final point of the line.
  11. */
  12. this.to = new Vector2();
  13. /**
  14. * Color of the line.
  15. */
  16. this.color = "#000000";
  17. }
  18. ConnectionLine.prototype = Object.create(Object2D.prototype);
  19. ConnectionLine.prototype.draw = function(context)
  20. {
  21. context.lineWidth = 2;
  22. context.strokeStyle = this.color;
  23. context.setLineDash([10, 10]);
  24. context.beginPath();
  25. context.moveTo(this.from.x, this.from.y);
  26. context.lineTo(this.to.x, this.to.y);
  27. context.stroke();
  28. };