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/ColorResult.php | |
| parent | 758de879cb759576604e325e0de1900da4fd8cf9 (diff) | |
dynamic ascii art
Diffstat (limited to 'web/ColorResult.php')
| -rw-r--r-- | web/ColorResult.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/web/ColorResult.php b/web/ColorResult.php new file mode 100644 index 0000000..549bda0 --- /dev/null +++ b/web/ColorResult.php @@ -0,0 +1,20 @@ +<?php +/** + * Transforms an ascii result to a colored HTML representation. Each + * color value is represented by a single char, but HTML-styled to + * display the correct color. + * + * (c) 2016 Alex Schenkel + */ +namespace Img2Ascii; + +class ColorResult extends Result { + public $blockChar = '#'; // can also be an HTML entity, e.g. █ + + protected function transformValue($value) { + $r = floor($value[0]); + $g = floor($value[1]); + $b = floor($value[2]); + return "<span style='color:rgb({$r},{$g},{$b})'>{$this->blockChar}</span>"; + } +} |
