Utilising PHP GD to Draw Polygon Plot Images and turning them into an animation w/ffmpeg

As my excercises and fun investigation into the neural interface and cosmic OS, a simple probabilistic language synthesis methodology based on the ancient chinese ideas of divination and the iching. The concepts of the number of variations for data, like the possible encoding of a CD as 2^58 probably be enough to represent nearly any sound a human artist could produce audibly to the human ear. In this case we’re going to be utilising the cryptographic random function to provide start and end point co-ordinates on the x and y axis for our polygon.. In this case each polygon drawn has 4 points and are redrawn onto the same $image object. But, meh, you could generate an indeterminite number of points randomly in a single polygon call, this way the draw is continuous. Though, over about 250 xy co-ordinate points you can’t see much else.

$x = 1920; $y = 1080;
$image=imagecreatetruecolor($x, $y);
$white= imagecolorallocatealpha($image, 255, 255, 255, 75);
// Draw the polygon

// generate random image co-ordinates for polygon

for ($f=0; $f <=250; $f++) {

$i = rand(0,1920);
$i2 = rand (0,1080);

$j = rand(0,1920);
$j2 = rand(0,1080);

$k = rand(0,1920);
$k2 = rand(0,1080);

$l = rand(0,1920);
$l2 = rand(0,1080);

imagepolygon($image, array(
        $i, $i2,
        $j, $j2,
        $k, $k2,
        $l, $l2
), 4, $white);


header('Content-type: image/png');

Like before we utilise the handy program I have developed for cosmic OS to create an imageset that we can turn into an animation with ffmpeg video multiplexing.

#generate tha images

for i in $(seq $count)
       php polygon2.php > images/img"$i".png;

I was really satisfied with this demonstration, although a simple principle the possibilities for the simulation utilising ML and AI are really great, and utilising a php renderer, is, frankly, acceptable. So the ‘frontend’ is potentially missing a more powerful AI backend, but all of the principles are pretty well established. Generative art, is really really neat, and PHP can be a simple and powerful tool when used to do the right stuff.

ffmpeg -framerate 30 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p out.mp4