MCPcopy Create free account
hub / github.com/32comic/image2pixel-web / paintBlockGrid

Function paintBlockGrid

web/js/algorithms.js:227–242  ·  view source on GitHub ↗
(grid, rows, cols, imageData, blockSize)

Source from the content-addressed store, hash-verified

225}
226
227function 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

Callers 4

processWithClassicLabFunction · 0.85
processWithLabDitherFunction · 0.85
processWithTezumieFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected