Circle.js 765 B

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