Created
August 8, 2018 23:06
-
-
Save silverkorn/afc5eed52c6514679265c6903cfc981b to your computer and use it in GitHub Desktop.
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
var fs = require('fs'); | |
filename = process.argv[2]; | |
var data = fs.readFileSync(filename); | |
var arr = data.toString().split('\n'); | |
var returnString = ''; | |
returnString = 'const vec3 palette[' + (arr.length - 1) + '] = vec3[]( '; | |
for(var i in arr){ | |
if(arr[i].length > 5){ | |
if(i > 0){ | |
returnString = returnString + ', '; | |
} | |
returnString = returnString + 'vec3('; | |
returnString = returnString + ((parseInt(arr[i][0]+ arr[i][1], 16))/255).toFixed(4) + ','; | |
returnString = returnString + ((parseInt(arr[i][2] + arr[i][3], 16))/255).toFixed(4) + ','; | |
returnString = returnString + ((parseInt(arr[i][4] + arr[i][5], 16))/255).toFixed(4); | |
returnString = returnString + ')'; | |
} | |
} | |
returnString = returnString + ' );'; | |
console.log(returnString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment