Exemplo n.º 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;
}
Exemplo n.º 2
0
        $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');
$canvas->setImageDepth(8);
$canvas->writeImage('out/' . $titleRow["filename"] . '.png');
Exemplo n.º 3
0
$detailsModifier = 0;
if ($size[0]) {
    $pW = 192;
    $pH = 230;
    $pX = 400;
    $pY = 801;
    if ($size[0] * 1.2 > $size[1]) {
        $pH = $size[1] / ($size[0] / $pW);
        $pY += 230 - $pH;
    }
    placeImage($canvas, $pX, $pY, $pW, $pH, $pPath);
} else {
    $nameModifier = -150;
    $detailsModifier = -220;
}
placeImage($canvas, 1442, 802 - $boxHeightModifier, 76, 76, "teamlogos/" . $teamrow["logo"] . ".png");
shadowedText($canvas, 560 + $nameModifier, 805 - $boxHeightModifier, 535 - $nameModifier - $positionWidthModifier, 70, $row["first"] . " " . $row["last"], "west", "fontN", "white");
shadowedText($canvas, 1100 - $positionWidthModifier, 800 - $boxHeightModifier, 150, 80, $row["num"], "center", "fontN", "white");
shadowedText($canvas, 1210 - $positionWidthModifier, 800 - $boxHeightModifier, 130 + $positionWidthModifier, 80, $row["pos"], "center", "fontN", "white");
shadowedText($canvas, 1300, 800 - $boxHeightModifier, 140, 80, $row["year"], "center", "fontN", "white");
$details = "Hometown: " . $row["hometown"] . "       Ht: " . $row["height"] . "       Wt: " . $row["weight"];
$detailsGravity = "west";
if (!$size[0]) {
    $details = "Hometown: " . $row["hometown"] . "       Height: " . $row["height"] . "       Weight: " . $row["weight"];
    $detailsGravity = "center";
}
plainText($canvas, 630 + $detailsModifier, 884 - $boxHeightModifier, 880 - $detailsModifier, 33, $details, $detailsGravity, "fontN", "white");
if ($stype && $stype != "txt") {
    if ($lastSeason == true) {
        shadowedText($canvas, 410, 995, 172, 30, 'Last Season:', 'center', 'fontN', 'white');
    }
Exemplo n.º 4
0
    $canvas = new Imagick();
    $canvas->newImage(1400, 260, "none", "png");
    $blackBoxCopy = $blackBox->clone();
    $blackBoxCopy->cropImage(1150, $step + 10, 0, 170 - $step);
    $canvas->compositeImage($blackBoxCopy, imagick::COMPOSITE_OVER, 50, 80);
    $canvas->compositeImage($mainBar, imagick::COMPOSITE_OVER, 10, 10);
    $canvas->writeImage(realpath('anim') . $file);
    echo $i . ':<br><img src="anim/' . $file . '"/ ><br>';
    flush();
}
if ($p) {
    $headshot = new Imagick();
    $headshot->newImage(192, 230, "none", "png");
    $p['x'] -= 400;
    $p['y'] -= 801;
    placeImage($headshot, $p);
    $frames3 = 20;
    for ($i = 0; $i < $frames3; $i++) {
        $file = '/' . $row["num"] . $row["first"] . $row["last"] . '_' . sprintf('%03d', $frames1 + $frames2 + $i) . '.png';
        $step = 230 / ($frames3 - 1) * $i;
        $canvas = new Imagick();
        $canvas->newImage(1400, 260, "none", "png");
        $canvas->compositeImage($blackBox, imagick::COMPOSITE_OVER, 50, 80);
        $canvas->compositeImage($mainBar, imagick::COMPOSITE_OVER, 10, 10);
        $headshotCopy = $headshot->clone();
        $headshotCopy->cropImage(192, $step + 1, 0, 0);
        $canvas->compositeImage($headshotCopy, imagick::COMPOSITE_OVER, 60, 230 - $step + 20);
        $canvas->writeImage(realpath('anim') . $file);
        echo $i . ', ' . $step . ':<br><img src="anim/' . $file . '"/ ><br>';
        flush();
    }
Exemplo n.º 5
0
function divingStandings(&$canvas, $geo)
{
    $geo['w'] = 1200;
    $geo['x'] = 360;
    $sort = $geo['sort'];
    $team = $geo['team'];
    $limit = $geo['limit'];
    $offset = $geo['offset'];
    $dir = $geo['sortDirection'];
    $sort = $geo['sort'];
    if ($geo['numericalSort'] == 'true') {
        $sort = '(0 + ' . $sort . ')';
    }
    if ($team == 'ecac') {
        $team = "rpi-mh,dart-mh,yale-mh,union-mh,clark-mh,brown-mh,colgate-mh,quin-mh,stl-mh,prin-mh,cornell-mh,harvard-mh";
        $teamarray = explode(',', $team);
        $finalteamstring = "";
        foreach ($teamarray as $strval) {
            $finalteamstring = $finalteamstring . "`team`='" . trim($strval) . "' OR ";
        }
        $finalteamstring = substr($finalteamstring, 0, -4);
        $sql = "SELECT * FROM `players` WHERE NOT `pos`='G' AND (" . $finalteamstring . ") ORDER BY " . $sort . " " . $dir . " LIMIT " . $offset . ',' . $limit;
    } else {
        if (strpos($team, ',') !== false) {
            $teamarray = explode(',', $team);
            $finalteamstring = "";
            foreach ($teamarray as $strval) {
                $finalteamstring = $finalteamstring . "`team`='" . trim($strval) . "' OR ";
            }
            $finalteamstring = substr($finalteamstring, 0, -4);
            $sql = "SELECT * FROM `players` WHERE NOT `pos`='G' AND (" . $finalteamstring . ") ORDER BY " . $sort . " " . $dir . " LIMIT " . $offset . ',' . $limit;
        } else {
            $sql = "SELECT * FROM players WHERE `team`='" . $team . "' ORDER BY " . $sort . " " . $dir . " LIMIT " . $offset . ',' . $limit;
        }
    }
    $result = dbQuery($sql);
    $players = [];
    while ($row = mysql_fetch_assoc($result)) {
        $players[] = $row;
    }
    $rowHeight = 60;
    $height = count($players) * $rowHeight;
    $yLocation = 1080 - $height - 50;
    $yOffset = $yLocation;
    blackBox($canvas, array('x' => $geo['x'], 'w' => $geo['w'], 'y' => $yLocation - 65, 'h' => $height + 65));
    slantRectangle($canvas, array('x' => $geo['x'] + 200, 'y' => $yLocation - 60, 'w' => 800, 'h' => 50, 'color' => '#333333'));
    shadowText($canvas, array('x' => $geo['x'] + 220, 'y' => $yLocation - 55, 'gravity' => 'center', 'w' => 760, 'h' => 40, 'text' => $geo['roundText'], 'font' => 'fontN', 'color' => 'white'));
    slantRectangle($canvas, array('x' => $geo['x'] - 35, 'y' => $yLocation - 130, 'w' => 1270, 'h' => 70, 'color' => 'red'));
    shadowText($canvas, array('x' => $geo['x'], 'y' => $yLocation - 125, 'gravity' => 'center', 'w' => 1200, 'h' => 60, 'text' => $geo['titleText'], 'font' => 'fontN', 'color' => 'white'));
    shadowText($canvas, array('x' => $geo['x'] + 1030, 'y' => $yLocation - 50, 'gravity' => 'east', 'w' => 150, 'h' => 50, 'text' => $geo['labelText'], 'font' => 'fontN', 'color' => 'white'));
    $place = $offset;
    foreach ($players as $player) {
        $place++;
        $team = array();
        if ($player['stype'] == 'dive') {
            $team = fetchOrg($player['pos']);
        } else {
            $team = fetchTeam($player['team']);
        }
        if ($geo['hideRankColumn'] == 'false') {
            shadowText($canvas, array('x' => $geo['x'], 'y' => $yOffset, 'gravity' => 'east', 'w' => 65, 'h' => $rowHeight, 'text' => $place, 'font' => 'fontN', 'color' => 'white'));
        }
        placeImage($canvas, array('x' => $geo['x'] + 75, 'y' => $yOffset, 'w' => 65, 'h' => $rowHeight, 'path' => $team['logo']));
        shadowText($canvas, array('x' => $geo['x'] + 150, 'y' => $yOffset, 'gravity' => 'west', 'w' => 425, 'h' => $rowHeight, 'text' => $player['first'] . ' ' . $player['last'], 'font' => 'fontN', 'color' => 'white'));
        shadowText($canvas, array('x' => $geo['x'] + 585, 'y' => $yOffset + 4, 'gravity' => 'west', 'w' => 485, 'h' => $rowHeight - 8, 'text' => $team['name'], 'font' => 'fontN', 'color' => 'white'));
        if ($geo['hideLastColumn'] == 'false') {
            shadowText($canvas, array('x' => $geo['x'] + 1080, 'y' => $yOffset, 'gravity' => 'east', 'w' => 100, 'h' => $rowHeight, 'text' => $player[$geo['sort']], 'font' => 'fontN', 'color' => 'white'));
        }
        $yOffset += $rowHeight;
    }
}
Exemplo n.º 6
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;