Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
cyberalien-color
Advanced tools
I needed library that:
There was no library that matched these requirements.
This library is available in 2 languages to make it usable in both client side web components and server side scripts:
Library has only 1 object: Color
Color object represents color. You can:
Class automatically converts between color spaces when needed.
Code is optimized for performance. Unusual coding style was used to make code consistent between different programming languages.
How to include library:
// For Node.js
const CAColor = require('cyberalien-color');
// For browser (change path to correct url)
// <script src="./dist/color-es5.js"></script>
Sample code:
var color, color2;
// Create simple color object, get HEX string
color = new CAColor();
color.setRGB(10, 20, 30);
color.toHex();
// Create color object from string
color = CAColor.fromString('rgba(10, 20, 30, .5)');
color.getRGBA();
// Change color components in different color spaces
color = CAColor.fromString('#f00');
color.setHue(180);
color.toString(); // '#00ffff'
color.toHex(true); // '#0ff' - compressed hex string
// Mix colors
color = CAColor.fromString('blue');
color2 = CAColor.fromString('red');
color.mix(color2, 50); // 50% of each color
color.toKeyword(); // 'purple'
// Manipulate color spaces
color = CAColor.fromString('yellow');
color.setHue(color.getHue() + 180);
color.setLightness(25);
color.toHex(); // '#000080'
color.toHSLString(); // 'hsl(240, 100%, 25%)'
// Calculate contrast between 2 colors
color = CAColor.fromString('yellow');
color2 = CAColor.fromString('darkblue');
color.getContrast(color2); // 14.245...
Documentation will be added later, when new website is ready.
For now you can easily figure it out by reading function names and docblocks in src/color.js or lib/color.php. Code is well documented.
Color values use following ranges:
JavaScript library is written in ES6, but is compiled into ES5 code for older browsers.
PHP library requires PHP 5.4 or newer version.
To re-compile library you need Node.js. Open Terminal or command prompt, run these commands:
npm install
grunt
First command will install all necessary libraries. Second command will compile libraries.
If you are having problems getting Grunt to execute, install it globally:
npm install -g grunt
To run tests run this command:
npm test
This library is licensed under MIT license. That means you can use it in both open source and commercial projects.
FAQs
Color library
The npm package cyberalien-color receives a total of 435 weekly downloads. As such, cyberalien-color popularity was classified as not popular.
We found that cyberalien-color demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.