{"id":1188,"date":"2023-10-20T13:11:12","date_gmt":"2023-10-20T12:11:12","guid":{"rendered":"https:\/\/haxed.me.uk\/?p=1188"},"modified":"2023-10-20T13:11:13","modified_gmt":"2023-10-20T12:11:13","slug":"utilising-php-gd-to-draw-polygon-plot-images-and-turning-them-into-an-animation-w-ffmpeg","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2023\/10\/20\/utilising-php-gd-to-draw-polygon-plot-images-and-turning-them-into-an-animation-w-ffmpeg\/","title":{"rendered":"Utilising PHP GD to Draw Polygon Plot Images and turning them into an animation w\/ffmpeg"},"content":{"rendered":"\n<p>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&#8217;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&#8217;t see much else. <\/p>\n\n\n\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n$x = 1920; $y = 1080;\n$image=imagecreatetruecolor($x, $y);\n$white= imagecolorallocatealpha($image, 255, 255, 255, 75);\n\/\/ Draw the polygon\n\n\/\/ generate random image co-ordinates for polygon\n\nfor ($f=0; $f &lt;=250; $f++) {\n\n$i = rand(0,1920);\n$i2 = rand (0,1080);\n\n$j = rand(0,1920);\n$j2 = rand(0,1080);\n\n$k = rand(0,1920);\n$k2 = rand(0,1080);\n\n$l = rand(0,1920);\n$l2 = rand(0,1080);\n\n\nimagepolygon($image, array(\n        $i, $i2,\n        $j, $j2,\n        $k, $k2,\n        $l, $l2\n), 4, $white);\n\n\n\n}\n\n\nheader('Content-type: image\/png');\nImagePNG($image);\nImageDestroy($image);\n?&gt;\n<\/pre>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n#!\/bin\/bash\n#generate tha images\n\ncount=1000\nfor i in $(seq $count)\ndo\n       php polygon2.php &gt; images\/img&quot;$i&quot;.png;\ndone\n\n<\/pre>\n\n\n\n<p>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 &#8216;frontend&#8217; 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.<\/p>\n\n\n\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nffmpeg -framerate 30 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p out.mp4\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2023\/10\/20\/utilising-php-gd-to-draw-polygon-plot-images-and-turning-them-into-an-animation-w-ffmpeg\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1188","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/1188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=1188"}],"version-history":[{"count":2,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/1188\/revisions"}],"predecessor-version":[{"id":1191,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/1188\/revisions\/1191"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}