mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-17 23:21:13 +00:00
:octocat: circular modules in Imagick output
This commit is contained in:
@@ -17,11 +17,14 @@ require_once __DIR__.'/../vendor/autoload.php';
|
||||
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
|
||||
$options = new QROptions([
|
||||
'version' => 7,
|
||||
'outputType' => QRCode::OUTPUT_IMAGICK,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'scale' => 5,
|
||||
'moduleValues' => [
|
||||
'version' => 7,
|
||||
'outputType' => QRCode::OUTPUT_IMAGICK,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'scale' => 20,
|
||||
'drawCircularModules' => true,
|
||||
'circleRadius' => 0.4,
|
||||
'keepAsSquare' => [QRMatrix::M_FINDER|QRMatrix::IS_DARK, QRMatrix::M_FINDER_DOT, QRMatrix::M_ALIGNMENT|QRMatrix::IS_DARK],
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
QRMatrix::M_FINDER | QRMatrix::IS_DARK => '#A71111', // dark (true)
|
||||
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
|
||||
|
||||
@@ -103,7 +103,7 @@ class QRImagick extends QROutputAbstract{
|
||||
|
||||
foreach($this->matrix->matrix() as $y => $row){
|
||||
foreach($row as $x => $M_TYPE){
|
||||
$this->drawPixel($x, $y, $M_TYPE);
|
||||
$this->setPixel($x, $y, $M_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,14 +113,22 @@ class QRImagick extends QROutputAbstract{
|
||||
/**
|
||||
* draws a single pixel at the given position
|
||||
*/
|
||||
protected function drawPixel(int $x, int $y, int $M_TYPE):void{
|
||||
protected function setPixel(int $x, int $y, int $M_TYPE):void{
|
||||
$this->imagickDraw->setStrokeColor($this->moduleValues[$M_TYPE]);
|
||||
$this->imagickDraw->setFillColor($this->moduleValues[$M_TYPE]);
|
||||
$this->imagickDraw->rectangle(
|
||||
$x * $this->scale,
|
||||
$y * $this->scale,
|
||||
($x + 1) * $this->scale,
|
||||
($y + 1) * $this->scale
|
||||
|
||||
$this->options->drawCircularModules && !$this->matrix->checkTypes($x, $y, $this->options->keepAsSquare)
|
||||
? $this->imagickDraw->circle(
|
||||
($x + 0.5) * $this->scale,
|
||||
($y + 0.5) * $this->scale,
|
||||
($x + 0.5 + $this->options->circleRadius) * $this->scale,
|
||||
($y + 0.5) * $this->scale
|
||||
)
|
||||
: $this->imagickDraw->rectangle(
|
||||
$x * $this->scale,
|
||||
$y * $this->scale,
|
||||
($x + 1) * $this->scale,
|
||||
($y + 1) * $this->scale
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user