{"_id":"cyberalien-color","_rev":"3620306","name":"cyberalien-color","description":"Color library","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"cyberalien","email":"cyberalien@gmail.com"}],"time":{"modified":"2024-10-21T01:57:42.000Z","created":"2017-04-18T10:23:00.811Z","1.0.0":"2017-04-18T10:23:00.811Z"},"users":{},"author":{"name":"Vjacheslav Trushkin"},"versions":{"1.0.0":{"name":"cyberalien-color","description":"Color library","author":{"name":"Vjacheslav Trushkin"},"version":"1.0.0","license":"MIT","keywords":["color","rgb","hsl","color contrast"],"main":"src/color.js","scripts":{"pretest":"grunt test","test":"mocha tests/**/*.js","tests":"mocha tests/**/*.js","prepublish":"grunt"},"devDependencies":{"babel-cli":"*","babel-plugin-transform-es2015-arrow-functions":"*","babel-plugin-transform-es2015-destructuring":"*","babel-plugin-transform-es2015-modules-commonjs":"*","babel-plugin-transform-es2015-parameters":"*","babel-preset-es2015":"*","chai":"*","glob":"*","grunt":"*","grunt-babel":"*","grunt-contrib-clean":"*","grunt-contrib-concat":"*","grunt-contrib-uglify":"*","grunt-contrib-watch":"*","mocha":"*"},"_id":"cyberalien-color@1.0.0","_shasum":"f7f9135fe0daa1ff5b373b385be98419c264fe5e","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"cyberalien","email":"cyberalien@gmail.com"},"dist":{"shasum":"f7f9135fe0daa1ff5b373b385be98419c264fe5e","size":43381,"noattachment":false,"key":"/cyberalien-color/-/cyberalien-color-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cyberalien-color/download/cyberalien-color-1.0.0.tgz"},"maintainers":[{"name":"cyberalien","email":"cyberalien@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/cyberalien-color-1.0.0.tgz_1492510980069_0.8053768633399159"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T14:17:24.844Z","publish_time":1492510980811,"_cnpm_publish_time":1492510980811}},"readme":"# Why create yet another color library?\n\nI needed library that:\n\n* Had similar code on server side (PHP) and client side (browser).\n* Had license compatible with commercial projects.\n\nThere was no library that matched these requirements.\n\nThis library is available in 2 languages to make it usable in both client side web components and server side scripts:\n\n* PHP\n* JavaScript, usable in Node.js and in browser. Browser version has no dependencies.\n\n# Features\n\nLibrary has only 1 object: Color\n\nColor object represents color. You can:\n\n* Set or get color and color components in RGB and HSL color spaces with optional alpha channel.\n* Import/export color from/to different commonly used string formats: hexadecimal, IE hex, rgb(), hsl(), color keywords.\n* Mix colors.\n* Get luminance and calculate color contrast.\n\nClass automatically converts between color spaces when needed.\n\nCode is optimized for performance. Unusual coding style was used to make code consistent between different programming languages.\n\n# Usage\n\nHow to include library:\n\n    // For Node.js\n    const CAColor = require('cyberalien-color');\n        \n    // For browser (change path to correct url)\n    // <script src=\"./dist/color-es5.js\"></script>\n\nSample code:\n\n    var color, color2;\n        \n    // Create simple color object, get HEX string\n    color = new CAColor();\n    color.setRGB(10, 20, 30);\n    color.toHex();\n        \n    // Create color object from string\n    color = CAColor.fromString('rgba(10, 20, 30, .5)');\n    color.getRGBA();\n        \n    // Change color components in different color spaces\n    color = CAColor.fromString('#f00');\n    color.setHue(180);\n    color.toString(); // '#00ffff'\n    color.toHex(true); // '#0ff' - compressed hex string\n     \n    // Mix colors\n    color = CAColor.fromString('blue');\n    color2 = CAColor.fromString('red');\n    color.mix(color2, 50); // 50% of each color\n    color.toKeyword(); // 'purple'\n        \n    // Manipulate color spaces\n    color = CAColor.fromString('yellow');\n    color.setHue(color.getHue() + 180);\n    color.setLightness(25);\n    color.toHex(); // '#000080'\n    color.toHSLString(); // 'hsl(240, 100%, 25%)'\n    \n    // Calculate contrast between 2 colors\n    color = CAColor.fromString('yellow');\n    color2 = CAColor.fromString('darkblue');\n    color.getContrast(color2); // 14.245...\n    \n\n# Documentation\n\nDocumentation will be added later, when new website is ready.\n\nFor now you can easily figure it out by reading function names and docblocks in src/color.js or lib/color.php. \nCode is well documented.\n\nColor values use following ranges:\n* red, green, blue: 0-255\n* hue: 0-360\n* lightness, saturation: 0-100\n* alpha: 0-1\n\n# Requirements\n\nJavaScript library is written in ES6, but is compiled into ES5 code for older browsers.\n\nPHP library requires PHP 5.4 or newer version.\n\n# Compiling library\n\nTo re-compile library you need Node.js. Open Terminal or command prompt, run these commands:\n\n    npm install\n    grunt\n\nFirst command will install all necessary libraries.\nSecond command will compile libraries.\n\nIf you are having problems getting Grunt to execute, install it globally:\n\n    npm install -g grunt\n\n# Unit tests\n\nTo run tests run this command:\n\n    npm test\n\n# License\n\nThis library is licensed under MIT license. That means you can use it in both open source and commercial projects.\n","_attachments":{},"license":"MIT"}