Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!


<?php
// Requires the GD Library
header("Content-type: image/png");
$im = imagecreatetruecolor(2120, 2120)
or die("Cannot Initialize new GD image stream");
$white = imagecolorallocate($im, 255, 255, 255);
for ($y=0; $y<2120; $y++) {
for ($x=0; $x<2120; $x++) {
if (rand(0,1) === 1) {
imagesetpixel($im, $x, $y, $white);
}
}
}
imagepng($im);
imagedestroy($im);


public static void main(String[] args) throws IOException {
int height = 512;
int weight = 512;
BufferedImage image = new BufferedImage(weight, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0 ; x < weight; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, new Random().nextBoolean() ? Color.white.getRGB() : Color.black.getRGB());
}
}
ImageIO.write(image, "jpg", new File("c:/randomCheck.jpg"));
}


function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
mt_srand(make_seed());
$size=512;
$image = imagecreatetruecolor($size,$size);
$black = imagecolorallocate ($image, 0,0,0 );
$white = imagecolorallocate ($image, 255,255,255 );
for ($x = 0; $x<$size; $x++) {
for ($y = 0; $y<$size; $y++) {
imagesetpixel($image,$x,$y,mt_rand(0,1)?$black:$white);
}
}
header ('Content-Type: image/png');
imagepng($image);
Генерация случайных чисел с помощью Random.org