public function generateColorCoding($mode, $isFill = false) {

        // initialize the returned code
        $codes = "";

        // ensure the color has a value
        if ($this->isValid()) {
            
            // cast the mode into the class 
            $mode = new Mode($mode);

            // generally you add 10 to escape numbers to switch to fill
            $base = 0;

            // if is fill
            if ($isFill) {

                // use a base of 10
                $base = 10;
            }

            // go through the different terminal modes
            switch ($mode->getMode()) {

                // legacy mode, uses straight-up ansi codes
                case Mode::VT100:

                    // return the coding for old style color (and make it a string like the rest)
                    $codes = ($base + $this->getANSICode()) . "";
                    break;

                
                // Full RGB color, starts with 38;2 for text, or 48;2 for fill followed by R;G;B numbers
                case Mode::RGB:

                    // get the [R,G,B]
                    $RGB = $this->getRGB();

                    // return the full RGB coding
                    $codes  =($base + 38) . ";2;" . $RGB[0] . ";" . $RGB[1] . ";" . $RGB[2];
                    break;

                // Xterm codes, start with 38;5 for text and 48;5 for fill followed by a number from 0-255 for different colors
                case Mode::XTERM:

                    // return the coding for xterm colors
                    $codes = ($base + 38) . ";5;" . $this->getXTermCode();
                    break;

            }
        }

        // return the sequence
        return $codes;

    }
public function generateColorCoding($mode, $isFill = false) {

        // initialize the returned code
        $codes = "";

        // ensure the color has a value
        if ($this->isValid()) {
            
            // cast the mode into the class 
            $mode = new Mode($mode);

            // generally you add 10 to escape numbers to switch to fill
            $base = 0;

            // if is fill
            if ($isFill) {

                // use a base of 10
                $base = 10;
            }

            // go through the different terminal modes
            switch ($mode->getMode()) {

                // legacy mode, uses straight-up ansi codes
                case Mode::VT100:

                    // return the coding for old style color (and make it a string like the rest)
                    $codes = ($base + $this->getANSICode()) . "";
                    break;

                
                // Full RGB color, starts with 38;2 for text, or 48;2 for fill followed by R;G;B numbers
                case Mode::RGB:

                    // get the [R,G,B]
                    $RGB = $this->getRGB();

                    // return the full RGB coding
                    $codes  =($base + 38) . ";2;" . $RGB[0] . ";" . $RGB[1] . ";" . $RGB[2];
                    break;

                // Xterm codes, start with 38;5 for text and 48;5 for fill followed by a number from 0-255 for different colors
                case Mode::XTERM:

                    // return the coding for xterm colors
                    $codes = ($base + 38) . ";5;" . $this->getXTermCode();
                    break;

            }
        }

        // return the sequence
        return $codes;

    }
public function generateColorCoding ( $ mode , $ isFill = false ) { // initialize the returned code $ codes = "" ; // ensure the color has a value if ( $ this -> isValid ( ) ) { // cast the mode into the class  $ mode = new Mode ( $ mode ) ; // generally you add 10 to escape numbers to switch to fill $ base = 0 ; // if is fill if ( $ isFill ) { // use a base of 10 $ base = 10 ; } // go through the different terminal modes switch ( $ mode -> getMode ( ) ) { // legacy mode, uses straight-up ansi codes case Mode :: VT100 : // return the coding for old style color (and make it a string like the rest) $ codes = ( $ base + $ this -> getANSICode ( ) ) . "" ; break ; // Full RGB color, starts with 38;2 for text, or 48;2 for fill followed by R;G;B numbers case Mode :: RGB : // get the [R,G,B] $ RGB = $ this -> getRGB ( ) ; // return the full RGB coding $ codes = ( $ base + 38 ) . ";2;" . $ RGB [ 0 ] . ";" . $ RGB [ 1 ] . ";" . $ RGB [ 2 ] ; break ; // Xterm codes, start with 38;5 for text and 48;5 for fill followed by a number from 0-255 for different colors case Mode :: XTERM : // return the coding for xterm colors $ codes = ( $ base + 38 ) . ";5;" . $ this -> getXTermCode ( ) ; break ; } } // return the sequence return $ codes ; }
Generate a color coding based on the terminal type

@param Mode | int | string $mode
Mode
send in a Mode object built already
integer -
send in the desired number of colors to pick the closest mode (<16 for VT100, >16 and <256 for xterm and > 256 for RGB)
string -
send in one of the constants Mode::VT100, Mode::XTERM, or Mode::RGB
send in one of the actual string values for the constants (case insensitive) "vt100", "RGB", "xterm"
@param boolean $isFill - whether the color is a fill

@return string
Generate a color coding based on the terminal type