Get X and Y pixel coordinates when iterating over HTML5 canvas getImageData

前端 未结 2 911
渐次进展
渐次进展 2020-12-13 14:04

I am iterating over some image data pulled from a canvas like so:

var imageData = this.context.getImageData(0, 0, this.el.width, this.el.height)         


        
2条回答
  •  情话喂你
    2020-12-13 14:35

    Corrected and tested version of code:

    var x = (i / 4) % this.el.width;
    var y = Math.floor((i / 4) / this.el.width);
    

提交回复
热议问题