Skip to content

Instantly share code, notes, and snippets.

@powder96
Created December 2, 2012 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save powder96/4189875 to your computer and use it in GitHub Desktop.
Save powder96/4189875 to your computer and use it in GitHub Desktop.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
<?php
// 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
$width = 40; // symbols
$height = 25; // symbols
$borderWidth = 2; // symbols
$bgColor = array( 65, 65, 230);
$fgColor = array(165, 165, 255);
$fontGd = 1;
$fontLineHeightDelta = 3; // px
$zoom = 2;
$symbolWidth = imageFontWidth($fontGd);
$symbolHeight = imageFontHeight($fontGd) - $fontLineHeightDelta;
$imageGd = imageCreate(($width + $borderWidth * 2) * $symbolWidth, ($height + $borderWidth * 2) * $symbolHeight);
$bgColorGd = imageColorResolve($imageGd, $bgColor[0], $bgColor[1], $bgColor[2]);
$fgColorGd = imageColorResolve($imageGd, $fgColor[0], $fgColor[1], $fgColor[2]);
imageFilledRectangle($imageGd, 0, 0, imageSx($imageGd) - 1, $borderWidth * $symbolHeight, $fgColorGd);
imageFilledRectangle($imageGd, 0, (imageSy($imageGd) - 1) - $borderWidth * $symbolHeight, imageSx($imageGd) - 1, imageSy($imageGd) - 1, $fgColorGd);
imageFilledRectangle($imageGd, 0, 0, $borderWidth * $symbolWidth, imageSy($imageGd) - 1, $fgColorGd);
imageFilledRectangle($imageGd, (imageSx($imageGd) - 1) - $borderWidth * $symbolWidth, 0, imageSx($imageGd) - 1, imageSy($imageGd) - 1, $fgColorGd);
for($y = 0; $y < $height; ++$y) {
$line = '';
for($x = 0; $x < $width; ++$x)
$line .= mt_rand(0, 1) ? '\\' : '/';
imageString($imageGd, $fontGd, $borderWidth * $symbolWidth, ($borderWidth + $y) * $symbolHeight - 1, $line, $fgColorGd);
}
if($zoom != 1) {
$imageSrcGd = $imageGd;
$imageGd = imageCreateTrueColor(imageSx($imageSrcGd) * $zoom, imageSy($imageSrcGd) * $zoom);
imageCopyResampled($imageGd, $imageSrcGd, 0, 0, 0, 0, imageSx($imageGd), imageSy($imageGd), imageSx($imageSrcGd), imageSy($imageSrcGd));
imageDestroy($imageSrcGd);
}
header('Content-type: image/png');
imagePNG($imageGd);
imageDestroy($imageGd);
@powder96
Copy link
Author

powder96 commented Dec 2, 2012

Output:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment