blob: f687ec64df19667887e0ebf19c0d3aa19b5232ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);
}
}
|