فهرست منبع

:sparkles: more examples

smiley 8 سال پیش
والد
کامیت
3d2f908d24
6فایلهای تغییر یافته به همراه163 افزوده شده و 0 حذف شده
  1. 34 0
      examples/MyCustomOutput.php
  2. 26 0
      examples/custom_output.php
  3. 2 0
      examples/html.php
  4. 60 0
      examples/image.php
  5. 2 0
      examples/svg.php
  6. 39 0
      examples/text.php

+ 34 - 0
examples/MyCustomOutput.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * Class MyCustomOutput
+ *
+ * @filesource   MyCustomOutput.php
+ * @created      24.12.2017
+ * @package      chillerlan\QRCodeExamples
+ * @author       Smiley <smiley@chillerlan.net>
+ * @copyright    2017 Smiley
+ * @license      MIT
+ */
+
+namespace chillerlan\QRCodeExamples;
+
+use chillerlan\QRCode\Output\QROutputAbstract;
+
+/**
+ */
+class MyCustomOutput extends QROutputAbstract{
+
+	public function dump(){
+
+		$output = '';
+
+		for($row = 0; $row < $this->moduleCount; $row++){
+			for($col = 0; $col < $this->moduleCount; $col++){
+				$output .= (int)$this->matrix->check($col, $row);
+			}
+		}
+
+		return $output;
+	}
+
+}

+ 26 - 0
examples/custom_output.php

@@ -0,0 +1,26 @@
+<?php
+/**
+ *
+ * @filesource   custom_output.php
+ * @created      24.12.2017
+ * @author       Smiley <smiley@chillerlan.net>
+ * @copyright    2017 Smiley
+ * @license      MIT
+ */
+
+namespace chillerlan\QRCodeExamples;
+
+use chillerlan\QRCode\{QRCode, QROptions};
+
+require_once __DIR__.'/../vendor/autoload.php';
+
+$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
+
+$options = new QROptions([
+	'version'      => 5,
+	'eccLevel'     => QRCode::ECC_L,
+]);
+
+$qrOutputInterface = new MyCustomOutput($options, (new QRCode($options))->getMatrix($data));
+
+var_dump($qrOutputInterface->dump());

+ 2 - 0
examples/html.php

@@ -8,6 +8,8 @@
  * @license      MIT
  */
 
+namespace chillerlan\QRCodeExamples;
+
 use chillerlan\QRCode\{QRCode, QROptions};
 
 require_once '../vendor/autoload.php';

+ 60 - 0
examples/image.php

@@ -0,0 +1,60 @@
+<?php
+/**
+ *
+ * @filesource   image.php
+ * @created      24.12.2017
+ * @author       Smiley <smiley@chillerlan.net>
+ * @copyright    2017 Smiley
+ * @license      MIT
+ */
+
+namespace chillerlan\QRCodeExamples;
+
+use chillerlan\QRCode\{QRCode, QROptions};
+
+require_once __DIR__.'/../vendor/autoload.php';
+
+$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
+
+$options = new QROptions([
+	'version'      => 5,
+	'outputType'   => QRCode::OUTPUT_IMAGE_PNG,
+	'eccLevel'     => QRCode::ECC_L,
+	'scale'        => 10,
+	'imageBase64'  => false,
+	'moduleValues' => [
+		// finder
+		1536 => [255, 0, 0], // dark (true)
+		6    => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
+		// alignment
+		2560 => [255, 0, 0],
+		10   => [255, 255, 255],
+		// timing
+		3072 => [0, 0, 0],
+		12   => [200,  200, 200],
+		// format
+		3584 => [0, 0, 0],
+		14   => [200,  200, 200],
+		// version
+		4096 => [0, 0, 0],
+		16   => [200,  200, 200],
+		// data
+		1024 => [0, 0, 150],
+		4    => [255, 255, 255],
+		// darkmodule
+		512  => [0, 0, 0],
+		// separator
+		8    => [200,  200, 200],
+		// quietzone
+		18   => [255, 255, 255],
+	],
+]);
+
+header('Content-type: image/png');
+
+echo (new QRCode($options))->render($data);
+
+
+
+
+

+ 2 - 0
examples/svg.php

@@ -8,6 +8,8 @@
  * @license      MIT
  */
 
+namespace chillerlan\QRCodeExamples;
+
 use chillerlan\QRCode\{QRCode, QROptions};
 
 require_once __DIR__.'/../vendor/autoload.php';

+ 39 - 0
examples/text.php

@@ -8,6 +8,8 @@
  * @license      MIT
  */
 
+namespace chillerlan\QRCodeExamples;
+
 use chillerlan\QRCode\{QRCode, QROptions};
 
 require_once __DIR__.'/../vendor/autoload.php';
@@ -24,6 +26,43 @@ $options = new QROptions([
 echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';
 
 
+// custom values
+$options = new QROptions([
+	'version'      => 5,
+	'outputType'   => QRCode::OUTPUT_STRING_TEXT,
+	'eccLevel'     => QRCode::ECC_L,
+	'moduleValues' => [
+		// finder
+		1536 => 'A', // dark (true)
+		6    => 'a', // light (false)
+		// alignment
+		2560 => 'B',
+		10   => 'b',
+		// timing
+		3072 => 'C',
+		12   => 'c',
+		// format
+		3584 => 'D',
+		14   => 'd',
+		// version
+		4096 => 'E',
+		16   => 'e',
+		// data
+		1024 => 'F',
+		4    => 'f',
+		// darkmodule
+		512  => 'G',
+		// separator
+		8    => 'h',
+		// quietzone
+		18   => 'i',
+	],
+]);
+
+// <pre> to view it in a browser
+echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';
+
+