p5.js-web-editor/static/interceptor/ntc.min.js

3 lines
36 KiB
JavaScript
Raw Normal View History

2016-08-19 18:44:44 +02:00
var ntc={init:function(){for(var a,b,c,d=0;d<ntc.names.length;d++)a="#"+ntc.names[d][0],b=ntc.rgb(a),c=ntc.hsl(a),ntc.names[d].push(b[0],b[1],b[2],c[0],c[1],c[2])},name:function(a){if(a=a.toUpperCase(),a.length<3||a.length>7)return["#000000","Invalid Color: "+a,!1];a.length%3==0&&(a="#"+a),4==a.length&&(a="#"+a.substr(1,1)+a.substr(1,1)+a.substr(2,1)+a.substr(2,1)+a.substr(3,1)+a.substr(3,1));var b=ntc.rgb(a),c=b[0],d=b[1],e=b[2],f=ntc.hsl(a),g=f[0],h=f[1],i=f[2],j=0;ndf2=0,ndf=0;for(var k=-1,l=-1,m=0;m<ntc.names.length;m++){if(a=="#"+ntc.names[m][0])return["#"+ntc.names[m][0],ntc.names[m][1],!0];j=Math.pow(c-ntc.names[m][2],2)+Math.pow(d-ntc.names[m][3],2)+Math.pow(e-ntc.names[m][4],2),ndf2=Math.pow(g-ntc.names[m][5],2)+Math.pow(h-ntc.names[m][6],2)+Math.pow(i-ntc.names[m][7],2),ndf=j+2*ndf2,(l<0||l>ndf)&&(l=ndf,k=m)}return k<0?["#000000","Invalid Color: "+a,!1]:["#"+ntc.names[k][0],ntc.names[k][1],!1]},hsl:function(a){var c,d,e,f,g,h,b=[parseInt("0x"+a.substring(1,3))/255,parseInt("0x"+a.substring(3,5))/255,parseInt("0x"+a.substring(5,7))/255],i=b[0],j=b[1],k=b[2];return c=Math.min(i,Math.min(j,k)),d=Math.max(i,Math.max(j,k)),e=d-c,h=(c+d)/2,g=0,h>0&&h<1&&(g=e/(h<.5?2*h:2-2*h)),f=0,e>0&&(d==i&&d!=j&&(f+=(j-k)/e),d==j&&d!=k&&(f+=2+(k-i)/e),d==k&&d!=i&&(f+=4+(i-j)/e),f/=6),[parseInt(255*f),parseInt(255*g),parseInt(255*h)]},rgb:function(a){return[parseInt("0x"+a.substring(1,3)),parseInt("0x"+a.substring(3,5)),parseInt("0x"+a.substring(5,7))]},names:[["000000","Black"],["000080","Navy Blue"],["0000C8","Dark Blue"],["0000FF","Blue"],["000741","Stratos"],["001B1C","Swamp"],["002387","Resolution Blue"],["002900","Deep Fir"],["002E20","Burnham"],["002FA7","International Klein Blue"],["003153","Prussian Blue"],["003366","Midnight Blue"],["003399","Smalt"],["003532","Deep Teal"],["003E40","Cyprus"],["004620","Kaitoke Green"],["0047AB","Cobalt"],["004816","Crusoe"],["004950","Sherpa Blue"],["0056A7","Endeavour"],["00581A","Camarone"],["0066CC","Science Blue"],["0066FF","Blue Ribbon"],["00755E","Tropical Rain Forest"],["0076A3","Allports"],["007BA7","Deep Cerulean"],["007EC7","Lochmara"],["007FFF","Azure Radiance"],["008080","Teal"],["0095B6","Bondi Blue"],["009DC4","Pacific Blue"],["00A693","Persian Green"],["00A86B","Jade"],["00CC99","Caribbean Green"],["00CCCC","Robin's Egg Blue"],["00FF00","Green"],["00FF7F","Spring Green"],["00FFFF","Cyan / Aqua"],["010D1A","Blue Charcoal"],["011635","Midnight"],["011D13","Holly"],["012731","Daintree"],["01361C","Cardin Green"],["01371A","County Green"],["013E62","Astronaut Blue"],["013F6A","Regal Blue"],["014B43","Aqua Deep"],["015E85","Orient"],["016162","Blue Stone"],["016D39","Fun Green"],["01796F","Pine Green"],["017987","Blue Lagoon"],["01826B","Deep Sea"],["01A368","Green Haze"],["022D15","English Holly"],["02402C","Sherwood Green"],["02478E","Congress Blue"],["024E46","Evening Sea"],["026395","Bahama Blue"],["02866F","Observatory"],["02A4D3","Cerulean"],["03163C","Tangaroa"],["032B52","Green Vogue"],["036A6E","Mosque"],["041004","Midnight Moss"],["041322","Black Pearl"],["042E4C","Blue Whale"],["044022","Zuccini"],["044259","Teal Blue"],["051040","Deep Cove"],["051657","Gulf Blue"],["055989","Venice Blue"],["056F57","Watercourse"],["062A78","Catalina Blue"],["063537","Tiber"],["069B81","Gossamer"],["06A189","Niagara"],["073A50","Tarawera"],["080110","Jaguar"],["081910","Black Bean"],["082567","Deep Sapphire"],["088370","Elf Green"],["08E8DE","Bright Turquoise"],["092256","Downriver"],["09230F","Palm Green"],["09255D","Madison"],["093624","Bottle Green"],["095859","Deep Sea Green"],["097F4B","Salem"],["0A001C","Black Russian"],["0A480D","Dark Fern"],["0A6906","Japanese Laurel"],["0A6F75","Atoll"],["0B0B0B","Cod Gray"],["0B0F08","Marshland"],["0B1107","Gordons Green"],["0B1304","Black Forest"],["0B6207","San Felix"],["0BDA51","Malachite"],["0C0B1D","Ebony"],["0C0D0F","Woodsmoke"],["0C1911","Racing Green"],["0C7A79","Surfie Green"],["0C8990","Blue Chill"],["0D0332","Black Rock"],["0D1117","Bunker"],["0D1C19","Aztec"],["0D2E1C","Bush"],["0E0E18","Cinder"],["0E2A30","Firefly"],["0F2D9E","
};ntc.init();