summaryrefslogtreecommitdiff
path: root/web/BlackWhiteResult.php
diff options
context:
space:
mode:
Diffstat (limited to 'web/BlackWhiteResult.php')
-rw-r--r--web/BlackWhiteResult.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/web/BlackWhiteResult.php b/web/BlackWhiteResult.php
new file mode 100644
index 0000000..f687ec6
--- /dev/null
+++ b/web/BlackWhiteResult.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * The black / white or "ascii art" output processor.
+ * Transforms the input color values into ascii art characters.
+ *
+ * (c) 2016 Alex Schenkel
+ */
+namespace Img2Ascii;
+require __DIR__ . '/result.php';
+
+class BlackWhiteResult extends Result {
+ public $symbols = "@%#*+=-:. ";
+
+ protected function gray2ascii($gray) {
+ $level = round($gray / 255.0 * (strlen($this->symbols)-1));
+ return $this->symbols[(int)min($level,strlen($this->symbols)-1)];
+ }
+ public function transformValue($value) {
+ return $this->gray2ascii($value);
+ }
+}