Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include Addition (Add) blending mode + Officially drop support for Node 8 #904

Merged
merged 4 commits into from Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
110 changes: 55 additions & 55 deletions packages/core/package.json
@@ -1,56 +1,56 @@
{
"name": "@jimp/core",
"version": "0.13.0",
"description": "Jimp core",
"main": "dist/index.js",
"module": "es/index.js",
"types": "types/index.d.ts",
"files": [
"dist",
"es",
"index.d.ts",
"fonts",
"types"
],
"repository": {
"type": "git",
"url": "https://github.com/oliver-moran/jimp.git"
},
"bugs": {
"url": "https://github.com/oliver-moran/jimp/issues"
},
"scripts": {
"test": "cross-env BABEL_ENV=test mocha --require @babel/register test/**/*.js",
"test:watch": "npm run test -- --reporter min --watch",
"test:coverage": "nyc npm run test",
"build": "npm run build:node:production && npm run build:module",
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
"build:debug": "npm run build:node:debug",
"build:module": "cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js",
"build:node": "babel src -d dist --source-maps --config-file ../../babel.config.js",
"build:node:debug": "cross-env BABEL_ENV=development npm run build:node",
"build:node:production": "cross-env BABEL_ENV=production npm run build:node"
},
"author": "Oliver Moran <oliver.moran@gmail.com>",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"any-base": "^1.1.0",
"buffer": "^5.2.0",
"exif-parser": "^0.1.12",
"file-type": "^9.0.0",
"load-bmfont": "^1.3.1",
"mkdirp": "^0.5.1",
"phin": "^2.9.1",
"pixelmatch": "^4.0.2",
"tinycolor2": "^1.4.1"
},
"devDependencies": {
"should": "^13.2.3"
},
"xo": false,
"publishConfig": {
"access": "public"
}
}
"name": "@jimp/core",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert changes to this file please

"version": "0.14.0",
"description": "Jimp core",
"main": "dist/index.js",
"module": "es/index.js",
"types": "types/index.d.ts",
"files": [
"dist",
"es",
"index.d.ts",
"fonts",
"types"
],
"repository": {
"type": "git",
"url": "https://github.com/oliver-moran/jimp.git"
},
"bugs": {
"url": "https://github.com/oliver-moran/jimp/issues"
},
"scripts": {
"test": "cross-env BABEL_ENV=test mocha --require @babel/register test/**/*.js",
"test:watch": "npm run test -- --reporter min --watch",
"test:coverage": "nyc npm run test",
"build": "npm run build:node:production && npm run build:module",
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
"build:debug": "npm run build:node:debug",
"build:module": "cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js",
"build:node": "babel src -d dist --source-maps --config-file ../../babel.config.js",
"build:node:debug": "cross-env BABEL_ENV=development npm run build:node",
"build:node:production": "cross-env BABEL_ENV=production npm run build:node"
},
"author": "Oliver Moran <oliver.moran@gmail.com>",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "link:../utils",
"any-base": "^1.1.0",
"buffer": "^5.2.0",
"exif-parser": "^0.1.12",
"file-type": "^9.0.0",
"load-bmfont": "^1.3.1",
"mkdirp": "^0.5.1",
"phin": "^2.9.1",
"pixelmatch": "^4.0.2",
"tinycolor2": "^1.4.1"
},
"devDependencies": {
"should": "^13.2.3"
},
"xo": false,
"publishConfig": {
"access": "public"
}
}
20 changes: 20 additions & 0 deletions packages/core/src/composite/composite-modes.js
Expand Up @@ -42,6 +42,26 @@ export function multiply(src, dst, ops = 1) {
return { r, g, b, a };
}

export function add(src, dst, ops = 1) {
src.a *= ops;

const a = dst.a + src.a - dst.a * src.a;

const sra = src.r * src.a;
const sga = src.g * src.a;
const sba = src.b * src.a;

const dra = dst.r * dst.a;
const dga = dst.g * dst.a;
const dba = dst.b * dst.a;

const r = (sra + dra) / a;
const g = (sga + dga) / a;
const b = (sba + dba) / a;

return { r, g, b, a };
}

export function screen(src, dst, ops = 1) {
src.a *= ops;

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/constants.js
Expand Up @@ -14,6 +14,7 @@ export const VERTICAL_ALIGN_BOTTOM = 32;
export const BLEND_SOURCE_OVER = 'srcOver';
export const BLEND_DESTINATION_OVER = 'dstOver';
export const BLEND_MULTIPLY = 'multiply';
export const BLEND_ADD = 'add';
export const BLEND_SCREEN = 'screen';
export const BLEND_OVERLAY = 'overlay';
export const BLEND_DARKEN = 'darken';
Expand Down
1 change: 1 addition & 0 deletions packages/core/types/jimp.d.ts
Expand Up @@ -30,6 +30,7 @@ export interface JimpConstructors {
BLEND_SOURCE_OVER: string;
BLEND_DESTINATION_OVER: string;
BLEND_MULTIPLY: string;
BLEND_ADD: string;
BLEND_SCREEN: string;
BLEND_OVERLAY: string;
BLEND_DARKEN: string;
Expand Down
1 change: 1 addition & 0 deletions packages/jimp/README.md
Expand Up @@ -344,6 +344,7 @@ The following modes can be used for compositing two images together. mode defaul
Jimp.BLEND_SOURCE_OVER;
Jimp.BLEND_DESTINATION_OVER;
Jimp.BLEND_MULTIPLY;
Jimp.BLEND_ADD;
Jimp.BLEND_SCREEN;
Jimp.BLEND_OVERLAY;
Jimp.BLEND_DARKEN;
Expand Down