File: color-pickers/Rigden_colorblind-convert_table.js

Recommend this page to a friend!
  Classes of Joseph   JS Master Color Picker script   color-pickers/Rigden_colorblind-convert_table.js   Download  
File: color-pickers/Rigden_colorblind-convert_table.js
Role: Auxiliary script
Content type: text/plain
Description: handles colorblind simulation conversions
Class: JS Master Color Picker script
Pick colors from a palette
Author: By
Last change:
Date: 11 years ago
Size: 11,186 bytes
 

Contents

Class file image Download
// requires SoftMoon.WebWare.rgb (JS_toolbucket/SoftMoon-WebWare/rgb.js) //this function: // • requires passing in a 6-digit hexadecimal RGB string or a 3-value integer-byte RGB array // • returns an array of hexadecimal RGB string values → [protan, deutan, tritan] // The returned array ☆simulates☆ colorblind vision for people with “full color” vision. // The returned array-Object has 2 additional properties: // • low // • high // Since the returned colorblind values are interpolated from a limited data pool, // these low/high properties are the arrays [protan, deutan, tritan] // of the “nearest” websafe colors from which the interpolated values are calculated. // I’m looking forward to finding a better formula to calculate the values directly… … … // Or perhaps converting to Hue-Chroma-Gray and interpolating those values would be better…but slower. SoftMoon.WebWare.rgb_to_colorblind=function(h) { if (typeof h == 'string' && SoftMoon.RigdenColorblindTable[h]) return SoftMoon.RigdenColorblindTable[h]; var i, j, x, ws=[], rgb=[], cb=[], low, high; for (i=0; i<3; i++) { //cycle through r, g, b x=(typeof h == 'string') ? parseInt(h.substr(i*2, 2), 16) : h[i]; // alert(x); ws[i]=0x33*Math.floor(x/0x33); rgb[i]=(x-ws[i])/0x33; } // alert(h +'\n'+ SoftMoon.WebWare.rgb.to.hex(ws)); cb.low=SoftMoon.RigdenColorblindTable[SoftMoon.WebWare.rgb.to.hex(ws)]; for (i=0; i<3; i++) {if (ws[i]<255) ws[i]+=0x33;} //cycle through r, g, b cb.high=SoftMoon.RigdenColorblindTable[SoftMoon.WebWare.rgb.to.hex(ws)]; for (i=0; i<3; i++) { //cycle through protan, deutan, tritan low=SoftMoon.WebWare.rgb.from.hex(cb.low[i]).rgb; high=SoftMoon.WebWare.rgb.from.hex(cb.high[i]).rgb; cb[i]=[]; for (j=0; j<3; j++) { //cycle through r, g, b cb[i][j]=low[j] + (high[j]-low[j])*rgb[j]; } cb[i]=SoftMoon.WebWare.rgb.to.hex(cb[i]); } return cb; } SoftMoon.RigdenColorblindTable={ // thanks to: http://safecolours.rigdenage.com/colours2.html // compiled by Christine Rigden 1997, updated 2010 /* websafe protan deutan tritan */ "FFFFFF": ["FFFAFA", "FFE8EF", "F4F0FF"], "FFFFCC": ["FFF2C8", "FFDFC8", "FDEFFF"], "FFFF99": ["FFEDA2", "FFDAAD", "FFEAF9"], "FFFF66": ["FFEA86", "FFD79D", "FFE6F5"], "FFFF33": ["FFE975", "FFD594", "FFE5F3"], "FFFF00": ["FFE871", "FFD592", "FFE4F2"], "FFCCFF": ["CFD7FF", "E1D8FD", "FBD1E1"], "FFCCCC": ["DED8D2", "F1D2CB", "FFCAD8"], "FFCC99": ["E5D69D", "FCCD99", "FFC4D1"], "FFCC66": ["E9D469", "FFCA6F", "FFC0CD"], "FFCC33": ["ECD435", "FFC857", "FFBFCA"], "FFCC00": ["ECD30F", "FFC750", "FFBECA"], "FF99FF": ["AABDFF", "B0BCF9", "F6A9B5"], "FF99CC": ["B1B8E0", "C5B5C7", "FC9FAA"], "FF9999": ["BDB6A8", "D2B095", "FF99A2"], "FF9966": ["C4B470", "DAAC62", "FF959E"], "FF9933": ["C7B43A", "DEAB2A", "FF949D"], "FF9900": ["C8B317", "DFAA00", "FF949C"], "FF66FF": ["98B2FF", "85A7F5", "F28791"], "FF66CC": ["82A0F6", "A09FC3", "F87981"], "FF6699": ["999DB9", "B19992", "FD6E74"], "FF6666": ["A59B7C", "BB955E", "FF666C"], "FF6633": ["AA9A42", "BF9322", "FF656A"], "FF6600": ["AC9A1E", "C09300", "FF6569"], "FF33FF": ["96B1FF", "679BF2", "F07178"], "FF33CC": ["779DFF", "8A92C1", "F75E63"], "FF3399": ["7A8ECE", "9D8B8F", "FB4C4F"], "FF3366": ["8F8C8B", "A7875C", "FE3D3E"], "FF3333": ["988B4A", "AD841C", "FF3332"], "FF3300": ["9A8B23", "AE8600", "FF3331"], "FF00FF": ["96B1FF", "5E98F1", "F06A71"], "FF00CC": ["7BA0FF", "838FC0", "F6555A"], "FF0099": ["6E89D7", "97888E", "FA4042"], "FF0066": ["888892", "A2835B", "FD2B28"], "FF0033": ["93874E", "A8801A", "FE1A00"], "FF0000": ["968726", "A98200", "FE1C00"], "CCFFFF": ["F8F4F8", "FFEAFD", "CBEFFF"], "CCFFCC": ["FFF1C5", "FFDECC", "D3EFFF"], "CCFF99": ["FFEB97", "FFD8AB", "D9EEFF"], "CCFF66": ["FFE873", "FFD497", "DDEEFF"], "CCFF33": ["FFE75C", "FFD38C", "E0EEFF"], "CCFF00": ["FFE655", "FFD389", "E0EEFF"], "CCCCFF": ["C4CEFF", "CBCCFF", "C6D1E1"], "CCCCCC": ["CFCBCB", "DEC6CD", "CECAD9"], "CCCC99": ["D7C997", "EAC19B", "D3C4D3"], "CCCC66": ["DBC764", "F1BE6A", "D7C1CF"], "CCCC33": ["DDC631", "F5BC3B", "D8BFCD"], "CCCC00": ["DDC600", "F6C600", "D9BECC"], "CC99FF": ["98B1FF", "8FAEFB", "BFA9B6"], "CC99CC": ["9EA8D7", "AAA7C9", "C79FAB"], "CC9999": ["AAA5A0", "BAA198", "CD98A2"], "CC9966": ["B1A46A", "C49D65", "D0929D"], "CC9933": ["B5A336", "C99B32", "D2909A"], "CC9900": ["B5A20E", "CA9A00", "D38F99"], "CC66FF": ["87A7FF", "4C97F6", "BB8791"], "CC66CC": ["648CEB", "7B8DC5", "C37982"], "CC6699": ["7F88AF", "918694", "C96E75"], "CC6666": ["8C8675", "9E8161", "CC656C"], "CC6633": ["92853C", "A47E2B", "CE6067"], "CC6600": ["948415", "A67F00", "CF5F65"], "CC33FF": ["8AAAFF", "008DEF", "B87178"], "CC33CC": ["4387FF", "577EC2", "C15E64"], "CC3399": ["5275C8", "767591", "C64C50"], "CC3366": ["707387", "856F5F", "CA3D3F"], "CC3333": ["7B7146", "8C6C27", "CC3334"], "CC3300": ["7E711B", "8F6D00", "CC3030"], "CC00FF": ["8CABFF", "008CEC", "B76A71"], "CC00CC": ["5D91FF", "4B7AC0", "C0555A"], "CC0099": ["356FD5", "6E7190", "C64043"], "CC0066": ["646D90", "7E6A5E", "CA2B2B"], "CC0033": ["746C4C", "856726", "CB170B"], "CC0000": ["786C1E", "886900", "CC1600"], "99FFFF": ["EFECF4", "F4E4FF", "A6EFFF"], "99FFCC": ["F7E9C1", "FFDDD0", "ACEFFF"], "99FF99": ["FBE790", "FFD6A9", "B0EEFF"], "99FF66": ["FEE65E", "FFD291", "B4EEFF"], "99FF33": ["FFE532", "FFD184", "B5EDFF"], "99FF00": ["FFE41C", "FFD080", "B6EDFF"], "99CCFF": ["B9C5FA", "B9C4FF", "91D1E1"], "99CCCC": ["C4C1C6", "CEBDCF", "9CCAD9"], "99CC99": ["CBBF93", "DBB89D", "A3C4D3"], "99CC66": ["CFBD61", "E4B56C", "A8C1CF"], "99CC33": ["D1BC2F", "E8B33F", "AABFCD"], "99CC00": ["D2BC00", "E9B22A", "ABBECD"], "9999FF": ["83A4FF", "6FA4FD", "86A9B6"], "9999CC": ["8F9CCE", "929BCC", "929FAB"], "999999": ["9B9899", "A6949A", "9A97A3"], "999966": ["A29665", "B29068", "9F929D"], "999933": ["A59532", "B78E37", "A2909A"], "999900": ["A69500", "A69500", "A28F99"], "9966FF": ["709BFF", "0090F3", "7E8791"], "9966CC": ["497BDF", "507FC7", "8C7982"], "996699": ["6A77A5", "737696", "946D75"], "996666": ["78746D", "847064", "9A656C"], "996633": ["7E7237", "8C6D31", "9C6067"], "996600": ["7F720D", "8E6C00", "9D5F66"], "9933FF": ["7DA2FF", "008DE8", "7A7078"], "9933CC": ["007AF6", "0073C2", "885D64"], "993399": ["005EBF", "496192", "914C51"], "993366": ["505B80", "625961", "963D40"], "993333": ["5F5941", "6C552D", "993335"], "993300": ["635913", "705600", "9A3032"], "9900FF": ["83A6FF", "008CE5", "796A71"], "9900CC": ["2782FF", "0073C0", "87555B"], "990099": ["0067D0", "385B90", "904044"], "990066": ["39538F", "57535F", "962B2C"], "990033": ["55514A", "634E2C", "981612"], "990000": ["5A5117", "674F00", "991100"], "66FFFF": ["EAE7F0", "EBDFFF", "88EFFF"], "66FFCC": ["F1E4BF", "FFDDD3", "8BEFFF"], "66FF99": ["F6E28D", "FFD5A7", "8EEEFF"], "66FF66": ["F8E15D", "FFD08B", "90EEFF"], "66FF33": ["FAE02A", "FFCF7C", "92EDFF"], "66FF00": ["FAE000", "FFCE79", "92EDFF"], "66CCFF": ["B2BEF5", "ADBEFF", "57D1E1"], "66CCCC": ["BDBBC1", "C3B7D1", "6BCAD9"], "66CC99": ["C4B88F", "D2B29F", "77C4D3"], "66CC66": ["C8B65E", "DAAE6E", "7EC1CF"], "66CC33": ["CAB52D", "DFAC42", "81BFCD"], "66CC00": ["CAB500", "E0AC2E", "82BECD"], "6699FF": ["6E98FE", "519CFE", "3EA9B6"], "6699CC": ["8593C7", "8093CD", "5A9FAB"], "669999": ["918F93", "978C9C", "6997A3"], "669966": ["988C61", "A4876A", "71929D"], "669933": ["9B8B2F", "AA853B", "74909A"], "669900": ["9B8B00", "AC8421", "758F9A"], "6666FF": ["518DFF", "0090EE", "228791"], "6666CC": ["326ED5", "0076C9", "4D7982"], "666699": ["59699C", "586A98", "5E6D75"], "666666": ["686666", "6F6367", "67656C"], "666633": ["6D6432", "795F35", "6B6067"], "666600": ["6F6300", "7B5E11", "6C5F66"], "6633FF": ["6E9AFF", "008CE4", "007179"], "6633CC": ["0074EA", "0076C2", "445D64"], "663399": ["0059B4", "005995", "584C51"], "663366": ["324676", "3D4763", "623D41"], "663333": ["46433A", "4F4031", "663336"], "663300": ["4A420B", "534000", "673033"], "6600FF": ["7AA1FF", "008BE1", "006B73"], "6600CC": ["007CF8", "0076BF", "42545B"], "660099": ["0065CA", "005A94", "563F44"], "660066": ["00478E", "253D60", "602B2D"], "660033": ["323748", "3F352F", "651615"], "660000": ["3C360F", "453500", "660B00"], "33FFFF": ["E7E5EF", "E7DDFF", "74EFFF"], "33FFCC": ["EEE2BD", "FCDBD4", "76EFFF"], "33FF99": ["F3DF8C", "FFD4A6", "78EEFF"], "33FF66": ["F5DE5C", "FFCF88", "79EEFF"], "33FF33": ["F7DD29", "FFCD78", "7AEDFF"], "33FF00": ["F7DD00", "FFCD74", "7AEDFF"], "33CCFF": ["AEBBF2", "A7BBFF", "00D1E0"], "33CCCC": ["B9B7BF", "BDB4D1", "3ECAD9"], "33CC99": ["C0B48E", "CCAEA0", "54C4D3"], "33CC66": ["C4B25D", "D6AB6F", "5EC1CF"], "33CC33": ["C6B22C", "DAA943", "63BFCD"], "33CC00": ["C6B100", "DBA830", "64BFD7"], "3399FF": ["6993FA", "3999FF", "00ABB7"], "3399CC": ["7F8EC3", "758FCE", "00A0AC"], "339999": ["8C8A90", "8F879D", "3997A3"], "339966": ["92875E", "9D826B", "49929D"], "339933": ["95862E", "A4803C", "4F909A"], "339900": ["958600", "A58600", "518F9A"], "3366FF": ["2581FF", "0090EC", "009099"], "3366CC": ["2067CD", "0078C9", "007F87"], "336699": ["506195", "43639A", "146D76"], "336666": ["5E5D61", "615B68", "35656D"], "336633": ["645B2F", "6D5737", "3F6068"], "336600": ["655B00", "705617", "415F66"], "3333FF": ["6094FF", "008CE2", "008187"], "3333CC": ["0070E1", "0078C2", "006A70"], "333399": ["0054AA", "005D99", "005056"], "333366": ["19376A", "003B65", "263C41"], "333333": ["343333", "373133", "333236"], "333300": ["373200", "3D2F09", "363033"], "3300FF": ["739DFF", "008BDF", "007C82"], "3300CC": ["0079F2", "0076BF", "006469"], "330099": ["0062C4", "005D96", "00474B"], "330066": ["00468B", "003F67", "212A2D"], "330033": ["002448", "131E30", "301517"], "330000": ["1E1B08", "221A00", "330600"], "00FFFF": ["E6E4EE", "E6DCFF", "6EEFFF"], "00FFCC": ["EDE1BD", "FBDAD4", "70EFFF"], "00FF99": ["F2DF8C", "FFD3A6", "72EEFF"], "00FF66": ["F5DD5C", "FFCF87", "73EEFF"], "00FF33": ["F6DD29", "FFCD77", "73EDFF"], "00FF00": ["F6DC00", "FFCD72", "73EDFF"], "00CCFF": ["ADBAF2", "A5BBFF", "00D0DF"], "00CCCC": ["B8B6BF", "BBB3D1", "29CAD9"], "00CC99": ["BFB38D", "CBAEA0", "47C4D3"], "00CC66": ["C3B25D", "D4AA6F", "54C1CF"], "00CC33": ["C5B12B", "D9A844", "59BFCD"], "00CC00": ["C5B000", "DAA831", "5ABFCD"], "0099FF": ["6792F8", "3398FF", "00ACB7"], "0099CC": ["7E8DC2", "728ECF", "00A1AC"], "009999": ["8A898F", "8D869D", "1F97A3"], "009966": ["90865E", "9B816C", "39929D"], "009933": ["93852D", "A27E3D", "42909A"], "009900": ["948500", "A37E25", "448F9A"], "0066FF": ["007EFE", "0090EC", "00929A"], "0066CC": ["1A66CC", "0078C9", "00828A"], "006699": ["4E5F93", "3D629A", "00727A"], "006666": ["5C5B5F", "5E5A69", "15656D"], "006633": ["61592E", "6A5538", "2A6068"], "006600": ["635800", "6D5418", "2D5F66"], "0033FF": ["5B91FF", "008CE2", "008389"], "0033CC": ["006FDE", "0078C2", "006F74"], "003399": ["0053A6", "005E9A", "00595E"], "003366": ["0D3366", "003E68", "004347"], "003333": ["2E2E30", "2F2D34", "0A3236"], "003300": ["312C00", "362A0C", "173033"], "0000FF": ["719CFF", "008BDF", "007F85"], "0000CC": ["0078F0", "0076BE", "006A6E"], "000099": ["0060C1", "005E97", "005155"], "000066": ["004487", "004168", "003739"], "000033": ["002346", "002135", "001C1D"], "000000": ["000000", "000000", "000000"] };