summaryrefslogtreecommitdiff
path: root/web/ColorResult.php
blob: 549bda0081bca980cbdbec15a1db3da22034acf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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. &#x2588;

    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>";
    }
}