Skip to content

Instantly share code, notes, and snippets.

@compermisos
Last active May 14, 2017 14:35
Show Gist options
  • Save compermisos/3e622d0f5103e71f24690c4fee9c681d to your computer and use it in GitHub Desktop.
Save compermisos/3e622d0f5103e71f24690c4fee9c681d to your computer and use it in GitHub Desktop.
#!/usr/bin/php
<?php
// Code FROM http://stackoverflow.com/questions/14079703/str-shuffle-and-randomness
header("Content-type: image/png");
$im = @imagecreatetruecolor(512, 512) or die("Cannot Initialize new GD image stream");
$white = imagecolorallocate($im, 255, 255, 255);
for($y = 0; $y < 512; $y ++) {
for($x = 0; $x < 512; $x ++) {
if (testMTRand()) { //change each function here
imagesetpixel($im, $x, $y, $white);
}
}
}
imagepng($im);
imagedestroy($im);
function testMTRand() {
return mt_rand(0, 1);
}
function testRand() {
return rand(0, 1);
}
function testShuffle() {
return substr(str_shuffle("01"), 0, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment