Page MenuHomeWickedGov Phorge

SquareModule.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

SquareModule.php

<?php
declare(strict_types = 1);
namespace BaconQrCode\Renderer\Module;
use BaconQrCode\Encoder\ByteMatrix;
use BaconQrCode\Renderer\Module\EdgeIterator\EdgeIterator;
use BaconQrCode\Renderer\Path\Path;
/**
* Groups modules together to a single path.
*/
final class SquareModule implements ModuleInterface
{
/**
* @var self|null
*/
private static $instance;
private function __construct()
{
}
public static function instance() : self
{
return self::$instance ?: self::$instance = new self();
}
public function createPath(ByteMatrix $matrix) : Path
{
$path = new Path();
foreach (new EdgeIterator($matrix) as $edge) {
$points = $edge->getSimplifiedPoints();
$length = count($points);
$path = $path->move($points[0][0], $points[0][1]);
for ($i = 1; $i < $length; ++$i) {
$path = $path->line($points[$i][0], $points[$i][1]);
}
$path = $path->close();
}
return $path;
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Jul 3, 21:42 (18 h, 53 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f4/3d/e8d0962045905709136e5a68dc51
Default Alt Text
SquareModule.php (1 KB)

Event Timeline