Closed MelchiorKokernoot closed 3 years ago
What is the a
parameter in $qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 127]);
???
I read through all the documentation and can't find it. I assume its a transparency value of some sort. Can it also be applied to the setForegroundColor
parameter as well?
Hi @rolinger, "a" stands for alpha and can be applied to the foreground color as well ;)
@MelchiorKokernoot this should be fixed.
If i configure like
$qrCode = new QrCode('https://www.google.com');
$qrCode->setSize(1000);
$qrCode->setMargin(50);
$qrCode->setWriterByName('png');
$qrCode->setEncoding('UTF-8');
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH());
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 127]);
$qrCode->setValidateResult(false);
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN);
header('Content-Type: ' . $qrCode->getContentType());
echo $qrCode->writeString();
I get a nice QR with a transparent background! But when I add:
$qrCode->setLabel('Testtest', 72,storage_path().'/app/fonts/Alata-Regular.ttf', LabelAlignment::CENTER());
The transparent background turns opaque again.