Skip to content

Commit

Permalink
v0.1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskr committed Jun 6, 2020
1 parent 18aa3e4 commit a9e49d6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
70 changes: 37 additions & 33 deletions package.json
@@ -1,15 +1,39 @@
{
"name": "color-interfaces",
"version": "0.1.2",
"author": "chriskr",
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
]
},
"bugs": {
"url": "https://github.com/chriskr/color-interfaces/issues"
},
"description": "interfaces for color spaces",
"repository": "https://github.com/chriskr/color-interfaces",
"main": "dist/index.js",
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"coveralls": "^3.1.0",
"cross-env": "^7.0.2",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"ts-loader": "^7.0.4",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.9.2",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"files": [
"dist"
],
"types": "dist/index.d.ts",
"author": "chrisk",
"license": "MIT",
"homepage": "https://github.com/chriskr/color-interfaces",
"keywords": [
"color",
"color space",
Expand All @@ -24,6 +48,10 @@
"hex",
"hexa"
],
"license": "MIT",
"main": "dist/index.js",
"name": "color-interfaces",
"repository": "https://github.com/chriskr/color-interfaces",
"scripts": {
"watch": "cross-env NODE_ENV=development webpack -w --mode development --display-error-details",
"build": "cross-env NODE_ENV=production webpack --mode production",
Expand All @@ -35,30 +63,6 @@
"version": "npm run format --scripts-prepend-node-path && git add -A src",
"postversion": "git push && git push --tags"
},
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"coveralls": "^3.1.0",
"cross-env": "^7.0.2",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"ts-loader": "^7.0.4",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.9.2",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
]
}
"types": "dist/index.d.ts",
"version": "0.1.22"
}
12 changes: 7 additions & 5 deletions src/Color.ts
Expand Up @@ -228,11 +228,13 @@ class Color implements Color_ {

// http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
getLuminance() {
const rgb = this.rgb.get().map((c: number) => {
const cs = c / 255;
return cs <= 0.03928 ? cs / 12.92 : Math.pow((cs + 0.055) / 1.055, 2.4);
});
return 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2];
const [r, g, b] = this.rgb
.get()
.map((c: number) => c / 255)
.map((c: number) =>
c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4),
);
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
}

// http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
Expand Down

0 comments on commit a9e49d6

Please sign in to comment.