{"id":141,"date":"2023-12-23T09:54:54","date_gmt":"2023-12-23T09:54:54","guid":{"rendered":"https:\/\/www.codelitter.com\/?p=141"},"modified":"2023-12-23T10:00:18","modified_gmt":"2023-12-23T10:00:18","slug":"random","status":"publish","type":"post","link":"https:\/\/www.codelitter.com\/?p=141","title":{"rendered":"Random"},"content":{"rendered":"<p><label for=\"delay-input\">Delay:<input type=\"number\" id=\"delay-input\" min=\"0\", max=\"60\" step=\"0.1\", value=\"1\" required\/><\/label><canvas id=\"random-image-canvas\" width=\"1920\" height=\"1080\" style=\"width:100%\"><\/canvas><script>const RANDOM_MAX_LENGTH=2**16;var animationDelay;var animationTimeout;function init(){window.requestAnimationFrame(draw);animationDelay=1000*Number(document.getElementById(\"delay-input\").value);document.getElementById(\"delay-input\").addEventListener(\"input\",function(){clearTimeout(animationTimeout);animationDelay=1000*Number(this.value);animationTimeout=setTimeout(()=>{window.requestAnimationFrame(draw)},animationDelay)})}function draw(){const canvas=document.getElementById(\"random-image-canvas\");if(canvas.getContext){const ctx=canvas.getContext(\"2d\");let newImageData=ctx.createImageData(canvas.width,canvas.height);let pixelData=newImageData.data;for(let i=0;i<pixelData.length;i+=RANDOM_MAX_LENGTH){if(i+RANDOM_MAX_LENGTH<pixelData.length){window.crypto.getRandomValues(new Uint32Array(pixelData.buffer,i,RANDOM_MAX_LENGTH\/Uint32Array.BYTES_PER_ELEMENT))}else{window.crypto.getRandomValues(new Uint8Array(pixelData.buffer,i))}}for(let i=0;i<pixelData.length;i+=4){pixelData[i+3]=255}ctx.putImageData(newImageData,0,0);animationTimeout=setTimeout(()=>{window.requestAnimationFrame(draw)},animationDelay)}}window.addEventListener(\"load\",init);<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-image","hentry","category-content","post_format-post-format-image","entry"],"_links":{"self":[{"href":"https:\/\/www.codelitter.com\/index.php?rest_route=\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codelitter.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codelitter.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codelitter.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codelitter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":58,"href":"https:\/\/www.codelitter.com\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":199,"href":"https:\/\/www.codelitter.com\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions\/199"}],"wp:attachment":[{"href":"https:\/\/www.codelitter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codelitter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codelitter.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}