($width / 2), 'y' => 10);
$corners[1] = array('x' => 0, 'y' => ($height - 10));
$corners[2] = array('x' => $width, 'y' => ($height - 10));
$red = imagecolorallocatealpha($gd, 255, 0, 0, $reverseopacity);
for ($i = 0; $i < $howmany; $i++) {
ourimagesetpixel($gd, round($x),round($y), $red);
if (1 == 1) {
$x = rand(0, $width);
$y = rand(0, $height);
$red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity);
} else {
$a = rand(0, 2);
$x = ($x + $corners[$a]['x']) / 2;
$y = ($y + $corners[$a]['y']) / 2;
}
}
if (!isset($_GET['mode']) && !isset($_POST['mode'])) {
header('Content-Type: image/png');
imagepng($gd);
} else { // thanks to https://stackoverflow.com/questions/8551754/convert-gd-output-to-base64 for ideas
if (isset($_GET['mode'])) {
if (strpos(strtolower(urldecode($_GET['mode'])),'image') !== false && strlen(urldecode($_GET['mode'])) == strlen('image')) {
$idb = modeideas($gd);
echo '
';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'image') !== false && strlen(urldecode($_GET['mode'])) != strlen('image')) {
$idb = modeideas($gd);
echo ' parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('image')) . '").style.width="' . $width . 'px"; parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('image')) . '").style.height="' . $height . 'px"; parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('image')) . '").src="data:image/png;base64,' . $idb . '"; ";
} else if (strpos(strtolower(urldecode($_GET['mode'])),'img') !== false && strlen(urldecode($_GET['mode'])) == strlen('img')) {
$idb = modeideas($gd);
echo '';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'img') !== false && strlen(urldecode($_GET['mode'])) != strlen('img')) {
$idb = modeideas($gd);
echo ' parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('img')) . '").style.width="' . $width . 'px"; parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('img')) . '").style.height="' . $height . 'px"; parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('img')) . '").src="data:image/png;base64,' . $idb . '"; ";
} else if (strpos(strtolower(urldecode($_GET['mode'])),'div') !== false && strlen(urldecode($_GET['mode'])) == strlen('div')) {
$idb = modeideas($gd);
echo '';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'div') !== false && strlen(urldecode($_GET['mode'])) != strlen('div')) {
$idb = modeideas($gd);
echo ' parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('div')) . '").style.width="' . $width . 'px"; parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('div')) . '").style.height="' . $height . 'px"; parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('div')) . '").innerHTML="" . '"; ";
} else if (strpos(strtolower(urldecode($_GET['mode'])),'canvas') !== false && strlen(urldecode($_GET['mode'])) == strlen('canvas')) {
$idb = modeideas($gd);
$jsis=" function onl() { var canvas = document.getElementById('c'); \n"; // thanks to https://stackoverflow.com/questions/17090571/is-there-a-way-to-set-background-image-as-a-base64-encoded-image for ideas
$jsis.=" canvas.width = '" . $width . "'; \n";
$jsis.=" canvas.height = '" . $height . "'; \n";
$jsis.=" var ctx = canvas.getContext('2d'); \n\n";
$jsis.=" var image = new Image(); \n";
$jsis.=" image.width = '" . $width . "'; \n";
$jsis.=" image.height = '" . $height . "'; \n";
$jsis.=" image.onload = function() { \n";
$jsis.=" ctx.drawImage(image, 0, 0, " . $width . ", " . $height . ", 0, 0, " . $width . ", " . $height . "); \n";
$jsis.=" }; \n";
$jsis.=" image.src = 'data:image/png;base64," . $idb . "'; } \n";
echo ' ' . $jsis . '