当前位置: 首页>>代码示例>>PHP>>正文


PHP ezcGraphColor::__toString方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:gbleydon,项目名称:mahara-survey,代码行数:72,代码来源:svg.php


注:本文中的ezcGraphColor::__toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。