{"ScriptPreparationCode":null,"TestCases":[{"Name":"32b","Code":"const W=300,H=300;\r\n\r\n//create canvas\r\nlet c = document.createElement(\u0027canvas\u0027);\r\nlet ctx = c.getContext(\u00272d\u0027);\r\nc.width=W; c.height=H;\r\nc.style.border=\u00271px solid white\u0027;\r\ndocument.body.appendChild(c);\r\n\r\n//create image\r\nlet img = ctx.createImageData(W,H);\r\n//create 32bit reference to img;\r\nlet buf32 = new Uint32Array(img.data.buffer);\r\n\r\n//set pixel via 32bit reference to the 8bit array in img\r\nfunction setPix(x,y,a,r,g,b)\r\n{\r\n\tbuf32[y*W\u002Bx] = (a \u003C\u003C 24) |\t// alpha\r\n\t\t\t\t\t\t\t\t (b \u003C\u003C 16) |\t// blue\r\n \t\t (g \u003C\u003C 8) |\t// green\r\n \t\t r;\t\t// red\r\n}\r\n\r\nfunction loop()\r\n{\r\n for (let i=0; i\u003CW; i\u002B\u002B)\r\n {\r\n for (let j=0; j\u003CH; j\u002B\u002B)\r\n {\r\n let r1 = Math.floor(Math.random() * 255);\r\n let r2 = Math.floor(Math.random() * 255);\r\n let r3 = Math.floor(Math.random() * 255);\r\n setPix(j,i,255,r1,r2,r3);\r\n }\r\n }\r\n ctx.putImageData(img,0,0);\r\n}\r\nloop();","IsDeferred":false},{"Name":"8b\u002B32b","Code":"const W=300,H=300;\r\n\r\n//create canvas\r\nlet c = document.createElement(\u0027canvas\u0027);\r\nlet ctx = c.getContext(\u00272d\u0027);\r\nc.width=W; c.height=H;\r\nc.style.border=\u00271px solid white\u0027;\r\ndocument.body.appendChild(c);\r\n\r\nlet img = ctx.createImageData(W,H);\r\n//create empty buffer\r\nvar imgbuf = new ArrayBuffer(img.data.length);\r\n//create 8bit reference to img;\r\nvar buf8 = new Uint8ClampedArray(imgbuf);\r\n//create 32bit reference to img;\r\nlet buf32 = new Uint32Array(imgbuf);\r\n\r\n//set pixel via 32bit reference to the 8bit array in img\r\nfunction setPix(x,y,a,r,g,b)\r\n{\r\n\tbuf32[y*W\u002Bx] = (a \u003C\u003C 24) |\t// alpha\r\n\t\t\t\t\t\t\t\t (b \u003C\u003C 16) |\t// blue\r\n \t\t (g \u003C\u003C 8) |\t// green\r\n \t\t r;\t\t// red\r\n}\r\n\r\nfunction loop()\r\n{\r\n for (let i=0; i\u003CW; i\u002B\u002B)\r\n {\r\n for (let j=0; j\u003CH; j\u002B\u002B)\r\n {\r\n let r1 = Math.floor(Math.random() * 255);\r\n let r2 = Math.floor(Math.random() * 255);\r\n let r3 = Math.floor(Math.random() * 255);\r\n setPix(j,i,255,r1,r2,r3);\r\n }\r\n }\r\n img.data.set(buf8);\r\n ctx.putImageData(img,0,0);\r\n}\r\nloop();","IsDeferred":false}]}