Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

color-forge

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-forge - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

12

doc.md

@@ -44,2 +44,3 @@ ## Classes

* [.burn(other)](#Color#burn)
* [.exponent(power)](#Color#exponent)
* _static_

@@ -249,2 +250,13 @@ * [.spaces](#Color.spaces)

<a name="Color#exponent"></a>
### color.exponent(power)
Returns a new color that is the result of raising each power to an exponent.
The resulting color has channels clipped at a maximum of 255.
**Kind**: instance method of <code>[Color](#Color)</code>
| Param | Type | Description |
| --- | --- | --- |
| power | <code>number</code> | The power to raise each channel by |
<a name="Color.spaces"></a>

@@ -251,0 +263,0 @@ ### Color.spaces

18

index.js

@@ -386,5 +386,21 @@ 'use strict';

});
/**
Returns a new color that is the result of raising each power to an exponent.
The resulting color has channels clipped at a maximum of 255.
@function
@param {number} power - The power to raise each channel by
*/
Color.prototype.exponent = function exponent(power) {
var values = this.convert('rgb').values.map(function(value) {
return Math.min(Math.pow(value / 255, power), 255) * 255;
});
var alpha = Math.pow(this.alpha, power);
return new Color(values, alpha, 'rgb');
};
/**

@@ -570,3 +586,3 @@ Available spaces for colors. Check`color-space` to ensure up-to-dateness. Note

return new Color(values, alpha);
return new Color(values, alpha, 'rgb');
};

@@ -573,0 +589,0 @@ }

2

package.json
{
"name": "color-forge",
"version": "1.0.4",
"version": "1.0.5",
"description": "A simple color system based on the work of https://github.com/dfcreative/color-space",

@@ -5,0 +5,0 @@ "url": "https://github.com/jacobp100/color-forge",

@@ -110,2 +110,7 @@ /* eslint-env node, mocha */

});
it('Should raise to exponents', function() {
assert.about(Color.hex('#111').exponent(2), Color.hex('#010101'));
assert.about(Color.hex('#888').exponent(2), Color.hex('#494949'));
assert.about(Color.hex('#fff').exponent(2), Color.hex('#ffffff'));
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc