* @function LevelRenderer.Tool.Areal.prototype.isInside * @description 包含判断。 * @param {Object} shape - 图形。 * @param {number} area - 目标区域。 * @param {number} x - 横坐标。 * @param {number} y - 纵坐标。 * @returns {boolean} 图形是否包含鼠标位置。
(shape, area, x, y)
| 105 | * @returns {boolean} 图形是否包含鼠标位置。 |
| 106 | */ |
| 107 | isInside(shape, area, x, y) { |
| 108 | if (!area || !shape) { |
| 109 | // 无参数或不支持类型 |
| 110 | return false; |
| 111 | } |
| 112 | var zoneType = shape.type; |
| 113 | |
| 114 | this._ctx = this._ctx || this.util.getContext(); |
| 115 | |
| 116 | // 未实现或不可用时则数学运算,主要是line,brokenLine,ring |
| 117 | var _mathReturn = this._mathMethod(shape, area, x, y); |
| 118 | if (typeof _mathReturn != 'undefined') { |
| 119 | return _mathReturn; |
| 120 | } |
| 121 | |
| 122 | if (shape.buildPath && this._ctx.isPointInPath) { |
| 123 | return this._buildPathMethod(shape, this._ctx, area, x, y); |
| 124 | } |
| 125 | |
| 126 | // 上面的方法都行不通时 |
| 127 | switch (zoneType) { |
| 128 | case 'ellipse': // Todo,不精确 |
| 129 | case 'smicellipse': // Todo,不精确 |
| 130 | return true; |
| 131 | // 旋轮曲线 不准确 |
| 132 | case 'trochoid': |
| 133 | var _r = area.location == 'out' |
| 134 | ? area.r1 + area.r2 + area.d |
| 135 | : area.r1 - area.r2 + area.d; |
| 136 | return this.isInsideCircle(area, x, y, _r); |
| 137 | // 玫瑰线 不准确 |
| 138 | case 'rose' : |
| 139 | return this.isInsideCircle(area, x, y, area.maxr); |
| 140 | // 路径,椭圆,曲线等-----------------13 |
| 141 | default: |
| 142 | return false; // Todo,暂不支持 |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * @function LevelRenderer.Tool.Areal.prototype._mathMethod |
no test coverage detected