本文整理汇总了PHP中ezcGraphColor::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcGraphColor::__toString方法的具体用法?PHP ezcGraphColor::__toString怎么用?PHP ezcGraphColor::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcGraphColor
的用法示例。
在下文中一共展示了ezcGraphColor::__toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGradientUrl
/**
* Return gradient URL
*
* Creates the definitions needed for a gradient, if a proper gradient does
* not yet exists. In each case a URL referencing the correct gradient will
* be returned.
*
* @param ezcGraphColor $color Gradient
* @return string Gradient URL
*/
protected function getGradientUrl(ezcGraphColor $color)
{
switch (true) {
case $color instanceof ezcGraphLinearGradient:
if (!in_array($color->__toString(), $this->drawnGradients, true)) {
$gradient = $this->dom->createElement('linearGradient');
$gradient->setAttribute('id', 'Definition_' . $color->__toString());
$this->defs->appendChild($gradient);
// Start of linear gradient
$stop = $this->dom->createElement('stop');
$stop->setAttribute('offset', 0);
$stop->setAttribute('style', sprintf('stop-color: #%02x%02x%02x; stop-opacity: %.2F;', $color->startColor->red, $color->startColor->green, $color->startColor->blue, 1 - $color->startColor->alpha / 255));
$gradient->appendChild($stop);
// End of linear gradient
$stop = $this->dom->createElement('stop');
$stop->setAttribute('offset', 1);
$stop->setAttribute('style', sprintf('stop-color: #%02x%02x%02x; stop-opacity: %.2F;', $color->endColor->red, $color->endColor->green, $color->endColor->blue, 1 - $color->endColor->alpha / 255));
$gradient->appendChild($stop);
$gradient = $this->dom->createElement('linearGradient');
$gradient->setAttribute('id', $color->__toString());
$gradient->setAttribute('x1', sprintf('%.4F', $color->startPoint->x));
$gradient->setAttribute('y1', sprintf('%.4F', $color->startPoint->y));
$gradient->setAttribute('x2', sprintf('%.4F', $color->endPoint->x));
$gradient->setAttribute('y2', sprintf('%.4F', $color->endPoint->y));
$gradient->setAttribute('gradientUnits', 'userSpaceOnUse');
$gradient->setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#Definition_' . $color->__toString());
$this->defs->appendChild($gradient);
$this->drawnGradients[] = $color->__toString();
}
return sprintf('url(#%s)', $color->__toString());
case $color instanceof ezcGraphRadialGradient:
if (!in_array($color->__toString(), $this->drawnGradients, true)) {
$gradient = $this->dom->createElement('linearGradient');
$gradient->setAttribute('id', 'Definition_' . $color->__toString());
$this->defs->appendChild($gradient);
// Start of linear gradient
$stop = $this->dom->createElement('stop');
$stop->setAttribute('offset', 0);
$stop->setAttribute('style', sprintf('stop-color: #%02x%02x%02x; stop-opacity: %.2F;', $color->startColor->red, $color->startColor->green, $color->startColor->blue, 1 - $color->startColor->alpha / 255));
$gradient->appendChild($stop);
// End of linear gradient
$stop = $this->dom->createElement('stop');
$stop->setAttribute('offset', 1);
$stop->setAttribute('style', sprintf('stop-color: #%02x%02x%02x; stop-opacity: %.2F;', $color->endColor->red, $color->endColor->green, $color->endColor->blue, 1 - $color->endColor->alpha / 255));
$gradient->appendChild($stop);
$gradient = $this->dom->createElement('radialGradient');
$gradient->setAttribute('id', $color->__toString());
$gradient->setAttribute('cx', sprintf('%.4F', $color->center->x));
$gradient->setAttribute('cy', sprintf('%.4F', $color->center->y));
$gradient->setAttribute('fx', sprintf('%.4F', $color->center->x));
$gradient->setAttribute('fy', sprintf('%.4F', $color->center->y));
$gradient->setAttribute('r', max($color->height, $color->width));
$gradient->setAttribute('gradientUnits', 'userSpaceOnUse');
$gradient->setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#Definition_' . $color->__toString());
$this->defs->appendChild($gradient);
$this->drawnGradients[] = $color->__toString();
}
return sprintf('url(#%s)', $color->__toString());
default:
return false;
}
}