Created
October 15, 2022 00:12
-
-
Save bayleedev/a373fde2c0a0857111ce47cd7a8b6cea to your computer and use it in GitHub Desktop.
Revisions
-
Baylee Schmeisser created this gist
Oct 15, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ import { distCIEDE2000 } from "@thi.ng/color"; import distance from 'euclidean-distance'; const difference = (color1, color2) => { return distCIEDE2000()( '#' + (color1.red).toString(16) + (color1.green).toString(16) + (color1.blue).toString(16), '#' + (color2.red).toString(16) + (color2.green).toString(16) + (color2.blue).toString(16), ) } console.log('lab difference') console.log('black to white', distCIEDE2000()( '#000000', '#ffffff', )) console.log('two blue hex', distCIEDE2000()( '#4287f5', '#429bf5', )) console.log('two blue rgb', difference({ red: 66, green: 135, blue: 245, }, { red: 66, green: 155, blue: 245, })) console.log('rgb difference') console.log('black to white', distance([0,0,0], [255,255,255])/4.41672956) console.log('two blues', distance([66,135,245], [66,155,245])/4.41672956) console.log('rgba difference') console.log('black to white', distance([0,0,0,255], [255,255,255,255])/4.41672956) console.log('two blues', distance([66,135,245,255], [66,155,245,125])/4.41672956) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ ▶ node test.js lab difference black to white 99.99999999999999 two blue hex 6.9116634623669375 two blue rgb 6.9116634623669375 rgb difference black to white 99.99999998416558 two blues 4.52823740469181 rgba difference black to white 99.99999998416558 two blues 29.779832021152558