本文整理汇总了PHP中Color::Rgb12ToString方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::Rgb12ToString方法的具体用法?PHP Color::Rgb12ToString怎么用?PHP Color::Rgb12ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color::Rgb12ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: contrastColors
static function contrastColors($string, $background)
{
$background = Color::StringToRgb24($background);
return preg_replace_callback('/(?<!\\$)((?:\\$\\$)*)(\\$[0-9a-f][^\\$]{0,2})/iu', function ($matches) use($background) {
$color = Color::StringToRgb24($matches[2]);
$color = Color::Contrast($color, $background);
$color = Color::Rgb24ToRgb12($color);
$color = Color::Rgb12ToString($color);
return $matches[1] . '$' . $color;
}, $string);
}
示例2: __toString
function __toString()
{
if ($this->style) {
$styles = '';
if ($this->style & StyleParser::COLORED) {
if (StyleParser::getBackground() !== null && StyleParser::getContrast() !== null) {
$color = Color::Rgb12ToRgb24($this->style & 0xfff);
$color = Color::Contrast($color, StyleParser::getBackground(), StyleParser::getContrast());
$color = Color::Rgb24ToString($color);
} else {
$color = Color::Rgb12ToString($this->style & 0xfff);
}
$styles .= 'color:#' . $color . ';';
}
if ($this->style & StyleParser::ITALIC) {
$styles .= 'font-style:italic;';
}
if ($this->style & StyleParser::BOLD) {
$styles .= 'font-weight:bold;';
}
if ($this->style & StyleParser::SHADOWED) {
$styles .= 'text-shadow:1px 1px 1px rgba(0,0,0,.5);';
}
if ($this->style & StyleParser::CAPITALIZED) {
$this->text = strtoupper($this->text);
}
if ($this->style & StyleParser::WIDE) {
$styles .= 'letter-spacing:.1em;font-size:105%;';
} else {
if ($this->style & StyleParser::NARROW) {
$styles .= 'letter-spacing:-.1em;font-size:95%;';
}
}
return '<span style="' . $styles . '">' . htmlentities($this->text, ENT_QUOTES, 'UTF-8') . '</span>';
} else {
return htmlentities($this->text, ENT_QUOTES, 'UTF-8');
}
}