PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 2.9.2
WP 2FA – Two-factor authentication for WordPress v2.9.2
4.1.0 4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / bacon / bacon-qr-code / src / Renderer / Module / DotsModule.php
wp-2fa / includes / classes / bacon / bacon-qr-code / src / Renderer / Module Last commit date
EdgeIterator 1 year ago DotsModule.php 1 year ago ModuleInterface.php 1 year ago RoundnessModule.php 1 year ago SquareModule.php 1 year ago
DotsModule.php
48 lines
1 <?php
2
3 declare (strict_types=1);
4 namespace WP2FA_Vendor\BaconQrCode\Renderer\Module;
5
6 use WP2FA_Vendor\BaconQrCode\Encoder\ByteMatrix;
7 use WP2FA_Vendor\BaconQrCode\Exception\InvalidArgumentException;
8 use WP2FA_Vendor\BaconQrCode\Renderer\Path\Path;
9 /**
10 * Renders individual modules as dots.
11 */
12 final class DotsModule implements ModuleInterface
13 {
14 public const LARGE = 1;
15 public const MEDIUM = 0.8;
16 public const SMALL = 0.6;
17 /**
18 * @var float
19 */
20 private $size;
21 public function __construct(float $size)
22 {
23 if ($size <= 0 || $size > 1) {
24 throw new InvalidArgumentException('Size must between 0 (exclusive) and 1 (inclusive)');
25 }
26 $this->size = $size;
27 }
28 public function createPath(ByteMatrix $matrix) : Path
29 {
30 $width = $matrix->getWidth();
31 $height = $matrix->getHeight();
32 $path = new Path();
33 $halfSize = $this->size / 2;
34 $margin = (1 - $this->size) / 2;
35 for ($y = 0; $y < $height; ++$y) {
36 for ($x = 0; $x < $width; ++$x) {
37 if (!$matrix->get($x, $y)) {
38 continue;
39 }
40 $pathX = $x + $margin;
41 $pathY = $y + $margin;
42 $path = $path->move($pathX + $this->size, $pathY + $halfSize)->ellipticArc($halfSize, $halfSize, 0, \false, \true, $pathX + $halfSize, $pathY + $this->size)->ellipticArc($halfSize, $halfSize, 0, \false, \true, $pathX, $pathY + $halfSize)->ellipticArc($halfSize, $halfSize, 0, \false, \true, $pathX + $halfSize, $pathY)->ellipticArc($halfSize, $halfSize, 0, \false, \true, $pathX + $this->size, $pathY + $halfSize)->close();
43 }
44 }
45 return $path;
46 }
47 }
48