| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class ResultPoint |
| 5 |
* |
| 6 |
* @created 17.01.2021 |
| 7 |
* @author ZXing Authors |
| 8 |
* @author Smiley <[email protected]> |
| 9 |
* @copyright 2021 Smiley |
| 10 |
* @license Apache-2.0 |
| 11 |
*/ |
| 12 |
namespace WCPOS\Vendor\chillerlan\QRCode\Detector; |
| 13 |
|
| 14 |
use function abs; |
| 15 |
/** |
| 16 |
* Encapsulates a point of interest in an image containing a barcode. Typically, this |
| 17 |
* would be the location of a finder pattern or the corner of the barcode, for example. |
| 18 |
* |
| 19 |
* @author Sean Owen |
| 20 |
*/ |
| 21 |
abstract class ResultPoint |
| 22 |
{ |
| 23 |
protected float $x; |
| 24 |
protected float $y; |
| 25 |
protected float $estimatedModuleSize; |
| 26 |
/** |
| 27 |
* |
| 28 |
*/ |
| 29 |
public function __construct(float $x, float $y, float $estimatedModuleSize) |
| 30 |
{ |
| 31 |
$this->x = $x; |
| 32 |
$this->y = $y; |
| 33 |
$this->estimatedModuleSize = $estimatedModuleSize; |
| 34 |
} |
| 35 |
/** |
| 36 |
* |
| 37 |
*/ |
| 38 |
public function getX() : float |
| 39 |
{ |
| 40 |
return $this->x; |
| 41 |
} |
| 42 |
/** |
| 43 |
* |
| 44 |
*/ |
| 45 |
public function getY() : float |
| 46 |
{ |
| 47 |
return $this->y; |
| 48 |
} |
| 49 |
/** |
| 50 |
* |
| 51 |
*/ |
| 52 |
public function getEstimatedModuleSize() : float |
| 53 |
{ |
| 54 |
return $this->estimatedModuleSize; |
| 55 |
} |
| 56 |
/** |
| 57 |
* Determines if this finder pattern "about equals" a finder pattern at the stated |
| 58 |
* position and size -- meaning, it is at nearly the same center with nearly the same size. |
| 59 |
*/ |
| 60 |
public function aboutEquals(float $moduleSize, float $i, float $j) : bool |
| 61 |
{ |
| 62 |
if (abs($i - $this->y) <= $moduleSize && abs($j - $this->x) <= $moduleSize) { |
| 63 |
$moduleSizeDiff = abs($moduleSize - $this->estimatedModuleSize); |
| 64 |
return $moduleSizeDiff <= 1.0 || $moduleSizeDiff <= $this->estimatedModuleSize; |
| 65 |
} |
| 66 |
return \false; |
| 67 |
} |
| 68 |
} |
| 69 |
|