javascript - HTML5 canvas: Same code outputs different results in different browsers -


in simple canvas test created performance , quality measurement purposes, canvas painted randomised colors , images during unlimited period.

a sample shown here: http://litterific.com/minisite/

warning: open in opera or chrome, script pretty heavy can hang on slow computers, don't leave script running while getting coffee ;)) rough prototype , did not optimize it.

what noticed here results painted script (js/asset.js) different in various browsers. in opera there more "green" in painting in chrome

alt text

code found here: http://litterific.com/minisite/js/asset.js

my question is:

how caused. different random seeds? different rounding or different color behavior in opera?

note: same script in both browsers, perhaps have @ in both chrome , opera.

it's not random numbers causing problems, it's "funny" pixel data. here's change:

for (i = 0, n = pixels.data.length; < n; += 4){   pixels.data[i + 0] = math.max(0, math.min(255, math.floor(r * f)));   pixels.data[i + 1] = math.max(0, math.min(255, math.floor(g * f)));   pixels.data[i + 2] = 0;   pixels.data[i + 3] = pixels.data[i + 3];  } 

if ensure pixel values integers in right range, opera works fine.

oh also, , obvious, goes lot faster if hoist multiplications out of loop.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -