Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # error_reporting(E_ALL);
- // While I coded this Drax quote thing, I doubt it's original and I'm sure others exist
- // But this one is mine.
- ## Alex Glanville 2015 - March 21st - http://comicidiot.com/strax.jpg
- ## Inspired by a TI-84+CSE program my friend Daniel, tifreak, created
- // Copied this fucntion from
- // http://www.johnciacia.com/2010/01/04/using-php-and-gd-to-add-border-to-text/
- function imagettfstroketext(&$image, $size, $angle, $x, $y, &$textcolor, &$strokecolor, $fontfile, $text, $px) {
- for($c1 = ($x-abs($px)); $c1 <= ($x+abs($px)); $c1++)
- for($c2 = ($y-abs($px)); $c2 <= ($y+abs($px)); $c2++)
- $bg = imagettftext($image, $size, $angle, $c1, $c2, $strokecolor, $fontfile, $text);
- return imagettftext($image, $size, $angle, $x, $y, $textcolor, $fontfile, $text);
- }
- // We'll use this for a section below where we need to determine if the first letter is a vowel
- $vowel = "/^[aeiou]/";
- $font = "res/monof55.ttf";
- $imgloc = "res/strax_bg.jpg";
- $fontsize = 12;
- $StraxIMG = imagecreatefromjpeg($imgloc);
- // Set this early so we don't get an error later on
- $six = null;
- // This is part 2 because it's effecively the second part of the string.
- // We need to get this first so we can either display "a" or "an" based
- // on the first letter of the selected phrase.
- ## Begin part 2
- $part = array(
- "full-frontal",
- "pincer",
- "surprise",
- "brutally excessive",
- "suicide",
- "multi-pronged",
- "glorious",
- "acid-heavy",
- "immediate",
- "violent",
- "traditional Sontaran",
- "devasting");
- $select = rand(0,(count($part)-1));
- $two = $part[$select];
- ## Begin Part 1
- if(preg_match($vowel, $two)) {
- $one = "an";
- } else {
- $one = "a";
- }
- ## Begin Part 3
- $part = array(
- "assault",
- "attack",
- "bombardment",
- "offensive",
- "barrage",
- "charge",
- "strike",
- "operation",
- "manoeuvre");
- $select = rand(0,(count($part)-1));
- $three = $part[$select];
- ## Begin Part 4
- $four = "with";
- ## Begin Part 5
- $part = array(
- "laser",
- "berserker",
- "acid",
- "armoured attack",
- "proton",
- "three kinds of",
- "atomic",
- "toxic",
- "explosive",
- "red-hot",
- "thermal",
- "automated fire",
- "cluster",
- "enhanced germ",
- "energy-drink-fueled");
- $select = rand(0,(count($part)-1));
- $five = $part[$select];
- ## Begin Part 6
- // Since acid appears in both $five and $six here, let's set up a check so
- // the phrase "acid acid" doesn't appear.
- $part = array(
- "bees",
- "chainsaws",
- "marmots",
- "acid",
- "monkeys",
- "mines",
- "bombs",
- "snakes",
- "spiders",
- "knives",
- "rockets",
- "sharks",
- "owls",
- "repurposed cybermats",
- "cannons",
- "alligators");
- $select = rand(0,(count($part)-1));
- $six = $part[$select];
- while($six == $five) {
- $select = rand(0,(count($part)-1));
- $six = $part[$select];
- }
- # if("$five $six" == "acid acid") {$five = "highly acidic";}
- ## Begin Part 7
- $seven = "and";
- ## Begin Part 8
- $part = array(
- "robots",
- "ninjas",
- "grenades",
- "a dolphin full of napalm",
- "acid",
- "dynamite",
- "xenomorphs",
- "lots and lots of C4",
- "tactical nukes",
- "MacGyver",
- "bio-weapons",
- "rocket launchers",
- "an elephant",
- "a memory worm for afterwards",
- "this pencil");
- $select = rand(0,(count($part)-1));
- $eight = $part[$select];
- $string1 = "Might I suggest $one $two";
- $string2 = "$three $four $five $six";
- $string3 = "$seven $eight?";
- ## This is the longest the string can be. Uncomment the line below to make sure your image is long enough
- ## This is kinda of not required since I abandonded the single string idea, but I'll leave it in for posterity.
- ## $string = "An traditional Sontaran bombardment with energy-drink-fuelled reporposed cybermats and a memory worm for afterwards";
- ## Create the image!
- list($width, $height, $type, $attr) = getimagesize($imgloc);
- $white = imagecolorallocate($StraxIMG, 255, 255, 255);
- $black = imagecolorallocate($StraxIMG, 0, 0, 0);
- #imagestring($StraxIMG, $font, 0, 0, $string, $color);
- imagettfstroketext($StraxIMG, $fontsize, 0, 80, 20, $white, $black, $font, $string1, 1);
- imagettfstroketext($StraxIMG, $fontsize, 0, 100, 40, $white, $black, $font, $string2, 1);
- imagettfstroketext($StraxIMG, $fontsize, 0, 120, 60, $white, $black, $font, $string3, 1);
- # imagettftext($StraxIMG, 10, 0, 80, 40, $black, $font,$string);
- // Set the content type header - in this case image/jpeg
- header('Content-Type: image/jpeg');
- // Output the image
- imagejpeg($StraxIMG);
- // Free up memory
- imagedestroy($StraxIMG);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement