(canvas, realHeight, ratio)
| 358 | } |
| 359 | |
| 360 | _updateMask(canvas, realHeight, ratio) { |
| 361 | canvas.width = realHeight * ratio; |
| 362 | canvas.height = realHeight; |
| 363 | let context = canvas.getContext('2d'); |
| 364 | context.beginPath(); |
| 365 | this.timeParams[0].originBounds.forEach((coord, index) => { |
| 366 | if (index === 0) { |
| 367 | context.moveTo(coord, this.timeParams[0].originBounds[index + 1]); |
| 368 | } |
| 369 | if (index % 2 === 0) { |
| 370 | context.lineTo(coord, this.timeParams[0].originBounds[index + 1]); |
| 371 | } |
| 372 | }); |
| 373 | context.closePath(); |
| 374 | context.fillStyle = '#ffffff'; |
| 375 | context.fill(); |
| 376 | let imgData = context.getImageData(0, 0, canvas.width, canvas.height); |
| 377 | let clipMat = this.cv.matFromImageData(imgData); |
| 378 | let dst1 = new this.cv.Mat(); |
| 379 | return { clipMat, dst1 }; |
| 380 | } |
| 381 | |
| 382 | _contain(coord, bounds) { |
| 383 | return (coord[0] > bounds[0] || Math.abs(coord[0] - bounds[0]) < 0.000001 ) && (coord[0] < bounds[2] || Math.abs(coord[0] - bounds[2]) < 0.000001 ) && (coord[1] > bounds[1] || Math.abs(coord[1] - bounds[1]) < 0.000001) && (coord[1] < bounds[3] || Math.abs(coord[1] - bounds[3]) < 0.000001); |
no test coverage detected