Update 'palette-gen.js'
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| #!/bin/nodejs | #!/bin/nodejs | ||||||
|  |  | ||||||
| const componentToHex = (c) => ("0" + c.toString(16)).slice(-2); | const componentToHex = (c) => ("0" + c.toString(16)).slice(-2); | ||||||
| const rgbToHex = (c) =>  "#" + componentToHex(c.r) + componentToHex(c.g) + componentToHex(c.b); | const rgbToHex = (c) => componentToHex(c.r) + componentToHex(c.g) + componentToHex(c.b); | ||||||
| const hexToRgb = (hex) => { | const hexToRgb = (hex) => { | ||||||
|     const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); |     const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | ||||||
|     return result ? { |     return result ? { | ||||||
| @@ -31,5 +31,5 @@ const rl = readline.createInterface({ | |||||||
| }); | }); | ||||||
|  |  | ||||||
| rl.on('line', (line) => { | rl.on('line', (line) => { | ||||||
|     console.log(parseScheme(line).map(e=>genPalette(e).map(c=>rgbToHex(c)))); |     console.log(parseScheme(line).map(e=>genPalette(e).map(c=>rgbToHex(c))).join(",")); | ||||||
| }); | }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user