示例#1
0
 public function drawRarity($canvas, $rarity, $set, $right, $middle, $height, $width, $whiteBorder, $fallback = true)
 {
     $image = null;
     if ($whiteBorder) {
         foreach ($this->setDB->getAbbrevs($set) as $abbrev) {
             list($image, $srcWidth, $srcHeight) = getPNG('images/preEighth/rarity/' . $abbrev . '_' . $rarity . '.png');
             if ($image) {
                 break;
             }
             list($image, $srcWidth, $srcHeight) = getGIF('images/preEighth/rarity/' . $abbrev . '_' . $rarity . '.gif');
             if ($image) {
                 break;
             }
         }
     }
     if (!$image && $fallback) {
         foreach ($this->setDB->getAbbrevs($set) as $abbrev) {
             list($image, $srcWidth, $srcHeight) = getPNG('images/eighth/rarity/' . $abbrev . '_' . $rarity . '.png');
             if ($image) {
                 break;
             }
             list($image, $srcWidth, $srcHeight) = getGIF('images/eighth/rarity/' . $abbrev . '_' . $rarity . '.gif');
             if ($image) {
                 break;
             }
         }
     }
     if ($image) {
         $destWidth = $srcWidth;
         $destHeight = $srcHeight;
         // Resize height, keeping width in proportion.
         if ($srcHeight > $height) {
             $destWidth = $height * ($srcWidth / $srcHeight);
             $destHeight = $height;
         }
         if ($width && $destWidth > $width) {
             $destWidth = $width;
             $destHeight = $width * ($srcHeight / $srcWidth);
         }
         imagecopyresampled($canvas, $image, $right - $destWidth, $middle - $destHeight / 2, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
         imagedestroy($image);
         $rarityLeft = $right - $destWidth - 5;
     } else {
         $rarityLeft = $right;
     }
     return $rarityLeft;
 }
示例#2
0
 public function render()
 {
     global $config;
     echo $this->card . '...';
     $card = $this->card;
     $settings = $this->getSettings();
     $frameDir = $this->getFrameDir($card->title, $card->set, $settings);
     $costColors = Card::getCostColors($card->cost);
     $useMulticolorFrame = strlen($costColors) > 1 && strpos($settings['card.multicolor.frames'], strval(strlen($costColors))) !== false || $card->isDualManaCost() && (strpos($settings['card.multicolor.frames'], strval(strlen($costColors))) !== false || strlen($costColors) == 2);
     switch ($frameDir) {
         case "timeshifted":
             $useMulticolorFrame = false;
             break;
         case "transform-day":
             $useMulticolorFrame = false;
             $pts = explode("|", $card->pt);
             $card->pt = $pts[0];
             break;
         case "transform-night":
             $useMulticolorFrame = false;
             break;
     }
     $canvas = imagecreatetruecolor(736, 1050);
     // Art image.
     if ($card->isEldrazi() && $card->isArtefact()) {
         $this->drawArt($canvas, $card->artFileName, 0, 0, 1050, 736, !$config['art.keep.aspect.ratio']);
     } else {
         $this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);
     }
     echo '.';
     // Background image, border image, and grey title/type image.
     $borderImage = null;
     $greyTitleAndTypeOverlay = null;
     if ($card->isLand()) {
         // Land frame.
         $landColors = @$this->writer->titleToLandColors[strtolower($card->title)];
         if ($settings['card.multicolor.fetch.land.frames']) {
             switch (strtolower($card->title)) {
                 case 'flooded strand':
                     $landColors = 'WU';
                     break;
                 case 'bloodstained mire':
                     $landColors = 'BR';
                     break;
                 case 'wooded foothills':
                     $landColors = 'RG';
                     break;
                 case 'polluted delta':
                     $landColors = 'UB';
                     break;
                 case 'windswept heath':
                     $landColors = 'GW';
                     break;
                 case 'flood plain':
                     $landColors = 'WU';
                     break;
                 case 'rocky tar pit':
                     $landColors = 'BR';
                     break;
                 case 'mountain valley':
                     $landColors = 'RG';
                     break;
                 case 'bad river':
                     $landColors = 'UB';
                     break;
                 case 'grasslands':
                     $landColors = 'GW';
                     break;
             }
         }
         switch (strtolower($card->title)) {
             case 'arid mesa':
                 $landColors = 'RW';
                 break;
             case 'marsh flats':
                 $landColors = 'WB';
                 break;
             case 'misty rainforest':
                 $landColors = 'GU';
                 break;
             case 'scalding tarn':
                 $landColors = 'UR';
                 break;
             case 'verdant catacombs':
                 $landColors = 'BG';
                 break;
         }
         if (!$landColors) {
             error('Land color missing for card: ' . $card->title);
         }
         if (strlen($landColors) > 1) {
             $useMulticolorLandFrame = strpos($settings['card.multicolor.land.frames'], strval(strlen($landColors))) !== false;
             if (!$useMulticolorLandFrame) {
                 $landColors = 'A';
             }
         }
         $bgImage = @imagecreatefrompng("images/eighth/{$frameDir}/land/{$landColors}.png");
         if (!$bgImage) {
             error("Background image not found for land color \"{$landColors}\": " . $card->title);
         }
         // Grey title/type image.
         if (strlen($landColors) >= 2 && $settings['card.multicolor.grey.title.and.type']) {
             $greyTitleAndTypeOverlay = @imagecreatefrompng("images/eighth/{$frameDir}/cards/C-overlay.png");
             if (!$greyTitleAndTypeOverlay) {
                 error('Image not found: C-overlay.png');
             }
         }
         // Green title/type image
         if (strtolower($card->title) == 'murmuring bosk') {
             $greyTitleAndTypeOverlay = @imagecreatefrompng("images/eighth/{$frameDir}/cards/G-overlay.png");
             if (!$greyTitleAndTypeOverlay) {
                 error('Image not found: G-overlay.png');
             }
         }
     } else {
         if ($card->isEldrazi() && $card->isArtefact()) {
             $bgImage = @imagecreatefrompng("images/eighth/{$frameDir}/cards/Eldrazi.png");
         } else {
             if ($card->isArtefact()) {
                 $bgImage = @imagecreatefrompng("images/eighth/{$frameDir}/cards/Art.png");
                 if (strpos($settings['card.artifact.color'], strval(strlen($costColors))) !== false) {
                     if (strlen($costColors) >= 2) {
                         $useMulticolorFrame = false;
                         $borderImage = @imagecreatefrompng("images/eighth/{$frameDir}/borders/{$costColors}.png");
                     } else {
                         $useMulticolorFrame = false;
                         $borderImage = @imagecreatefrompng("images/eighth/{$frameDir}/borders/{$card->color}.png");
                     }
                 } else {
                     if (strlen($costColors) >= 2 || $card->color == 'Gld') {
                         $useMulticolorFrame = false;
                         $borderImage = @imagecreatefrompng("images/eighth/{$frameDir}/borders/Gld.png");
                     }
                 }
             } else {
                 if ($useMulticolorFrame) {
                     // Multicolor frame.
                     $bgImage = @imagecreatefrompng("images/eighth/{$frameDir}/cards/{$costColors}.png");
                     if (!$bgImage) {
                         error("Background image not found for color: {$costColors}");
                     }
                     // Grey title/type image.
                     if ($settings['card.multicolor.grey.title.and.type']) {
                         $greyTitleAndTypeOverlay = @imagecreatefrompng("images/eighth/{$frameDir}/cards/C-overlay.png");
                         if (!$greyTitleAndTypeOverlay) {
                             error('Image not found: C-overlay.png');
                         }
                     }
                 } else {
                     // Mono color frame.
                     $bgImage = @imagecreatefrompng("images/eighth/{$frameDir}/cards/" . $card->color . '.png');
                     if (!$bgImage) {
                         error('Background image not found for color "' . $card->color . '" in frame dir: ' . $frameDir);
                     }
                     // Border image.
                     if (strlen($costColors) == 2 && $settings['card.multicolor.dual.borders']) {
                         $borderImage = @imagecreatefrompng("images/eighth/{$frameDir}/borders/{$costColors}.png");
                     }
                 }
             }
         }
     }
     imagecopy($canvas, $bgImage, 0, 0, 0, 0, 736, 1050);
     imagedestroy($bgImage);
     if ($borderImage) {
         imagecopy($canvas, $borderImage, 0, 0, 0, 0, 736, 1050);
         imagedestroy($borderImage);
     }
     if ($greyTitleAndTypeOverlay) {
         imagecopy($canvas, $greyTitleAndTypeOverlay, 0, 0, 0, 0, 736, 1050);
         imagedestroy($greyTitleAndTypeOverlay);
     }
     // Power / toughness.
     if ($card->pt) {
         if ($card->isEldrazi() && $card->isArtefact()) {
             $image = @imagecreatefrompng("images/eighth/{$frameDir}/pt/B.png");
         } else {
             if ($useMulticolorFrame) {
                 $image = @imagecreatefrompng("images/eighth/{$frameDir}/pt/" . substr($costColors, -1, 1) . '.png');
             } else {
                 $image = @imagecreatefrompng("images/eighth/{$frameDir}/pt/" . $card->color . '.png');
             }
         }
         if (!$image) {
             error("Power/toughness image not found for color: {$card->color}");
         }
         imagecopy($canvas, $image, 0, 1050 - 162, 0, 0, 736, 162);
         imagedestroy($image);
         $this->drawText($canvas, $settings['pt.center.x'], $settings['pt.center.y'], $settings['pt.width'], $card->pt, $this->font('pt'));
     }
     //Transform P/T
     if ($frameDir == "transform-day" && isset($pts[1])) {
         $this->drawText($canvas, $settings['pt.transform.center.x'], $settings['pt.transform.center.y'], $settings['pt.transform.width'], $pts[1], $this->font('pt.transform'));
     }
     // Casting cost.
     $costLeft = $this->drawCastingCost($canvas, $card->getCostSymbols(), $card->isDualManaCost() ? $settings['cost.top.dual'] : $settings['cost.top'], $settings['cost.right'], $settings['cost.size'], true);
     echo '.';
     // Set and rarity.
     if (!$card->isBasicLand() || $settings['card.basic.land.set.symbols']) {
         $rarityLeft = $this->drawRarity($canvas, $card->rarity, $card->set, $settings['rarity.right'], $settings['rarity.center.y'], $settings['rarity.height'], $settings['rarity.width'], false);
     } else {
         $rarityLeft = $settings['rarity.right'];
     }
     // Card title.
     $this->drawText($canvas, $settings['title.x'], $settings['title.y'], $costLeft - $settings['title.x'], $card->getDisplayTitle(), $this->font('title'));
     echo '.';
     // Type.
     if ($indicator = $this->getIndicator($card->title)) {
         $image = @imagecreatefrompng("images/symbols/indicators/" . $indicator . '.png');
         imagecopyresampled($canvas, $image, $settings['indicator.x'], $settings['indicator.y'], 0, 0, $settings['indicator.size'], $settings['indicator.size'], 300, 300);
         imagedestroy($image);
         $typex = $settings['type.indicator.x'];
     } else {
         $typex = $frameDir == "transform-night" && $card->isArtefact() ? $settings['type.art.x'] : $settings['type.x'];
     }
     $this->drawText($canvas, $typex, $settings['type.y'], $rarityLeft - $settings['type.x'], $card->type, $this->font('type'));
     // Guild sign.
     if ($card->set == "DIS" || $card->set == "GP" || $card->set == "GPT" || $card->set == "RAV" || $card->set == "RV") {
         if ($guild = $this->getGuild($card->title)) {
             list($image, $width, $height) = getPNG("images/eighth/guilds/{$guild}.png", "Guild image not found for: {$guild}");
             imagecopy($canvas, $image, 373 - $width / 2, 652, 0, 0, $width, $height);
             imagecopy($canvas, $image, 373 - $width / 2, 652, 0, 0, $width, $height);
             // Too much alpha, need to apply twice.
             imagedestroy($image);
         }
     }
     // Phyrexia/Mirran sign.
     if ($card->set == "SOM" || $card->set == "MBS" || $card->set == "NPH") {
         if ($phyrexia = $this->getPhyrexia($card->title)) {
             list($image, $width, $height) = getPNG("images/eighth/phyrexia/{$phyrexia}.png", "Phyrexia/Mirran image not found for: {$phyrexia}");
             imagecopy($canvas, $image, 373 - $width / 2, 652, 0, 0, $width, $height);
             imagecopy($canvas, $image, 373 - $width / 2, 652, 0, 0, $width, $height);
             // Too much alpha, need to apply twice.
             imagedestroy($image);
         }
     }
     // Promo overlay
     if ($card->promo && !$card->isBasicLand()) {
         list($image, $width, $height) = getPNG('images/promo/' . $card->promo . '.png', 'Promo overlay image not found for: ' . $card->promo);
         imagecopy($canvas, $image, 359 - $width / 2, 680, 0, 0, $width, $height);
         imagedestroy($image);
     }
     if ($card->isBasicLand() || $card->isLand() && $card->legal == '' && $card->flavor == '') {
         // Basic land symbol instead of legal text.
         list($image, $width, $height) = getPNG("images/symbols/land/{$landColors}.png", "Basic land image not found for: images/symbols/land/{$landColors}.png");
         imagecopy($canvas, $image, 373 - $width / 2, 660, 0, 0, $width, $height);
         imagedestroy($image);
     } else {
         if ($card->isLand() && strlen($landColors) == 2 && !$card->legal) {
             // Dual land symbol instead of legal text.
             if ($settings['card.dual.land.symbols'] == 1) {
                 // Single hybrid symbol.
                 list($image, $width, $height) = getPNG("images/symbols/land/{$landColors}.png", "Dual symbol image not found for: {$landColors}");
                 imagecopy($canvas, $image, 368 - $width / 2, 680, 0, 0, $width, $height);
                 imagedestroy($image);
             } else {
                 if ($settings['card.dual.land.symbols'] == 2) {
                     // One of each basic symbol.
                     $landColor = substr($landColors, 0, 1);
                     list($image, $width, $height) = getPNG("images/symbols/land/{$landColor}.png", 'Basic land image not found for: ' . $card->title);
                     imagecopy($canvas, $image, 217 - $width / 2, 660, 0, 0, $width, $height);
                     imagedestroy($image);
                     $landColor = substr($landColors, 1, 2);
                     list($image, $width, $height) = getPNG("images/symbols/land/{$landColor}.png", 'Basic land image not found for: ' . $card->title);
                     imagecopy($canvas, $image, 519 - $width / 2, 660, 0, 0, $width, $height);
                     imagedestroy($image);
                 }
             }
         } else {
             // Legal and flavor text.
             if (strlen($card->legal) < 40 && strpos($card->legal, "\n") === FALSE && $card->flavor == '') {
                 $this->drawText($canvas, ($settings['text.right'] + $settings['text.left']) / 2, ($settings['text.top'] + $settings['text.bottom']) / 2, null, $card->legal, $this->font('text', 'centerY:true centerX:true'));
             } else {
                 $heightAdjust = $card->pt ? $settings['text.pt.height.adjust'] : 0;
                 $this->drawLegalAndFlavorText($canvas, $settings['text.top'], $settings['text.left'], $settings['text.bottom'], $settings['text.right'], $card->legal, $card->flavor, $this->font('text'), $heightAdjust);
             }
         }
     }
     // Artist and copyright.
     // The artist color is white if the frame behind it is black.
     $footerColor = '0,0,0';
     if ($card->isLand()) {
         $footerColor = '255,255,255';
     } else {
         if (($costColors == 'B' || $card->color == 'B') && !$card->isArtefact()) {
             $footerColor = '255,255,255';
         } else {
             if ($card->isEldrazi() && $card->isArtefact()) {
                 $footerColor = '255,255,255';
             } else {
                 if ($useMulticolorFrame) {
                     // Only multicolor frames with a bottom left color of black should use a white footer.
                     if (strlen($costColors) <= 2 && substr($costColors, 0, 1) == 'B' || strlen($costColors) >= 3 && substr($costColors, 2, 1) == 'B') {
                         $footerColor = '255,255,255';
                     }
                 }
             }
         }
     }
     if ($card->artist) {
         if ($settings['card.artist.gears']) {
             $artistSymbol = '{gear}';
         } else {
             $artistSymbol = '{brush}';
         }
         $this->drawText($canvas, $settings['artist.x'], $settings['artist.y'], null, $artistSymbol . $card->artist, $this->font('artist', 'color:' . $footerColor));
     }
     if ($card->copyright) {
         $this->drawText($canvas, $settings['copyright.x'], $settings['copyright.y'], null, $card->copyright, $this->font('copyright', 'color:' . $footerColor));
     }
     echo "\n";
     return $canvas;
 }
示例#3
0
	public function render () {
		global $config;

		echo $this->card . '...';
		$card = $this->card;

		$settings = $this->getSettings();
		$costColors = Card::getCostColors($card->cost);
		$canvas = imagecreatetruecolor(736, 1050);

		// Art image.
		$this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);

		echo '.';

		// Background image.
		if ($card->isLand()) {
			// Land frame.
			$landColors = @$this->writer->titleToLandColors[strtolower($card->title)];
			$notBasicFrame = '';
			if ($settings['card.multicolor.fetch.land.frames']) {
				switch (strtolower($card->title)) {
				case 'flooded strand': $landColors = 'WU'; break;
				case 'bloodstained mire': $landColors = 'BR'; break;
				case 'wooded foothills': $landColors = 'RG'; break;
				case 'polluted delta': $landColors = 'UB'; break;
				case 'windswept heath': $landColors = 'GW'; break;
				case 'flood plain': $landColors = 'WU'; break;
				case 'rocky tar pit': $landColors = 'BR'; break;
				case 'mountain valley': $landColors = 'RG'; break;
				case 'bad river': $landColors = 'UB'; break;
				case 'grasslands': $landColors = 'GW'; break;
				}
			}
			if (!$landColors) error('Land color missing for card: ' . $card->title);
			if (strlen($landColors) > 1) {
				$useMulticolorLandFrame = strpos($settings['card.multicolor.land.frames'], strval(strlen($landColors))) !== false;
				if (strlen($landColors) > 2 || !$useMulticolorLandFrame) $landColors = 'A';
			}
			else if(!$card->isBasicLand() && $landColors != 'A' && $landColors != 'C')
				$notBasicFrame = 'C';
			$bgImage = @imagecreatefrompng("images/preEighth/land/$notBasicFrame$landColors.png");
			if (!$bgImage) error("Background image not found for land color \"$notBasicFrame$landColors\": " . $card->title);
		} else {
			// Mono color frame.
			$bgImage = @imagecreatefrompng('images/preEighth/cards/' . $card->color . '.png');
			if (!$bgImage) error('Background image not found for mono color: ' . $card->color);
		}
		imagecopy($canvas, $bgImage, 0, 0, 0, 0, 736, 1050);

		// Power / toughness.
		if ($card->pt) $this->drawText($canvas, $settings['pt.center.x'], $settings['pt.center.y'], $settings['pt.width'], $card->pt, $this->font('pt'));

		// Casting cost.
		$costLeft = $this->drawCastingCost($canvas, $card->getCostSymbols(), $settings['cost.top'], $settings['cost.right'], $settings['cost.size']);

		echo '.';

		// Set and rarity.
		if (!$card->isBasicLand() || $settings['card.basic.land.set.symbols']) {
			$rarityMiddle = $settings['rarity.center.y'];
			if ($card->isLand()) $rarityMiddle += 2; // Rarity on pre8th lands is slightly lower.
			$rarityLeft = $this->drawRarity($canvas, $card->rarity, $card->set, $settings['rarity.right'], $rarityMiddle, $settings['rarity.height'], $settings['rarity.width'], true, $settings['card.rarity.fallback']);
		} else
			$rarityLeft = $settings['rarity.right'];

		// Tombstone sign.
		if ($settings['card.tombstone']) {
			if (strpos($card->legal, 'Flashback') !=false || strpos($card->type, 'Incarnation') !=false || $card->title == 'Riftstone Portal' || $card->title == 'Ichorid') {
				list($image, $width, $height) = getPNG('images/preEighth/tombstone.png', 'Tombstone image not found.');
				imagecopy($canvas, $image, $settings["tombstone.left"], $settings["tombstone.top"], 0, 0, $width, $height);
			}
		}

		// Card title.
		$this->drawText($canvas, $settings['title.x'], $settings['title.y'], $costLeft - $settings['title.x'], $card->getDisplayTitle(false), $this->font('title'));

		echo '.';

		// Type.
		$typeBaseline = $settings['type.y'];
		if ($card->isLand()) $typeBaseline += 2; // Type on pre8th lands is slightly lower.
		$this->drawText($canvas, $settings['type.x'], $typeBaseline, $rarityLeft - $settings['type.x'], $card->type, $this->font('type'));

		if ($card->isBasicLand()) {
			// Basic land symbol instead of legal text.
			list($image, $width, $height) = getPNG("images/symbols/land/$landColors.png", "Basic land image not found for: images/symbols/land/$landColors.png");
			imagecopy($canvas, $image, 373 - ($width / 2), 640, 0, 0, $width, $height);
		} else if ($card->isLand() && strlen($landColors) == 2 && !$card->legal) {
			// Dual land symbol instead of legal text.
			if ($settings['card.dual.land.symbols'] == 1) {
				// Single hybrid symbol.
				list($image, $width, $height) = getPNG("images/symbols/land/$landColors.png", "Dual symbol image not found for: $landColors");
				imagecopy($canvas, $image, 368 - ($width / 2), 667, 0, 0, $width, $height);
			} else if ($settings['card.dual.land.symbols'] == 2) {
				// One of each basic symbol.
				$landColor = substr($landColors, 0, 1);
				list($image, $width, $height) = getPNG("images/symbols/land/$landColor.png", 'Basic land image not found for: ' . $card->title);
				imagecopy($canvas, $image, 217 - ($width / 2), 640, 0, 0, $width, $height);

				$landColor = substr($landColors, 1, 2);
				list($image, $width, $height) = getPNG("images/symbols/land/$landColor.png", 'Basic land image not found for: ' . $card->title);
				imagecopy($canvas, $image, 519 - ($width / 2), 640, 0, 0, $width, $height);
			}
		} else {
			// Legal and flavor text.
			$this->drawLegalAndFlavorText($canvas, $settings['text.top'], $settings['text.left'], $settings['text.bottom'], $settings['text.right'], $card->legal, $card->flavor, $this->font('text'));
		}

		// Artist and copyright.
		if ($card->artist) $this->drawText($canvas, $settings['artist.x'], $settings['artist.y'], null, 'Illus. ' . $card->artist, $this->font('artist'));
		if ($card->copyright) {
			$copyrightColor = '255,255,255';
			if ($card->color == 'W') $copyrightColor = '0,0,0';
			$this->drawText($canvas, $settings['copyright.x'], $settings['copyright.y'], null, $card->copyright, $this->font('copyright', 'color:' . $copyrightColor));
		}

		echo "\n";
		return $canvas;
	}
示例#4
0
	public function drawSymbol ($canvas, $top, $left, $height, $symbol, $shadow, $fixedSize = false, $color = '0,0,0') {
		global $config;

		if ($color != '255,255,255') $color = '0,0,0';

		$scale = true;
		$yOffset = 0; //only used when $scale == true
		
		if ($symbol == '*') {
			$symbol = "star_$color";
			$shadow = null;
		}
		if ($symbol == '+') {
			$symbol = "plus_$color";
			$shadow = null;
		}
		if ($symbol == '-') {
			$symbol = "minus_$color";
			$shadow = null;
		}
		if ($symbol == 'brush') {
			$symbol = "brush_$color";
			$shadow = null;
			$scale = false;
			$yOffset = $height/4;
		}
		if ($symbol == 'gear') {
			$symbol = "gear_$color";
			$shadow = null;
			$scale = false;
		}

		// If a dual symbol or always using larger symbols, use a larger symbol.
		if ((!is_numeric($symbol) && strlen($symbol) == 2) || ($config['card.larger.regular.symbols'] && !$fixedSize)) {
			$top -= $height * 0.25 / 2; // Move symbol up half the height increase.
			$height *= 1.25;
		}

		if(preg_match('/(\d|X|Y|Z)(W|U|R|G|B)/i', $symbol, $matches)) {
			list($sliceImage, $srcWidth, $srcHeight) = getPNG("images/symbols/$matches[1]_.png", "Symbol image not found: $matches[1]_");
			switch($matches[2]) {
				case 'W':
				case 'U':
					$prefix = 'G';
					break;
				case 'R':
				case 'G':
					$prefix = 'B';
					break;
				case 'B':
					$prefix = 'U';
					break;
			}
			list($image, $srcWidth, $srcHeight) = getPNG("images/symbols/$prefix$matches[2].png", "Symbol image not found: $prefix$matches[1]");
			imagecopy($image, $sliceImage, 0, 0, 0, 0, $srcWidth, $srcHeight);
		}
		else
			list($image, $srcWidth, $srcHeight) = getPNG("images/symbols/$symbol.png", "Symbol image not found: $symbol");
		$width = $height * ($srcWidth / $srcHeight);
		if ($canvas) {
			if ($shadow) {
				$shadowImage = @imagecreatefrompng('images/symbols/shadow.png');
				if (!$shadowImage) error('Symbol shadow image not found.');
				imagecopyresampled($canvas, $shadowImage, $left - 2, $top + 2, 0, 0, $width + 2, $width + 2, 134, 134);
			}
			if($scale)
				imagecopyresampled($canvas, $image, $left, $top, 0, 0, $width, $height, $srcWidth, $srcHeight);
			else
				imagecopy($canvas, $image, $left, $top+$yOffset, 0, 0, $srcWidth, $srcHeight);
		}
		if ($scale)
			return array($width, $left);
		else
			return array($srcWidth, $left);
	}
示例#5
0
 public function drawSymbol($canvas, $top, $left, $height, $symbol, $shadow, $fixedSize = false, $color = '0,0,0')
 {
     global $config;
     if ($color != '255,255,255') {
         $color = '0,0,0';
     }
     $scale = true;
     $yOffset = 0;
     //only used when $scale == true
     if ($symbol == '*') {
         $symbol = "star_{$color}";
         $shadow = null;
     }
     if ($symbol == '+') {
         $symbol = "plus_{$color}";
         $shadow = null;
     }
     if ($symbol == '-') {
         $symbol = "minus_{$color}";
         $shadow = null;
     }
     if ($symbol == 'brush') {
         $symbol = "brush_{$color}";
         $shadow = null;
         $scale = false;
         $yOffset = $height / 3;
     }
     if ($symbol == 'gear') {
         $symbol = "gear_{$color}";
         $shadow = null;
         $scale = false;
     }
     // If a dual symbol or always using larger symbols, use a larger symbol.
     if (!is_numeric($symbol) && strlen($symbol) == 2 || $config['card.larger.regular.symbols'] && !$fixedSize) {
         $top -= $height * 0.25 / 2;
         // Move symbol up half the height increase.
         $height *= 1.25;
     }
     if (preg_match('/(\\d|X|Y|Z)(W|U|R|G|B)/i', $symbol, $matches)) {
         list($sliceImage, $srcWidth, $srcHeight) = getPNG("images/symbols/{$matches['1']}_.png", "Symbol image not found: {$matches['1']}_");
         switch ($matches[2]) {
             case 'W':
             case 'U':
                 $prefix = 'G';
                 break;
             case 'R':
             case 'G':
                 $prefix = 'B';
                 break;
             case 'B':
                 $prefix = 'U';
                 break;
         }
         list($image, $srcWidth, $srcHeight) = getPNG("images/symbols/{$prefix}{$matches['2']}.png", "Symbol image not found: {$prefix}{$matches['1']}");
         imagecopy($image, $sliceImage, 0, 0, 0, 0, $srcWidth, $srcHeight);
         imagedestroy($sliceImage);
     } else {
         if ($symbol == 'T' && $this instanceof PreEighthRenderer && $config['card.old.tap.symbol']) {
             $symbol .= "_pre";
         }
         list($image, $srcWidth, $srcHeight) = getPNG("images/symbols/{$symbol}.png", "Symbol image not found: {$symbol}");
     }
     $width = $height * ($srcWidth / $srcHeight);
     if ($canvas) {
         if ($shadow) {
             $shadowImage = @imagecreatefrompng('images/symbols/shadow.png');
             if (!$shadowImage) {
                 error('Symbol shadow image not found.');
             }
             imagecopyresampled($canvas, $shadowImage, $left - 2, $top + 2, 0, 0, $width + 2, $width + 2, 134, 134);
             imagedestroy($shadowImage);
         }
         if ($scale) {
             imagecopyresampled($canvas, $image, $left, $top, 0, 0, $width, $height, $srcWidth, $srcHeight);
         } else {
             imagecopy($canvas, $image, $left, $top + $yOffset, 0, 0, $srcWidth, $srcHeight);
         }
         imagedestroy($image);
     }
     if ($scale) {
         return array($width, $left);
     } else {
         return array($srcWidth, $left);
     }
 }