Circle.js 784 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. /**
  3. * Circle object draw a circular object.
  4. */
  5. function Circle()
  6. {
  7. Object2D.call(this);
  8. /**
  9. * Radius of the circle.
  10. */
  11. this.radius = 10.0;
  12. /**
  13. * Color of the box border line.
  14. */
  15. this.strokeStyle = "#000000";
  16. }
  17. Circle.prototype = Object.create(Object2D.prototype);
  18. Circle.prototype.isInside = function(point)
  19. {
  20. return point.length() <= this.radius;
  21. };
  22. Circle.prototype.onPointerEnter = function(mouse, viewport)
  23. {
  24. this.strokeStyle = "#FF0000";
  25. };
  26. Circle.prototype.onPointerLeave = function(mouse, viewport)
  27. {
  28. this.strokeStyle = "#000000";
  29. };
  30. Circle.prototype.draw = function(context)
  31. {
  32. context.lineWidth = 1;
  33. context.strokeStyle = this.strokeStyle;
  34. context.beginPath();
  35. context.arc(0, 0, this.radius, 0, 2 * Math.PI);
  36. context.stroke();
  37. };