meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.55k stars 404 forks source link

Why use Uint8Array instead of Uint8ClampedArray? #186

Open jocooler opened 8 years ago

jocooler commented 8 years ago

I realize that they are very similar (see http://stackoverflow.com/questions/21819870/difference-between-uint8array-and-uint8clampedarray for difference), but using the ClampedArray would be more inline with how canvases are normally manipulated.

IE10 only supports Uint8Arrays, but the fallback in place would already work for them.

util.coffee:38

# Support for browsers that don't know Uint8Array (such as IE9)
  @dataArray: (length = 0) ->
    return new Uint8Array(length) if Caman.NodeJS or window.Uint8Array?
    return new Array(length)