Jump to content

Modify canvas on the fly


talamask
 Share

Recommended Posts

I kind of cannot understand why given example does not ends up with red texture.

function modify(width, pixelSize) {
   let existingImage = this.textures.get("dude").getSourceImage();
   let context = existingImage.getContext("2d");

   for (var y = 0; y < width; y++) {
      for (var x = 0; x < width; x++) {
         context.fillStyle = "#f00";
         context.fillRect(x * pixelSize, y * pixelSize, pixelSize, pixelSize);
      }
   }
}

I have checked that existingImage and context variables are populated ok, but calling this function does not produce desired result.

Please assist.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...