Debian Codegraph @

vendor/chillerlan/php-qrcode/src/Detector/ResultPoint.php

raw
1 <?php
2 /**
3 * Class ResultPoint
4 *
5 * @created 17.01.2021
6 * @author ZXing Authors
7 * @author Smiley <[email protected]>
8 * @copyright 2021 Smiley
9 * @license Apache-2.0
10 */
11 declare(strict_types=1);
12
13 namespace chillerlan\QRCode\Detector;
14
15 use function abs;
16
17 /**
18 * Encapsulates a point of interest in an image containing a barcode. Typically, this
19 * would be the location of a finder pattern or the corner of the barcode, for example.
20 *
21 * @author Sean Owen
22 */
23 abstract class ResultPoint{
24
25 protected float $x;
26 protected float $y;
27 protected float $estimatedModuleSize;
28
29 public function __construct(float $x, float $y, float $estimatedModuleSize){
30 $this->x = $x;
31 $this->y = $y;
32 $this->estimatedModuleSize = $estimatedModuleSize;
33 }
34
35 /**
36 * @deprecated 6.0.1 This method will be removed. In v7, use the property "ResultPoint::$x" instead.
37 */
38 public function getX():float{
39 return $this->x;
40 }
41
42 /**
43 * @deprecated 6.0.1 This method will be removed. In v7, use the property "ResultPoint::$y" instead.
44 */
45 public function getY():float{
46 return $this->y;
47 }
48
49 /**
50 * @deprecated 6.0.1 This method will be removed. In v7, use the property "ResultPoint::$estimatedModuleSize" instead.
51 */
52 public function getEstimatedModuleSize():float{
53 return $this->estimatedModuleSize;
54 }
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
65 return $moduleSizeDiff <= 1.0 || $moduleSizeDiff <= $this->estimatedModuleSize;
66 }
67
68 return false;
69 }
70
71 }