--- ./p2j.strokes.js.orig 2020-10-09 15:52:11.166217000 +0300 +++ ./p2j.strokes.js 2020-10-16 17:23:26.340609000 +0300 @@ -675,6 +675,10 @@ imageData[i + 3] = 255; } + // prepare one pixel with selected color attribute + const pix32Bit = new Uint32Array(imageData.buffer); + var onePix = pix32Bit[0]; + /** * Prepares the given stroke to be applied to the line of pixels called a path. */ @@ -701,27 +705,13 @@ // Calculate the line with and height to draw a line as an image var lineWidth = x2 - x1 + 1; var lineHeight = y2 - y1 + 1; + // Create a line image var screenImage = canvasRenderer.createImageData(lineWidth, lineHeight); - var data = screenImage.data; - var length = 4 * lineWidth * lineHeight; - - // Fill a line image with the given stroke color - data[0] = strokeColor[0]; - data[1] = strokeColor[1]; - data[2] = strokeColor[2]; - data[3] = 255; - var pos = 4; - var seqLen = 4; - while(pos < length) - { - data.copyWithin(pos, 0, seqLen); - // increment position by the length of the current segment - pos += seqLen; - // double the length of the next segment - seqLen <<= 1; - } + // fill new line data with current line color + const data32 = new Uint32Array(screenImage.data.buffer); + data32.fill(onePix); // Put the line image on the canvas canvasRenderer.putImageData(screenImage, x1, y1);