diff --git a/examples/html.php b/examples/html.php
index 5ac189136..707f49ce8 100644
--- a/examples/html.php
+++ b/examples/html.php
@@ -44,7 +44,7 @@ header('Content-Type: text/html; charset=utf-8');
5,
diff --git a/examples/index.html b/examples/index.html
new file mode 100644
index 000000000..a53f3f3d4
--- /dev/null
+++ b/examples/index.html
@@ -0,0 +1,179 @@
+
+
+
+
+
+ QR Code Generator
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/qrcode-interactive.php b/examples/qrcode-interactive.php
new file mode 100644
index 000000000..637450e99
--- /dev/null
+++ b/examples/qrcode-interactive.php
@@ -0,0 +1,101 @@
+
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodePublic;
+
+use chillerlan\QRCode\Data\QRMatrix;
+use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\QROptions;
+
+require_once '../vendor/autoload.php';
+
+try{
+
+ $moduleValues = [
+ // finder
+ QRMatrix::M_FINDER | QRMatrix::IS_DARK => $_POST['m_finder_dark'],
+ QRMatrix::M_FINDER => $_POST['m_finder_light'],
+ QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => $_POST['m_finder_dot_dark'],
+ // alignment
+ QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => $_POST['m_alignment_dark'],
+ QRMatrix::M_ALIGNMENT => $_POST['m_alignment_light'],
+ // timing
+ QRMatrix::M_TIMING | QRMatrix::IS_DARK => $_POST['m_timing_dark'],
+ QRMatrix::M_TIMING => $_POST['m_timing_light'],
+ // format
+ QRMatrix::M_FORMAT | QRMatrix::IS_DARK => $_POST['m_format_dark'],
+ QRMatrix::M_FORMAT => $_POST['m_format_light'],
+ // version
+ QRMatrix::M_VERSION | QRMatrix::IS_DARK => $_POST['m_version_dark'],
+ QRMatrix::M_VERSION => $_POST['m_version_light'],
+ // data
+ QRMatrix::M_DATA | QRMatrix::IS_DARK => $_POST['m_data_dark'],
+ QRMatrix::M_DATA => $_POST['m_data_light'],
+ // darkmodule
+ QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => $_POST['m_darkmodule_dark'],
+ // separator
+ QRMatrix::M_SEPARATOR => $_POST['m_separator_light'],
+ // quietzone
+ QRMatrix::M_QUIETZONE => $_POST['m_quietzone_light'],
+ // logo
+ QRMatrix::M_LOGO => $_POST['m_logo_light'],
+ ];
+
+ $moduleValues = array_map(function($v){
+ if(preg_match('/[a-f\d]{6}/i', $v) === 1){
+ return in_array($_POST['output_type'], ['png', 'jpg', 'gif'])
+ ? array_map('hexdec', str_split($v, 2))
+ : '#'.$v ;
+ }
+ return null;
+ }, $moduleValues);
+
+
+ $ecc = in_array($_POST['ecc'], ['L', 'M', 'Q', 'H'], true) ? $_POST['ecc'] : 'L';
+
+ $options = new QROptions([
+ 'version' => (int)$_POST['version'],
+ 'eccLevel' => constant('chillerlan\\QRCode\\Common\\EccLevel::'.$ecc),
+ 'maskPattern' => (int)$_POST['maskpattern'],
+ 'addQuietzone' => isset($_POST['quietzone']),
+ 'quietzoneSize' => (int)$_POST['quietzonesize'],
+ 'moduleValues' => $moduleValues,
+ 'outputType' => $_POST['output_type'],
+ 'scale' => (int)$_POST['scale'],
+ 'imageBase64' => true,
+ 'imageTransparent' => false,
+ ]);
+
+ $qrcode = (new QRCode($options))->render($_POST['inputstring']);
+
+ if(in_array($_POST['output_type'], ['png', 'jpg', 'gif', 'svg'])){
+ $qrcode = '
';
+ }
+ elseif($_POST['output_type'] === 'text'){
+ $qrcode = ''.$qrcode.'
';
+ }
+ elseif($_POST['output_type'] === 'json'){
+ $qrcode = ''.$qrcode.'
';
+ }
+
+ send_response(['qrcode' => $qrcode]);
+}
+// Pokémon exception handler
+catch(\Exception $e){
+ header('HTTP/1.1 500 Internal Server Error');
+ send_response(['error' => $e->getMessage()]);
+}
+
+/**
+ * @param array $response
+ */
+function send_response(array $response){
+ header('Content-type: application/json;charset=utf-8;');
+ echo json_encode($response);
+ exit;
+}
diff --git a/public/index.html b/public/index.html
deleted file mode 100644
index d7bf6c891..000000000
--- a/public/index.html
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
-
-
- QR Code Generator
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/public/qrcode.php b/public/qrcode.php
deleted file mode 100644
index d4e5deb32..000000000
--- a/public/qrcode.php
+++ /dev/null
@@ -1,96 +0,0 @@
-
- * @copyright 2017 Smiley
- * @license MIT
- */
-
-namespace chillerlan\QRCodePublic;
-
-use chillerlan\QRCode\QRCode;
-use chillerlan\QRCode\QROptions;
-
-require_once '../vendor/autoload.php';
-
-try{
-
- $moduleValues = [
- // finder
- 1536 => $_POST['m_finder_dark'],
- 6 => $_POST['m_finder_light'],
- // alignment
- 2560 => $_POST['m_alignment_dark'],
- 10 => $_POST['m_alignment_light'],
- // timing
- 3072 => $_POST['m_timing_dark'],
- 12 => $_POST['m_timing_light'],
- // format
- 3584 => $_POST['m_format_dark'],
- 14 => $_POST['m_format_light'],
- // version
- 4096 => $_POST['m_version_dark'],
- 16 => $_POST['m_version_light'],
- // data
- 1024 => $_POST['m_data_dark'],
- 4 => $_POST['m_data_light'],
- // darkmodule
- 512 => $_POST['m_darkmodule_dark'],
- // separator
- 8 => $_POST['m_separator_light'],
- // quietzone
- 18 => $_POST['m_quietzone_light'],
- ];
-
- $moduleValues = array_map(function($v){
- if(preg_match('/[a-f\d]{6}/i', $v) === 1){
- return in_array($_POST['output_type'], ['png', 'jpg', 'gif'])
- ? array_map('hexdec', str_split($v, 2))
- : '#'.$v ;
- }
- return null;
- }, $moduleValues);
-
-
- $ecc = in_array($_POST['ecc'], ['L', 'M', 'Q', 'H'], true) ? $_POST['ecc'] : 'L';
-
- $qro = new QROptions;
-
- $qro->version = (int)$_POST['version'];
- $qro->eccLevel = constant('chillerlan\\QRCode\\QRCode::ECC_'.$ecc);
- $qro->maskPattern = (int)$_POST['maskpattern'];
- $qro->addQuietzone = isset($_POST['quietzone']);
- $qro->quietzoneSize = (int)$_POST['quietzonesize'];
- $qro->moduleValues = $moduleValues;
- $qro->outputType = $_POST['output_type'];
- $qro->scale = (int)$_POST['scale'];
- $qro->imageTransparent = false;
-
- $qrcode = (new QRCode($qro))->render($_POST['inputstring']);
-
- if(in_array($_POST['output_type'], ['png', 'jpg', 'gif'])){
- $qrcode = '
';
- }
- elseif($_POST['output_type'] === 'text'){
- $qrcode = ''.$qrcode.'
';
- }
- elseif($_POST['output_type'] === 'json'){
- $qrcode = ''.$qrcode.'
';
- }
-
- send_response(['qrcode' => $qrcode]);
-}
-// Pokémon exception handler
-catch(\Exception $e){
- header('HTTP/1.1 500 Internal Server Error');
- send_response(['error' => $e->getMessage()]);
-}
-
-/**
- * @param array $response
- */
-function send_response(array $response){
- header('Content-type: application/json;charset=utf-8;');
- echo json_encode($response);
- exit;
-}