Created
          May 10, 2020 15:48 
        
      - 
      
- 
        Save forksofpower/9f4a3354916d7991805c84ebcc49d8cb to your computer and use it in GitHub Desktop. 
    Deprecated functions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function splitLow4Bits(num) { | |
| return (num & parseInt('00001111', 2)) | |
| } | |
| function splitHigh4Bits(num) { | |
| return (num & parseInt('11110000', 2)) >> 4 | |
| } | |
| // All this is no longer needed because of | |
| // the magic of ArrayBuffer and TypedArrays | |
| function assign32BitColors(array) { | |
| return new Uint32Array(array.map(x => COLORS[x])) | |
| } | |
| function convertToUint8ClampedArray(array) { | |
| let test = array.reduce((arr, num) => { | |
| let bytes = toBytesInt32(num); | |
| arr.push(bytes[0]) | |
| arr.push(bytes[1]) | |
| arr.push(bytes[2]) | |
| arr.push(bytes[3]) | |
| return arr; | |
| }, []); | |
| return new Uint8ClampedArray(test) | |
| } | |
| // split 32bits into 4 x 8bits | |
| function toBytesInt32 (num) { | |
| let arr = new Uint8Array([ | |
| (num & 0xff000000) >> 24, | |
| (num & 0x00ff0000) >> 16, | |
| (num & 0x0000ff00) >> 8, | |
| (num & 0x000000ff) | |
| ]); | |
| return arr; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment