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


PHP Artists::getArtistByName方法代码示例

本文整理汇总了PHP中Artists::getArtistByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Artists::getArtistByName方法的具体用法?PHP Artists::getArtistByName怎么用?PHP Artists::getArtistByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Artists的用法示例。


在下文中一共展示了Artists::getArtistByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 /**
  * Output the image with the logos of each artist
  */
 public function show()
 {
     if (count($this->artists) == 0) {
         throw new Exception("Missing some informations (artists).");
     }
     $totalHeight = array(self::$marginTop, self::$marginTop);
     $listImageRessources = array(array(), array());
     $forcedWidth = self::$width / 2 - self::$seperation / 2;
     foreach ($this->artists as $name) {
         if (count($listImageRessources[0]) + count($listImageRessources[1]) == $this->nbArtists) {
             break;
         }
         $a = Artists::getArtistByName($name);
         if ($a != null) {
             $image = Artists::imageFromArtist($a);
             if (isset($image)) {
                 $i = $totalHeight[1] < $totalHeight[0] ? 1 : 0;
                 $x = imagesx($image);
                 $y = imagesy($image);
                 $newHeight = floor($y * $forcedWidth / $x);
                 $totalHeight[$i] += $newHeight + self::$seperation;
                 array_push($listImageRessources[$i], $image);
             }
         }
     }
     $container = imagecreatetruecolor(self::$width, max($totalHeight));
     //Some colors needed
     $colWhite = imagecolorallocate($container, 255, 255, 255);
     //Background color
     imagefilledrectangle($container, 0, 0, self::$width, max($totalHeight), $colWhite);
     $currentHeight = array(self::$marginTop, self::$marginTop);
     for ($l = 0; $l < count($listImageRessources); $l++) {
         $list = $listImageRessources[$l];
         foreach ($list as $image) {
             $x = imagesx($image);
             $y = imagesy($image);
             $newHeight = floor($y * $forcedWidth / $x);
             $resized = imagecreatetruecolor($forcedWidth, $newHeight);
             imagecopyresampled($resized, $image, 0, 0, 0, 0, $forcedWidth, $newHeight, $x, $y);
             imagecopymerge($container, $resized, ($forcedWidth + self::$seperation) * $l, $currentHeight[$l], 0, 0, $forcedWidth, $newHeight, 100);
             //echo $currentHeight[$l] . "-";
             $currentHeight[$l] += $newHeight + self::$seperation;
         }
     }
     ImageUtil::applyFilter($container, $this->color);
     imagepng($container);
 }
开发者ID:h3xstream,项目名称:bandlogos,代码行数:50,代码来源:TwoColumnsLayout.class.php

示例2: show

 /**
  * Output the image with the logos of each artist
  */
 public function show()
 {
     if (count($this->artists) == 0) {
         throw new Exception("Missing some informations (artists).");
     }
     $totalHeight = 0;
     $listImageRessources = array();
     foreach ($this->artists as $name) {
         if (count($listImageRessources) == $this->nbArtists) {
             break;
         }
         $a = Artists::getArtistByName($name);
         if ($a != null) {
             $image = Artists::imageFromArtist($a);
             if (isset($image)) {
                 $totalHeight += imagesy($image) + self::$seperation;
                 array_push($listImageRessources, $image);
             }
         }
     }
     //echo $totalHeight;
     $totalHeight += self::$marginTop;
     $container = imagecreatetruecolor(self::$width, $totalHeight);
     //Some colors needed
     $colWhite = imagecolorallocate($container, 255, 255, 255);
     //Background color
     imagefilledrectangle($container, 0, 0, self::$width, $totalHeight, $colWhite);
     $expectWidth = self::$width - 2 * self::$marginSide;
     $currentHeight = self::$marginTop;
     foreach ($listImageRessources as $image) {
         $widthImg = imagesx($image);
         //echo $this->width."-2 * ".self::$marginSide);
         //echo $widthImg."--".$expectWidth."<br/>";
         imagecopymerge($container, $image, self::$marginSide + ($widthImg < $expectWidth ? ($expectWidth - $widthImg) * 0.5 : 0), $currentHeight, 0, 0, imagesx($image), imagesy($image), 100);
         $currentHeight += imagesy($image) + self::$seperation;
     }
     ImageUtil::applyFilter($container, $this->color);
     imagepng($container);
 }
开发者ID:hazrpg,项目名称:bandlogos,代码行数:42,代码来源:OneColumnLayout.class.php


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