當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。