本文整理汇总了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);
}
示例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);
}