Пример #1
0
function scoringPlay($score, $teams)
{
    $width = 980;
    $height = 100;
    $play = new Imagick();
    $play->newPseudoImage($width, $height, 'xc:none');
    placeImage($play, array('w' => 94, 'h' => 94, 'x' => 3, 'y' => 3, 'path' => $teams[$score["vh"] . '']['logo']));
    $goal = explode(',', $score['name']);
    $a1 = explode(',', $score['assist1']);
    $a2 = explode(',', $score['assist2']);
    $goalString = checkDBForName(ucwords(strtolower($goal[0])));
    if (strlen($score['seasong'])) {
        $goalString .= ' (' . $score['seasong'] . ')';
    }
    plainText($play, array('text' => $goalString, 'w' => 500, 'h' => 45, 'x' => 125, 'y' => 10, 'gravity' => 'west', 'font' => 'fontN', 'color' => 'white'));
    $assistString = 'Unassisted';
    if ($a1[0]) {
        $assistString = checkDBForName(ucwords(strtolower($a1[0])));
        if (strlen($score['seasona1'])) {
            $assistString .= ' (' . $score['seasona1'] . ')';
        }
    }
    if ($a2[0]) {
        $assistString .= ', ' . checkDBForName(ucwords(strtolower($a2[0])));
        if (strlen($score['seasona2'])) {
            $assistString .= ' (' . $score['seasona2'] . ')';
        }
    }
    plainText($play, array('text' => $assistString, 'w' => 575, 'h' => 40, 'x' => 125, 'y' => 55, 'gravity' => 'west', 'font' => 'fontN', 'color' => 'white'));
    $time = $score['time'] . '';
    if ($time[0] == '0') {
        $time = substr($time, 1, strlen($time));
    }
    //$time = str_replace('0','',$time);
    plainText($play, array('text' => $time, 'w' => 150, 'h' => 50, 'x' => 825, 'y' => 25, 'gravity' => 'center', 'font' => 'fontN', 'color' => 'white'));
    $strength = $score['type'] != 'EV' ? $score['type'] : '';
    plainText($play, array('text' => $strength, 'w' => 80, 'h' => 50, 'x' => 725, 'y' => 25, 'gravity' => 'center', 'font' => 'fontN', 'color' => 'white'));
    return $play;
}
Пример #2
0
if ($xml->geo->slantRectangle) {
    foreach ($xml->geo->slantRectangle as $slantRectangle) {
        $sR = dbFetch($id, $slantRectangle);
        slantRectangle($canvas, $sR["x"], $sR["y"], $sR["w"], $sR["h"], $sR["color"]);
    }
}
if ($xml->overlay->shadowText) {
    foreach ($xml->overlay->shadowText as $text) {
        $t = dbFetch($id, $text);
        shadowedText($canvas, $t["x"], $t["y"], $t["w"], $t["h"], $t["text"], $t["gravity"], $t["font"], $t["color"]);
    }
}
if ($xml->overlay->plainText) {
    foreach ($xml->overlay->plainText as $text) {
        $t = dbFetch($id, $text);
        plainText($canvas, $t["x"], $t["y"], $t["w"], $t["h"], $t["text"], $t["gravity"], $t["font"], $t["color"], true);
    }
}
if ($xml->overlay->placeImage) {
    foreach ($xml->overlay->placeImage as $image) {
        $l = dbFetch($id, $image);
        //print_r($l);
        placeImage($canvas, $l["x"], $l["y"], $l["w"], $l["h"], $l["path"]);
    }
}
header("Content-Type: image/png");
echo $canvas;
$thumb = $canvas->clone();
$thumb->cropImage(1440, 1080, 0, 0);
$thumb->resizeImage(53, 40, Imagick::FILTER_TRIANGLE, 1);
$thumb->writeImage('thumbs/' . $titleRow["filename"] . '.png');
Пример #3
0
    }
    $i = 2;
    for (; strlen($slabel[$i]) > 0; $i++) {
    }
    $boxW = 880 / ($i - 2);
    $totalwidths = 0;
    for ($j = 2; $j < $i; $j++) {
        $totalwidths += getTextWidth($boxW, 80, $row[$j + 8], "fontN");
    }
    //echo $totalwidths;
    $spacing = (880 - $totalwidths) / ($i - 2);
    //plainText($canvas,50,50,300,50,$i-2 . ", $boxW, $totalwidths, $spacing ","left","fontN","white");
    $xpos = 650;
    for ($j = 2; $j < $i; $j++) {
        $thisWidth = getTextWidth($boxW, 80, $row[$j + 8], "fontN");
        $xpos -= ($boxW - $thisWidth) / 2;
        plainText($canvas, $xpos, 915, $boxW, 40, $slabel[$j], "center", "fontN", "white");
        plainText($canvas, $xpos, 955, $boxW, 80, $row[$j + 8], "center", "fontN", "white");
        $xpos += ($boxW - $thisWidth) / 2 + $thisWidth + $spacing;
    }
}
dbquery("REPLACE INTO cache SET `key` = '{$key}', `hash` = '{$hash}';");
$filename = $row["num"] . $row["first"] . $row["last"];
$canvas->setImageDepth(8);
$canvas->writeImage('out/' . $filename . '.png');
$thumb = $canvas->clone();
$thumb->cropImage(318, 239, 398, 794);
$thumb->resizeImage(53, 40, Imagick::FILTER_TRIANGLE, 1);
$thumb->writeImage('thumbs/' . $filename . '.png');
header("Content-Type: image/png");
echo $canvas;
Пример #4
0
    $i = 2;
    for (; strlen($slabel[$i]) > 0; $i++) {
    }
    $boxW = $statsBoxWidth / ($i - 2);
    $totalwidths = 0;
    for ($j = 2; $j < $i; $j++) {
        $totalwidths += getTextWidth(array('w' => $boxW, 'h' => 80, 'text' => $row[$j + 8], 'font' => "fontN"));
    }
    //echo $totalwidths;
    $spacing = ($statsBoxWidth - $totalwidths) / ($i - 2);
    //plainText($canvas,50,50,300,50,$i-2 . ", $boxW, $totalwidths, $spacing ","left","fontN","white");
    for ($j = 2; $j < $i; $j++) {
        $thisWidth = getTextWidth(array('w' => $boxW, 'h' => 80, 'text' => $row[$j + 8], 'font' => "fontN"));
        $statsBoxX -= ($boxW - $thisWidth) / 2;
        plainText($blackBox, array('x' => $statsBoxX, 'y' => 55, 'w' => $boxW, 'h' => 40, 'text' => $slabel[$j], 'gravity' => "center", 'font' => "fontN", 'color' => "white"));
        plainText($blackBox, array('x' => $statsBoxX, 'y' => 95, 'w' => $boxW, 'h' => 80, 'text' => $row[$j + 8], 'gravity' => "center", 'font' => "fontN", 'color' => "white"));
        $statsBoxX += ($boxW - $thisWidth) / 2 + $thisWidth + $spacing;
    }
}
/*$filename = $row["num"] . $row["first"] . $row["last"];

$mainBar->setImageDepth(8);
$mainBar->writeImage(realpath('anim') . '/' . $filename . '_bar.png');

$blackBox->setImageDepth(8);
$blackBox->writeImage(realpath('anim') . '/' . $filename . '_box.png');

$logoBox->setImageDepth(8);
$logoBox->writeImage(realpath('anim') . '/' . $filename . '_logo.png');

echo '<img src="anim/' . $filename . '_bar.png">';
Пример #5
0
include "include.php";
include "imagick_include.php";
$name = $_GET["name"];
$id = $_GET["id"];
$type = $_GET["type"];
$attr = dbFetchAll($id, $name, $type);
//print_r($attr);
$canvas = new Imagick();
$canvas->newImage($attr["w"] + 20, $attr["h"] + 30, "none", "png");
if ($type == "slantRectangle") {
    slantRectangle($canvas, 10, 10, $attr["w"], $attr["h"], $attr["color"]);
} else {
    if ($type == "blackBox") {
        blackBox($canvas, 10, 10, $attr["w"], $attr["h"]);
    } else {
        if ($type == "plainText") {
            plainText($canvas, 10, 10, $attr["w"], $attr["h"], $attr["text"], $attr["gravity"], $attr["font"], $attr["color"]);
        } else {
            if ($type == "shadowText") {
                shadowedText($canvas, 10, 10, $attr["w"], $attr["h"], $attr["text"], $attr["gravity"], $attr["font"], $attr["color"]);
            } else {
                if ($type == "placeImage") {
                    placeImage($canvas, 10, 10, $attr["w"], $attr["h"], $attr["path"]);
                }
            }
        }
    }
}
header("Content-Type: image/png");
echo $canvas;