(grid, rows, cols, imageData, blockSize)
| 225 | } |
| 226 | |
| 227 | function paintBlockGrid(grid, rows, cols, imageData, blockSize) { |
| 228 | const { width, height } = imageData; |
| 229 | const d = imageData.data; |
| 230 | for (let row = 0; row < rows; row++) { |
| 231 | for (let col = 0; col < cols; col++) { |
| 232 | const [r, g, b] = grid[row][col]; |
| 233 | const x0 = col * blockSize, y0 = row * blockSize; |
| 234 | for (let dy = 0; dy < blockSize && y0 + dy < height; dy++) { |
| 235 | for (let dx = 0; dx < blockSize && x0 + dx < width; dx++) { |
| 236 | const idx = ((y0 + dy) * width + (x0 + dx)) * 4; |
| 237 | d[idx] = r; d[idx + 1] = g; d[idx + 2] = b; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | // ============================================================ |
| 245 | // Floyd-Steinberg Dithering on Block Grid |
no outgoing calls
no test coverage detected