diff options
| author | Cristei Gabriel <cristei.g772@gmail.com> | 2023-12-18 03:19:59 +0200 |
|---|---|---|
| committer | Cristei Gabriel <cristei.g772@gmail.com> | 2023-12-18 03:19:59 +0200 |
| commit | 6442494822d12c23cdd609031c4039d3309b64f6 (patch) | |
| tree | c542f1039ecc8c5fe30cca3c3bad0481a0196d07 /web/BlackWhiteResult.php | |
| parent | 758de879cb759576604e325e0de1900da4fd8cf9 (diff) | |
dynamic ascii art
Diffstat (limited to 'web/BlackWhiteResult.php')
| -rw-r--r-- | web/BlackWhiteResult.php | 21 |
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); + } +} |
