91c460595eb7b1fad1b399c6a8724bb90b77dfaa.svn-base 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * zrender
  3. *
  4. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  5. *
  6. * shape类:handlePolygon,dataRange手柄
  7. */
  8. define(function (require) {
  9. var Base = require('zrender/shape/Base');
  10. var PolygonShape = require('zrender/shape/Polygon');
  11. var zrUtil = require('zrender/tool/util');
  12. function HandlePolygon(options) {
  13. Base.call(this, options);
  14. }
  15. HandlePolygon.prototype = {
  16. type : 'handle-polygon',
  17. /**
  18. * 创建多边形路径
  19. * @param {Context2D} ctx Canvas 2D上下文
  20. * @param {Object} style 样式
  21. */
  22. buildPath : function (ctx, style) {
  23. PolygonShape.prototype.buildPath(
  24. ctx, style
  25. );
  26. },
  27. isCover : function (x, y) {
  28. var originPos = this.transformCoordToLocal(x, y);
  29. x = originPos[0];
  30. y = originPos[1];
  31. // 不能缓存rect!
  32. var rect = this.style.rect;
  33. if (x >= rect.x
  34. && x <= (rect.x + rect.width)
  35. && y >= rect.y
  36. && y <= (rect.y + rect.height)
  37. ) {
  38. // 矩形内
  39. return true;
  40. }
  41. else {
  42. return false;
  43. }
  44. }
  45. };
  46. zrUtil.inherits(HandlePolygon, Base);
  47. return HandlePolygon;
  48. });