0

I have a canvas that is mostly filled black but some of the pixels have been turned transparent using the following code where imageData is one transparent pixel32:

const ctx = canvas.getContext("2d");
ctx.putImageData(imageData, x, y);

How can I scale the canvas so that as it's own size grows, the placement of the transparent pixels is also scaled? I suppose this would mean losing some transparent pixels if making the canvas smaller in size and adding some transparent pixels if making the canvas larger in size.

There are a lot of similar questions but none of their answers seem to achieve this functionality.

m4gik
  • 430
  • 5
  • 27
  • You can try progressively put larger and larger ones on top of the original – Andrew Jan 21 '18 at 07:44
  • This question I found ended up being the solution: https://stackoverflow.com/questions/3448347/how-to-scale-an-imagedata-in-html-canvas – m4gik Jan 21 '18 at 08:20

0 Answers0