* @function LevelRenderer.Tool.Areal.prototype._mathMethod * @description 包含判断。用数学方法判断,三个方法中最快,但是支持的shape少。 * @param {Object} shape - 图形。 * @param {number} area - 目标区域。 * @param {number} x - 横坐标。 * @param {number} y - 纵坐标。 * @returns {boolean} 图形是否包含鼠标位置,true表示坐标处在图形中。
(shape, area, x, y)
| 153 | * @returns {boolean} 图形是否包含鼠标位置,true表示坐标处在图形中。 |
| 154 | */ |
| 155 | _mathMethod(shape, area, x, y) { |
| 156 | var zoneType = shape.type; |
| 157 | // 在矩形内则部分图形需要进一步判断 |
| 158 | switch (zoneType) { |
| 159 | // 贝塞尔曲线 |
| 160 | case 'bezier-curve': |
| 161 | if (typeof(area.cpX2) === 'undefined') { |
| 162 | return this.isInsideQuadraticStroke( |
| 163 | area.xStart, area.yStart, |
| 164 | area.cpX1, area.cpY1, |
| 165 | area.xEnd, area.yEnd, |
| 166 | area.lineWidth, x, y |
| 167 | ); |
| 168 | } |
| 169 | return this.isInsideCubicStroke( |
| 170 | area.xStart, area.yStart, |
| 171 | area.cpX1, area.cpY1, |
| 172 | area.cpX2, area.cpY2, |
| 173 | area.xEnd, area.yEnd, |
| 174 | area.lineWidth, x, y |
| 175 | ); |
| 176 | // 线 |
| 177 | case 'line': |
| 178 | return this.isInsideLine( |
| 179 | area.xStart, area.yStart, |
| 180 | area.xEnd, area.yEnd, |
| 181 | area.lineWidth, x, y |
| 182 | ); |
| 183 | // 折线 |
| 184 | case 'broken-line': |
| 185 | return this.isInsideBrokenLine( |
| 186 | area.pointList, area.lineWidth, x, y |
| 187 | ); |
| 188 | // 扩展折线 |
| 189 | case 'smicbroken-line': { |
| 190 | // SMIC-修改 - start |
| 191 | let icX = x; |
| 192 | let icY = y; |
| 193 | if (shape.refOriginalPosition) { |
| 194 | icX = x - shape.refOriginalPosition[0]; |
| 195 | icY = y - shape.refOriginalPosition[1]; |
| 196 | } |
| 197 | return this.isInsideBrokenLine( |
| 198 | area.pointList, area.lineWidth, icX, icY |
| 199 | ); |
| 200 | } |
| 201 | //初始代码: |
| 202 | // return isInsideBrokenLine( |
| 203 | // area.pointList, area.lineWidth, x, y |
| 204 | // ); |
| 205 | // SMIC-修改 - end |
| 206 | // 圆环 |
| 207 | case 'ring': |
| 208 | return this.isInsideRing( |
| 209 | area.x, area.y, area.r0, area.r, x, y |
| 210 | ); |
| 211 | case 'smicring': { |
| 212 | let areaX = area.x; |
no test coverage detected