Create a chart of common surnames.

@param string|null $color_from
@param string|null $color_to
@param int         $number_of_surnames

@return string
547983
public function chartCommonSurnames(
        string $color_from = null,
        string $color_to = null,
        int $number_of_surnames = 10
    ): string {
        $tot_indi     = $this->totalIndividualsQuery();
        $all_surnames = $this->topSurnames($number_of_surnames, 0);

        if (empty($all_surnames)) {
            return I18N::translate('This information is not available.');
        }

        return (new ChartCommonSurname($this->tree))
            ->chartCommonSurnames($tot_indi, $all_surnames, $color_from, $color_to);
    }
1192356
public function chartNoChildrenFamilies(
        int $no_child_fam,
        int $year1 = -1,
        int $year2 = -1
    ): string {
        $data = [
            [
                I18N::translate('Century'),
                I18N::translate('Total')
            ]
        ];

        $total = 0;

        foreach ($this->queryRecords($year1, $year2) as $record) {
            $total += $record->total;

            $data[] = [
                $this->century_service->centuryName((int) $record->century),
                $record->total
            ];
        }

        if ($total) {
            $data[] = [
                I18N::translateContext('unknown century', 'Unknown'),
                $no_child_fam - $total
            ];
        }

        $chart_title   = I18N::translate('Number of families without children');
        $chart_options = [
            'title' => $chart_title,
            'subtitle' => '',
            'legend' => [
                'position'  => 'none',
            ],
            'vAxis' => [
                'title' => I18N::translate('Total families'),
            ],
            'hAxis' => [
                'title' => I18N::translate('Century'),
            ],
            'colors' => [
                '#84beff'
            ],
        ];

        return view(
            'statistics/other/charts/column',
            [
                'data'          => $data,
                'chart_options' => $chart_options,
                'chart_title'   => $chart_title,
            ]
        );
    }
941766
def from_name(clz, name):
        
        if isinstance(name, list) and "green" in name:
            name = "teal"
        assert name in COLOR_NAMES, 'Unknown color name'
        r, b, g = COLOR_NAMES[name]
        return clz(r, b, g)
881513
function (sColor) {
				var sHexColor = "";

				if (!sColor || sColor.toLowerCase().indexOf("hsl") !== -1) {
					return undefined;
				}

				// named color
				if (sColor.indexOf("#") === -1) {
					return this.NAME_COLORS_TO_RGB_MAP[sColor.toLowerCase()] ? sColor.toLowerCase() : undefined;
				}

				//HEX value
				if (sColor.length === 4) {
					sHexColor = ["#", sColor[1], sColor[1], sColor[2], sColor[2], sColor[3], sColor[3]].join("");
				} else {
					sHexColor = sColor;
				}

				sHexColor = sHexColor.toUpperCase();

				return this.RGB_TO_NAMED_COLORS_MAP[sHexColor];
			}
658725
public function send($message, $from, $color = null)
    {
        $data = [
            'room_id' => $this->name,
            'message' => $message,
            'from' => $from
        ];

        if ($color) {
            $data['color'] = $color;
        }

        $this->connection->write('/v1/rooms/message', $data);
    }
995097
protected function getColorScore($color, $count, $colorsCount)
	    {
	        $sRGBComponents = $this->getSRGBComponents($this->getRGBComponents($color));
	        $max 			= max($sRGBComponents);
	        $min 			= min($sRGBComponents);
	        $diff 			= $max - $min;
	        $sum 			= $max + $min;
	        $saturation 	= $diff ? ($sum / 2 > .5 ? $diff / (2 - $diff) : $diff / $sum) : 0;
	        $luminosity 	= ($sum / 2 + .2126 * $sRGBComponents[0] + .7152 * $sRGBComponents[1] + .0722 * $sRGBComponents[2]) / 2;

	        return $saturation < .5 ?
	            (1 - $luminosity) * $count / $colorsCount :
	            $count * ($saturation) * $luminosity;
	    }
966070
public static Color nameToColor(String strColor)
    {
        final Object[][] obj = {
            {"black", Color.black},
            {"blue", Color.blue},
            {"cyan", Color.cyan},
            {"darkGray", Color.darkGray},
            {"gray", Color.gray},
            {"green", Color.green},
            {"lightGray", Color.lightGray},
            {"magenta", Color.magenta},
            {"orange", Color.orange},
            {"pink", Color.pink},
            {"red", Color.red},
            {"white", Color.white},
            {"yellow", Color.yellow}
        };      // Not static, because this method is usually not called.
        for (int i = 0; i < obj.length; i++)
        {
            if (strColor.equalsIgnoreCase((String)obj[i][0]))
                return (Color)obj[i][1];
        }
        try {
            return Color.decode(strColor);
        } catch (NumberFormatException ex)  {
        }
        return null;
    }
909296
public function statsBirth(string $color_from = null, string $color_to = null): string
    {
        return (new ChartBirth($this->tree))
            ->chartBirth($color_from, $color_to);
    }
924353
public static ColorStateList getTextColorStateList(int text_color, int selected_text_color) {
        return new ColorStateList(
                new int[][]{
                        new int[]{android.R.attr.state_selected},
                        new int[]{}
                },
                new int[]{
                        selected_text_color,
                        text_color
                }
        );
    }
1190250
protected function renderContent() {
        
        /** @var \Fisharebest\Webtrees\Tree $tree */
        $tree = $this->data->get('tree');
        
        echo '<h2 class="center">', $this->data->get('title') , '</h2>';
        echo '<p class="center alpha_index">', implode(' | ', $this->getInitialLettersList()), '</p>';
         
        if($this->data->get('issurnames', false)) {
            $surns = $this->data->get('surnameslist', array());
            $extra_params = array ('mod' => Constants::MODULE_MAJ_PATROLIN_NAME, 'mod_action' => 'Lineage');
            // Show the surname list
            switch ($tree->getPreference('SURNAME_LIST_STYLE')) {
                case 'style1':
					echo FunctionsPrintLists::surnameList($surns, 3, true, WT_SCRIPT_NAME, $tree, $extra_params);
					break;
                case 'style3':
                    echo FunctionsPrintLists::surnameTagCloud($surns, WT_SCRIPT_NAME, true, $tree, $extra_params);
                    break;
                case 'style2':
                default:
                    echo FunctionsPrintLists::surnameTable($surns, WT_SCRIPT_NAME, $tree, $extra_params);
                    break;
            }
        }
        else if ($this->data->get('islineages', false)) {
            //Link to indilist
            echo '<p class="center"><strong>'.
                '<a href="indilist.php?ged=' . $tree->getNameUrl() . '&surname=' . rawurlencode($this->data->get('surname')) .'">'. 
                I18N::translate('Go to the list of individuals with surname %s', $this->data->get('legend')).
                '</a></strong></p>';
            
            $lineages = $this->data->get('lineages', null);
            $nb_lineages = is_null($lineages) ? 0 : count($lineages);
            if($nb_lineages == 0) {
            	echo '<p class="center"><span class="warning">',
            		I18N::translate('No individuals with surname %s has been found. Please try another name.',
            			'<span dir="auto">' . $this->data->get('legend') . '</span>'),
            			'</span></p>';
            } else { 
            	
            	echo '<div id="patronymiclineages">'.
            		'<div class="list_label">',
            		$this->data->get('table_title'),
            		'</div>';
            	
            	echo '<div class="list_value_wrap">';            	
            	
            	foreach($lineages as $i => $lineage) {
            		$this->printRootLineage($lineage);
            		if($i < $nb_lineages - 1) echo '<hr />';
            	}
            	
            	echo '</div>';
            	
            	echo '<div class="list_label">',
            		I18N::translate('%s lineages found', $nb_lineages),
            		'</div>'.
            		'</div>';

            }
        }
    }
474884
function colorLines(name, str) {
  return str
    .split('\n')
    .map(function(str) {
      return color(name, str);
    })
    .join('\n');
}
454273
public static function GetColorNameList () {
		return [
			static::NAME_INDIAN_RED,
			static::NAME_LIGHT_CORAL,
			static::NAME_SALMON ,
			static::NAME_DARK_SALMON,
			static::NAME_LIGHT_SALMON,
			static::NAME_CRIMSON,
			static::NAME_RED,
			static::NAME_FIRE_BRICK ,
			static::NAME_DARK_RED,
			static::NAME_PINK,
			static::NAME_LIGHT_PINK ,
			static::NAME_HOT_PINK,
			static::NAME_DEEP_PINK,
			static::NAME_MEDIUM_VIOLET_RED,
			static::NAME_PALE_VIOLET_RED,
			static::NAME_LIGHT_SALMON,
			static::NAME_CORAL,
			static::NAME_TOMATO ,
			static::NAME_ORANGE_RED ,
			static::NAME_DARK_ORANGE,
			static::NAME_ORANGE ,
			static::NAME_GOLD,
			static::NAME_YELLOW ,
			static::NAME_LIGHT_YELLOW,
			static::NAME_LEMON_CHIFFON,
			static::NAME_LIGHT_GOLDENROD_YELLOW,
			static::NAME_PAPAYA_WHIP,
			static::NAME_MOCCASIN,
			static::NAME_PEACH_PUFF ,
			static::NAME_PALE_GOLDENROD ,
			static::NAME_KHAKI,
			static::NAME_DARK_KHAKI ,
			static::NAME_LAVENDER,
			static::NAME_THISTLE,
			static::NAME_PLUM,
			static::NAME_VIOLET ,
			static::NAME_ORCHID ,
			static::NAME_FUCHSIA,
			static::NAME_MAGENTA,
			static::NAME_MEDIUM_ORCHID,
			static::NAME_MEDIUM_PURPLE,
			static::NAME_AMETHYST,
			static::NAME_BLUE_VIOLET,
			static::NAME_DARK_VIOLET,
			static::NAME_DARK_ORCHID,
			static::NAME_DARK_MAGENTA,
			static::NAME_PURPLE ,
			static::NAME_INDIGO ,
			static::NAME_SLATE_BLUE ,
			static::NAME_DARK_SLATE_BLUE,
			static::NAME_MEDIUM_SLATE_BLUE,
			static::NAME_GREEN_YELLOW,
			static::NAME_CHARTREUSE ,
			static::NAME_LAWN_GREEN ,
			static::NAME_LIME,
			static::NAME_LIME_GREEN ,
			static::NAME_PALE_GREEN ,
			static::NAME_LIGHT_GREEN,
			static::NAME_MEDIUM_SPRING_GREEN,
			static::NAME_SPRING_GREEN,
			static::NAME_MEDIUM_SEA_GREEN,
			static::NAME_SEA_GREEN,
			static::NAME_FOREST_GREEN,
			static::NAME_GREEN,
			static::NAME_DARK_GREEN ,
			static::NAME_YELLOW_GREEN,
			static::NAME_OLIVE_DRAB ,
			static::NAME_OLIVE,
			static::NAME_DARK_OLIVE_GREEN,
			static::NAME_MEDIUM_AQUAMARINE,
			static::NAME_DARK_SEA_GREEN ,
			static::NAME_LIGHT_SEA_GREEN,
			static::NAME_DARK_CYAN,
			static::NAME_TEAL,
			static::NAME_AQUA,
			static::NAME_CYAN,
			static::NAME_LIGHT_CYAN ,
			static::NAME_PALE_TURQUOISE ,
			static::NAME_AQUAMARINE ,
			static::NAME_TURQUOISE,
			static::NAME_MEDIUM_TURQUOISE,
			static::NAME_DARK_TURQUOISE ,
			static::NAME_CADET_BLUE ,
			static::NAME_STEEL_BLUE ,
			static::NAME_LIGHT_STEEL_BLUE,
			static::NAME_POWDER_BLUE,
			static::NAME_LIGHT_BLUE ,
			static::NAME_SKY_BLUE,
			static::NAME_LIGHT_SKY_BLUE ,
			static::NAME_DEEP_SKY_BLUE,
			static::NAME_DODGER_BLUE,
			static::NAME_CORNFLOWER_BLUE,
			static::NAME_MEDIUM_SLATE_BLUE,
			static::NAME_ROYAL_BLUE ,
			static::NAME_BLUE,
			static::NAME_MEDIUM_BLUE,
			static::NAME_DARK_BLUE,
			static::NAME_NAVY,
			static::NAME_MIDNIGHT_BLUE,
			static::NAME_CORNSILK,
			static::NAME_BLANCHED_ALMOND,
			static::NAME_BISQUE ,
			static::NAME_NAVAJO_WHITE,
			static::NAME_WHEAT,
			static::NAME_BURLY_WOOD ,
			static::NAME_TAN,
			static::NAME_ROSY_BROWN ,
			static::NAME_SANDY_BROWN,
			static::NAME_GOLDENROD,
			static::NAME_DARK_GOLDENROD ,
			static::NAME_PERU,
			static::NAME_CHOCOLATE,
			static::NAME_SADDLE_BROWN,
			static::NAME_SIENNA ,
			static::NAME_BROWN,
			static::NAME_MAROON ,
			static::NAME_WHITE,
			static::NAME_SNOW,
			static::NAME_HONEYDEW,
			static::NAME_MINT_CREAM ,
			static::NAME_AZURE,
			static::NAME_ALICE_BLUE ,
			static::NAME_GHOST_WHITE,
			static::NAME_WHITE_SMOKE,
			static::NAME_SEASHELL,
			static::NAME_BEIGE,
			static::NAME_OLD_LACE,
			static::NAME_FLORAL_WHITE,
			static::NAME_IVORY,
			static::NAME_ANTIQUE_WHITE,
			static::NAME_LINEN,
			static::NAME_LAVENDER_BLUSH ,
			static::NAME_MISTY_ROSE ,
			static::NAME_GAINSBORO,
			static::NAME_LIGHT_GREY ,
			static::NAME_SILVER ,
			static::NAME_DARK_GRAY,
			static::NAME_GRAY,
			static::NAME_DIM_GRAY,
			static::NAME_LIGHT_SLATE_GRAY,
			static::NAME_SLATE_GRAY ,
			static::NAME_DARK_SLATE_GRAY,
			static::NAME_BLACK,
		];
	}
846690
public static function renderToCommandLine(common_report_Report $report, $useColor = self::AUTOSENSE, $intend = 0) {
        switch ($report->getType()) {
            case common_report_Report::TYPE_SUCCESS:
                $color = '0;32'; // green
                break;
            
            case common_report_Report::TYPE_WARNING:
                $color = '1;33'; // yellow
                break;
            
            case common_report_Report::TYPE_ERROR:
                $color = '1;31'; // red
                break;
            
            default:
                $color = '0;37'; // light grey
        }
        if ($useColor == self::AUTOSENSE) {
            $useColor = getenv('TAO_CONSOLE') !== 'nocolor' && !SystemHelper::isWindows();
        }
            
        $output =  ($useColor ? "\033[".$color.'m' : '')
            .($intend > 0 ? str_repeat(' ', $intend) : '')
            .$report->getMessage()
            .($useColor ? "\033[0m" : '').PHP_EOL;
        foreach ($report as $child) {
            $output .= self::renderToCommandline($child, $useColor, $intend + 2);
        }
        return $output;
    }
1298421
public function chartLargestFamilies(
        string $color_from = null,
        string $color_to = null,
        int $total = 10
    ): string {
        return (new ChartFamilyLargest($this->tree))
            ->chartLargestFamilies($color_from, $color_to, $total);
    }
847379
public static Color fromRGB(final int red, final int green, final int blue) {
        if (ColorHelper.helper == null)
            ColorHelper.helper = new ColorHelper();
        return ColorHelper.helper.getFromRGB(red, green, blue);
    }
1205961
public static String toColorShorthand(String red, String green, String blue) {
		return shorthandHex(toColor(red, green, blue));
	}
1366492
public int getColorNumber(RtfColor color) {
        int colorIndex = -1;
        for(int i = 0; i < colorList.size(); i++) {
            if(colorList.get(i).equals(color)) {
                colorIndex = i;
            }
        }
        if(colorIndex == -1) {
            colorIndex = colorList.size();
            colorList.add(color);
        }
        return colorIndex;
    }