const canvas = document.createElement('canvas')
canvas.width = 200
canvas.height = 200
document.body.appendChild(canvas)
const ctx = canvas.getContext('2d')
const imgData = ctx.createImageData(100, 100)
for (let i=0; i<imgData.data.length; i+=4) {
imgData.data[i + 0] = 255
imgData.data[i + 1] = 0
imgData.data[i + 2] = 0
imgData.data[i + 3] = 255
}
ctx.putImageData(imgData, 10, 10)
'html | javascript' 카테고리의 다른 글
html javascript - array filter (0) | 2024.08.21 |
---|---|
html javascript - canvas to png, jpg file (0) | 2024.08.19 |
html javascript - array, object copy (0) | 2024.08.19 |
html javascript - easing circular (0) | 2024.08.19 |
html javascript - easing exponential (0) | 2024.08.19 |