Skip to content

Instantly share code, notes, and snippets.

View olehmelnyk's full-sized avatar
👻

Oleh Melnyk olehmelnyk

👻
  • Lviv, Ukraine
  • 18:04 (UTC +02:00)
View GitHub Profile
@olehmelnyk
olehmelnyk / rgbToPantone.js
Created December 30, 2017 17:47
Parsing 3rd party website for RGB to Pantone
/**
* Parsing 3rd party website
* not sure how accurate/valid/outdated it is
* and this resource might be closed any time
* but https://github.com/teelaunch/pms-pantone-color-chart
* uses this site here https://github.com/teelaunch/pms-pantone-color-chart/blob/master/pantone.js#L9
* */
async function rgbToPantone(RGB){
return fetch(`http://www.netfront.fr/Services/rgb2pantone/pantone.htm?r=${RGB[0]}&g=${RGB[1]}&b=${RGB[2]}`)
.then(resolve => resolve.text())
@olehmelnyk
olehmelnyk / pantone.js
Created December 30, 2017 17:44
get HEX/RGB/CMYK by Pantone code (parse official Pantone website search result)
// get HEX/RGB/CMYK by Pantone code (parse official Pantone website search result)
async function pantone(pantoneCode){
pantoneCode = pantoneCode // validate input:
.trim()
.replace(/^PANTONE /i, '') // we don't need 'PANTONE ' here
.replace(/ /g, '-'); // no spaces
return fetch(`https://www.pantone.com/color-finder/${pantoneCode}`)
.then(response => response.text())
.then(doc => new DOMParser().parseFromString(doc, 'text/html'))