javascript - Line break data every N elements, when converting and image to hex -


i'm trying insert line break code, when image data output hex, there line break every 150 values. thought appeand line break , use modulus remainder = 0 determine if value divisible 150.

to tried... if (i % 150==0) not output correctly.

code:

for (var = 0, n = imagedata.length; < n; += 4) {          // r in rgba         var de = imagedata[i];         // g in rgba         var ne = imagedata[i + 1];         // b in rgba         var eu = imagedata[i + 2];         // in rgba (opacity). don't use in our calculation. if you'd enable         // it, uncomment code directly below it.         var ah = imagedata[i + 3];         // uncomment code enable accurate opacity in images         // http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb         // de = ((1 - ah) * de) + (ah * de);         // ne = ((1 - ah) * ne) + (ah * ne);         // eu = ((1 - ah) * eu) + (ah * eu);         var hexi =             // each 1 of these take r, g or b converts hex , concatinates them             // make hex values 51327e             ("0" + parseint(de, 10).tostring(16)).slice(-2) +             ("0" + parseint(ne, 10).tostring(16)).slice(-2) +             ("0" + parseint(eu, 10).tostring(16)).slice(-2);         // prepend 0x hex make hex values 0x51327e         result += "0x";         result += hexi;         result += ", ";          if (i % 150==0) {         result += " ******************* ";          }     } 


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -