function DoDots(imageData) { let width = imageData.width let height = imageData.height let data = imageData.data for(let dots = 0; dots < 100; ++dots) { let x = Math.round(Math.random() * width ) let y = Math.round(Math.random() * height ) let offset = (y * width + x) * 4 data[offset + 0] = Math.round(Math.random() * 255) data[offset + 1] = Math.round(Math.random() * 255) data[offset + 2] = Math.round(Math.random() * 255) data[offset + 3] = 255 } } export function DrawImage(inset, canvas) { const width= canvas.width const height = canvas.height const ctx = canvas.getContext("2d") const imageData = ctx.createImageData(width, height) DoDots(imageData) ctx.putImageData(imageData,0,0) }