mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-24 16:17:54 +00:00
🛀 fix examples
This commit is contained in:
@@ -20,7 +20,7 @@ class MyCustomOutput extends QROutputAbstract{
|
||||
// TODO: Implement setModuleValues() method.
|
||||
}
|
||||
|
||||
public function dump(string $file = null){
|
||||
public function dump(string $file = null):string{
|
||||
|
||||
$output = '';
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ class QRImageWithLogo extends QRImage{
|
||||
}
|
||||
|
||||
$this->matrix->setLogoSpace(
|
||||
$this->options->logoWidth,
|
||||
$this->options->logoHeight
|
||||
// not utilizing the position here
|
||||
$this->options->logoSpaceWidth,
|
||||
$this->options->logoSpaceHeight
|
||||
// not utilizing the position here
|
||||
);
|
||||
|
||||
// there's no need to save the result of dump() into $this->image here
|
||||
@@ -56,8 +56,8 @@ class QRImageWithLogo extends QRImage{
|
||||
$h = imagesy($im);
|
||||
|
||||
// set new logo size, leave a border of 1 module
|
||||
$lw = ($this->options->logoWidth - 2) * $this->options->scale;
|
||||
$lh = ($this->options->logoHeight - 2) * $this->options->scale;
|
||||
$lw = ($this->options->logoSpaceWidth - 2) * $this->options->scale;
|
||||
$lh = ($this->options->logoSpaceHeight - 2) * $this->options->scale;
|
||||
|
||||
// get the qrcode size
|
||||
$ql = $this->matrix->size() * $this->options->scale;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
@@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
// invoke the QROutputInterface manually
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'eccLevel' => EccLevel::L,
|
||||
]);
|
||||
|
||||
$qrcode = new QRCode($options);
|
||||
@@ -33,7 +34,7 @@ var_dump($qrOutputInterface->dump());
|
||||
// or just
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'outputType' => QRCode::OUTPUT_CUSTOM,
|
||||
'outputInterface' => MyCustomOutput::class,
|
||||
]);
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
@@ -11,7 +12,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
$options = new QROptions([
|
||||
'version' => 7,
|
||||
'outputType' => QRCode::OUTPUT_FPDF,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'scale' => 5,
|
||||
'imageBase64' => false,
|
||||
'moduleValues' => [
|
||||
|
||||
+4
-3
@@ -11,6 +11,7 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
@@ -60,9 +61,9 @@ header('Content-Type: text/html; charset=utf-8');
|
||||
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_HTML,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'version' => 5,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_HTML,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
1536 => '#A71111', // dark (true)
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
@@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
$options = new QROptions([
|
||||
'version' => 10,
|
||||
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
|
||||
'eccLevel' => QRCode::ECC_H,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'scale' => 5,
|
||||
'imageBase64' => false,
|
||||
'moduleValues' => [
|
||||
|
||||
@@ -11,28 +11,29 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
/**
|
||||
* @property int $logoWidth
|
||||
* @property int $logoHeight
|
||||
* @property int $logoSpaceWidth
|
||||
* @property int $logoSpaceHeight
|
||||
*
|
||||
* @noinspection PhpIllegalPsrClassPathInspection
|
||||
*/
|
||||
class LogoOptions extends QROptions{
|
||||
protected int $logoWidth;
|
||||
protected int $logoHeight;
|
||||
protected int $logoSpaceWidth;
|
||||
protected int $logoSpaceHeight;
|
||||
}
|
||||
|
||||
$options = new LogoOptions;
|
||||
|
||||
$options->version = 7;
|
||||
$options->eccLevel = QRCode::ECC_H;
|
||||
$options->eccLevel = EccLevel::H;
|
||||
$options->imageBase64 = false;
|
||||
$options->logoWidth = 13;
|
||||
$options->logoHeight = 13;
|
||||
$options->logoSpaceWidth = 13;
|
||||
$options->logoSpaceHeight = 13;
|
||||
$options->scale = 5;
|
||||
$options->imageTransparent = false;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
@@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
$options = new QROptions([
|
||||
'version' => 7,
|
||||
'outputType' => QRCode::OUTPUT_IMAGICK,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'scale' => 5,
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
|
||||
+8
-7
@@ -11,6 +11,7 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
@@ -18,14 +19,14 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
$gzip = true;
|
||||
|
||||
$options = new QROptions([
|
||||
'version' => 7,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'version' => 7,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'svgViewBoxSize' => 530,
|
||||
'addQuietzone' => true,
|
||||
'cssClass' => 'my-css-class',
|
||||
'svgOpacity' => 1.0,
|
||||
'svgDefs' => '
|
||||
'addQuietzone' => true,
|
||||
'cssClass' => 'my-css-class',
|
||||
'svgOpacity' => 1.0,
|
||||
'svgDefs' => '
|
||||
<linearGradient id="g2">
|
||||
<stop offset="0%" stop-color="#39F" />
|
||||
<stop offset="100%" stop-color="#F3F" />
|
||||
|
||||
+3
-2
@@ -11,6 +11,7 @@
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
@@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'outputType' => QRCode::OUTPUT_STRING_TEXT,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'eccLevel' => EccLevel::L,
|
||||
]);
|
||||
|
||||
// <pre> to view it in a browser
|
||||
@@ -30,7 +31,7 @@ echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->ren
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'outputType' => QRCode::OUTPUT_STRING_TEXT,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
1536 => 'A', // dark (true)
|
||||
|
||||
Reference in New Issue
Block a user