//Color of background; default darker bg2 $img_ol = isset($_GET['ol']) && strlen($_GET['ol']) == 6 && ctype_xdigit($_GET['ol']) ? str_split($_GET['ol'], 2) : array("00", "00", "00"); //Color of outlines; default black $img_w = isset($_GET['w']) && is_numeric($_GET['w']) ? $_GET['w'] : 200; //Width of HP bar; default 200 $img_h = isset($_GET['h']) && is_numeric($_GET['h']) ? $_GET['h'] : 40; //Height of HP bar; default 40 $hp_cur = isset($_GET['chp']) && is_numeric($_GET['chp']) ? $_GET['chp'] : 100; //Current HP; default 100 $hp_max = isset($_GET['mhp']) && is_numeric($_GET['mhp']) ? $_GET['mhp'] : 100; //Max HP; default 100 $img_hp = $img_w / $hp_max * $hp_cur; //Create both halves of the bar. $my_img = imagecreatetruecolor($img_w, $img_h); image_gradientrect($my_img, 0, 0, $img_w, $img_h, $img_c, $img_c2); image_gradientrect($my_img, $img_hp, 0, $img_w, $img_h, $img_bg, $img_bg2); //Border between "current" and "max" portions of HP bar imagesetthickness($my_img, 2); $line_color = imagecolorallocate($my_img, hexdec($img_ol[0]), hexdec($img_ol[1]), hexdec($img_ol[2])); imageline($my_img, $img_hp, 1, $img_hp, $img_h, $line_color); //Black borders ERRYWHERE imageline($my_img, 0, 1, $img_w, 1, $line_color); imageline($my_img, 0, $img_h - 1, $img_w, $img_h - 1, $line_color); imageline($my_img, 1, 0, 1, $img_h, $line_color); imageline($my_img, $img_w - 1, 0, $img_w - 1, $img_h, $line_color); //Setting up for text if (isset($_GET['text'])) { $font_color = imagecolorallocate($my_img, 255, 255, 255); $stroke_color = imagecolorallocate($my_img, 0, 0, 0); imagettfstroketext($my_img, 14, 0, 10, 27, $font_color, $stroke_color, "fonts/arial.ttf", $hp_cur . " / " . $hp_max, 2); }
$s = array(hexdec(substr($start, 0, 2)), hexdec(substr($start, 2, 2)), hexdec(substr($start, 4, 2))); $e = array(hexdec(substr($end, 0, 2)), hexdec(substr($end, 2, 2)), hexdec(substr($end, 4, 2))); $steps = $y1 - $y; for ($i = 0; $i < $steps; $i++) { $r = $s[0] - ($s[0] - $e[0]) / $steps * $i; $g = $s[1] - ($s[1] - $e[1]) / $steps * $i; $b = $s[2] - ($s[2] - $e[2]) / $steps * $i; $color = imagecolorallocate($img, $r, $g, $b); imagefilledrectangle($img, $x, $y + $i, $x1, $y + $i + 1, $color); } return true; } $im = imagecreate($_GET['width'], $_GET['height']); $bg = imagecolorallocate($im, 150, 150, 150); $black = imagecolorallocate($im, 0, 0, 0); image_gradientrect($im, 0, 0, $_GET['width'], $_GET['height'], 'FF0000', '0000FF'); for ($i = 0; $i <= $_GET['width']; $i += 100) { imageline($im, $i - 1, 0, $i - 1, $_GET['height'], $black); imageline($im, $i, 0, $i, $_GET['height'], $black); } for ($i = 0; $i <= $_GET['height']; $i += 100) { imageline($im, 0, $i - 1, $_GET['width'], $i - 1, $black); imageline($im, 0, $i, $_GET['width'], $i, $black); } for ($y = 0; $y <= $_GET['height']; $y += 100) { for ($x = 0; $x <= $_GET['width']; $x += 100) { $i = $y / 100; $j = $x / 100; imagestring($im, 3, $x + 6, $y + 2, "{$i}, {$j}", $textcolor); } }
$e = array(hexdec(substr($end, 0, 2)), hexdec(substr($end, 2, 2)), hexdec(substr($end, 4, 2))); $steps = $y1 - $y; for ($i = 0; $i < $steps; $i++) { $r = $s[0] - ($s[0] - $e[0]) / $steps * $i; $g = $s[1] - ($s[1] - $e[1]) / $steps * $i; $b = $s[2] - ($s[2] - $e[2]) / $steps * $i; $color = imagecolorallocate($img, $r, $g, $b); imagefilledrectangle($img, $x, $y + $i, $x1, $y + $i + 1, $color); } return true; } $imgWidth = 1920; $imgHeight = 1080 + floor($argv[1] * 20); $img = imagecreatetruecolor($imgWidth, $imgHeight); image_gradientrect($img, 0, 0, $imgWidth, floor($imgHeight * 0.5), $pal['color5'], $pal['color4']); image_gradientrect($img, 0, ceil($imgHeight * 0.5), $imgWidth, $imgHeight, $pal['color4'], $pal['color3']); $water_pattern = imagecreatefrompng('assets/botb_bg.png'); imagesettile($img, $water_pattern); imagefilledrectangle($img, 0, 0, $imgWidth, $imgHeight, IMG_COLOR_TILED); imagedestroy($water_pattern); imagepng($img, 'assets/background.png'); imagedestroy($img); # create BotB logo $text = 'battleofthebits.org'; $font = './arial-black.ttf'; $size = 160; $spacing = -20; function create_color($hex, $img) { $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2));