First commit.
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
/node_modules
 | 
			
		||||
							
								
								
									
										31
									
								
								colorgen.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								colorgen.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
#!/usr/bin/env node
 | 
			
		||||
import { program } from 'commander';
 | 
			
		||||
import tinycolor from 'tinycolor2';
 | 
			
		||||
 | 
			
		||||
program.command('gen <color>')
 | 
			
		||||
    .description('Generates multiple colors from a given color')
 | 
			
		||||
    .option('-a, --amount <n>', 'Amount of darken', 10)
 | 
			
		||||
    .action((color, options) => {
 | 
			
		||||
        const primary = tinycolor(color);
 | 
			
		||||
        const amount = options.amount;
 | 
			
		||||
 | 
			
		||||
        logColor(primary, 'primary');
 | 
			
		||||
        const darkPrimary = primary.clone().darken(amount);
 | 
			
		||||
        logColor(darkPrimary, 'dark primary');
 | 
			
		||||
        const darkerPrimary = darkPrimary.clone().darken(amount);
 | 
			
		||||
        logColor(darkerPrimary, 'darker primary');
 | 
			
		||||
 | 
			
		||||
        const secondary = primary.complement();
 | 
			
		||||
        logColor(secondary, 'secondary');
 | 
			
		||||
        const darkSecondary = secondary.clone().darken(amount);
 | 
			
		||||
        logColor(darkSecondary, 'dark secondary');
 | 
			
		||||
        const darkerSecondary = darkSecondary.clone().darken(amount);
 | 
			
		||||
        logColor(darkerSecondary, 'darker secondary');
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
program.parse(process.argv);
 | 
			
		||||
 | 
			
		||||
function logColor(color, name) {
 | 
			
		||||
    const { r, g, b } = color.toRgb()
 | 
			
		||||
    console.log(`\x1b[48;2;${r};${g};${b}m COLOR \x1b[0m [${name.toUpperCase()}] ${color.toHexString()} `);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										33
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "colorgen",
 | 
			
		||||
  "version": "0.1.0",
 | 
			
		||||
  "lockfileVersion": 3,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "name": "colorgen",
 | 
			
		||||
      "version": "0.1.0",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "commander": "^10.0.0",
 | 
			
		||||
        "tinycolor2": "^1.6.0"
 | 
			
		||||
      },
 | 
			
		||||
      "bin": {
 | 
			
		||||
        "colorgen": "colorgen.js"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/commander": {
 | 
			
		||||
      "version": "10.0.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz",
 | 
			
		||||
      "integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==",
 | 
			
		||||
      "engines": {
 | 
			
		||||
        "node": ">=14"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/tinycolor2": {
 | 
			
		||||
      "version": "1.6.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",
 | 
			
		||||
      "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw=="
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@midefos/colorgen",
 | 
			
		||||
  "type": "module",
 | 
			
		||||
  "version": "0.1.0",
 | 
			
		||||
  "description": "Color generator",
 | 
			
		||||
  "bin": {
 | 
			
		||||
    "colorgen": "./colorgen.js"
 | 
			
		||||
  },
 | 
			
		||||
  "author": "Midefos",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "commander": "^10.0.0",
 | 
			
		||||
    "tinycolor2": "^1.6.0"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user