|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * reflectance.php |
| 4 | + * |
| 5 | + * @created 13.07.2023 |
| 6 | + * @author smiley <[email protected]> |
| 7 | + * @copyright 2023 smiley |
| 8 | + * @license MIT |
| 9 | + */ |
| 10 | + |
| 11 | +use chillerlan\QRCode\Common\EccLevel; |
| 12 | +use chillerlan\QRCode\Data\QRMatrix; |
| 13 | +use chillerlan\QRCode\Output\QROutputInterface; |
| 14 | +use chillerlan\QRCode\QRCode; |
| 15 | +use chillerlan\QRCode\QROptions; |
| 16 | + |
| 17 | +require_once __DIR__.'/../vendor/autoload.php'; |
| 18 | + |
| 19 | +$options = new QROptions([ |
| 20 | + 'outputType' => QROutputInterface::MARKUP_SVG, |
| 21 | + 'imageBase64' => false, |
| 22 | + 'svgAddXmlHeader' => false, |
| 23 | + 'connectPaths' => true, |
| 24 | + 'drawCircularModules' => false, |
| 25 | + 'drawLightModules' => true, |
| 26 | + 'addLogoSpace' => true, |
| 27 | + 'eccLevel' => EccLevel::H, |
| 28 | + 'logoSpaceWidth' => 11, |
| 29 | + 'moduleValues' => [ |
| 30 | + // finder |
| 31 | + QRMatrix::M_FINDER_DARK => '#555', // dark (true) |
| 32 | + QRMatrix::M_FINDER => '#ccc', // light (false) |
| 33 | + QRMatrix::M_FINDER_DOT => '#555', |
| 34 | + QRMatrix::M_FINDER_DOT_LIGHT => '#ccc', |
| 35 | + // alignment |
| 36 | + QRMatrix::M_ALIGNMENT_DARK => '#555', |
| 37 | + QRMatrix::M_ALIGNMENT => '#ccc', |
| 38 | + // timing |
| 39 | + QRMatrix::M_TIMING_DARK => '#555', |
| 40 | + QRMatrix::M_TIMING => '#ccc', |
| 41 | + // format |
| 42 | + QRMatrix::M_FORMAT_DARK => '#555', |
| 43 | + QRMatrix::M_FORMAT => '#ccc', |
| 44 | + // version |
| 45 | + QRMatrix::M_VERSION_DARK => '#555', |
| 46 | + QRMatrix::M_VERSION => '#ccc', |
| 47 | + // data |
| 48 | + QRMatrix::M_DATA_DARK => '#555', |
| 49 | + QRMatrix::M_DATA => '#ccc', |
| 50 | + // darkmodule |
| 51 | + QRMatrix::M_DARKMODULE_LIGHT => '#ccc', |
| 52 | + QRMatrix::M_DARKMODULE => '#555', |
| 53 | + // separator |
| 54 | + QRMatrix::M_SEPARATOR_DARK => '#555', |
| 55 | + QRMatrix::M_SEPARATOR => '#ccc', |
| 56 | + // quietzone |
| 57 | + QRMatrix::M_QUIETZONE_DARK => '#555', |
| 58 | + QRMatrix::M_QUIETZONE => '#ccc', |
| 59 | + // logo space |
| 60 | + QRMatrix::M_LOGO_DARK => '#555', |
| 61 | + QRMatrix::M_LOGO => '#ccc', |
| 62 | + ], |
| 63 | +]); |
| 64 | + |
| 65 | +$qrcode = (new QRCode($options))->addByteSegment('https://www.youtube.com/watch?v=dQw4w9WgXcQ'); |
| 66 | +$matrix = $qrcode->getQRMatrix(); |
| 67 | + |
| 68 | +// dump the output |
| 69 | +header('Content-type: text/html'); |
| 70 | + |
| 71 | +?> |
| 72 | +<!DOCTYPE html> |
| 73 | +<html lang="en"> |
| 74 | +<head> |
| 75 | + <meta charset="UTF-8"/> |
| 76 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> |
| 77 | + <title>QRCode Reflectance reversal Example</title> |
| 78 | + <style> |
| 79 | + #reflectance-example{ |
| 80 | + width: 500px; |
| 81 | + margin: 2em auto; |
| 82 | + } |
| 83 | + #reflectance-example > svg.qrcode{ |
| 84 | + margin: 1em; |
| 85 | + } |
| 86 | + </style> |
| 87 | +</head> |
| 88 | +<body> |
| 89 | +<div id="reflectance-example"> |
| 90 | + <!-- embed the SVG directly --> |
| 91 | + <?php |
| 92 | + echo $qrcode->renderMatrix($matrix); |
| 93 | + echo $qrcode->renderMatrix($matrix->invert()); |
| 94 | + ?> |
| 95 | +</div> |
| 96 | +</body> |
| 97 | +</html> |
| 98 | +<?php |
| 99 | + |
| 100 | +exit; |
0 commit comments