@pixi/filter-adjustment
Advanced tools
Comparing version 2.7.0 to 3.0.0
/*! | ||
* @pixi/filter-adjustment - v2.7.0 | ||
* Compiled Sun, 13 Jan 2019 22:51:52 UTC | ||
* Compiled Fri, 10 May 2019 22:56:42 UTC | ||
* | ||
@@ -8,3 +8,126 @@ * @pixi/filter-adjustment is licensed under the MIT License. | ||
*/ | ||
import{Filter as r}from"pixi.js";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",n="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform float gamma;\nuniform float contrast;\nuniform float saturation;\nuniform float brightness;\nuniform float red;\nuniform float green;\nuniform float blue;\nuniform float alpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (c.a > 0.0) {\n c.rgb /= c.a;\n\n vec3 rgb = pow(c.rgb, vec3(1. / gamma));\n rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);\n rgb.r *= red;\n rgb.g *= green;\n rgb.b *= blue;\n c.rgb = rgb * brightness;\n\n c.rgb *= c.a;\n }\n\n gl_FragColor = c * alpha;\n}\n",o=function(r){function o(o){r.call(this,t,n),Object.assign(this,{gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},o)}return r&&(o.__proto__=r),o.prototype=Object.create(r&&r.prototype),o.prototype.constructor=o,o.prototype.apply=function(r,t,n,o){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,r.applyFilter(this,t,n,o)},o}(r);export{o as AdjustmentFilter}; | ||
import { Filter } from '@pixi/core'; | ||
var vertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}"; | ||
var fragment = "varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform float gamma;\nuniform float contrast;\nuniform float saturation;\nuniform float brightness;\nuniform float red;\nuniform float green;\nuniform float blue;\nuniform float alpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (c.a > 0.0) {\n c.rgb /= c.a;\n\n vec3 rgb = pow(c.rgb, vec3(1. / gamma));\n rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);\n rgb.r *= red;\n rgb.g *= green;\n rgb.b *= blue;\n c.rgb = rgb * brightness;\n\n c.rgb *= c.a;\n }\n\n gl_FragColor = c * alpha;\n}\n"; | ||
/** | ||
* The ability to adjust gamma, contrast, saturation, brightness, alpha or color-channel shift. This is a faster | ||
* and much simpler to use than {@link http://pixijs.download/release/docs/PIXI.filters.ColorMatrixFilter.html ColorMatrixFilter} | ||
* because it does not use a matrix.<br> | ||
* ![original](../tools/screenshots/dist/original.png)![filter](../tools/screenshots/dist/adjustment.png) | ||
* | ||
* @class | ||
* @extends PIXI.Filter | ||
* @memberof PIXI.filters | ||
* @see {@link https://www.npmjs.com/package/@pixi/filter-adjustment|@pixi/filter-adjustment} | ||
* @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters} | ||
* | ||
* @param {object|number} [options] - The optional parameters of the filter. | ||
* @param {number} [options.gamma=1] - The amount of luminance | ||
* @param {number} [options.saturation=1] - The amount of color saturation | ||
* @param {number} [options.contrast=1] - The amount of contrast | ||
* @param {number} [options.brightness=1] - The overall brightness | ||
* @param {number} [options.red=1] - The multipled red channel | ||
* @param {number} [options.green=1] - The multipled green channel | ||
* @param {number} [options.blue=1] - The multipled blue channel | ||
* @param {number} [options.alpha=1] - The overall alpha amount | ||
*/ | ||
var AdjustmentFilter = /*@__PURE__*/(function (Filter) { | ||
function AdjustmentFilter(options) { | ||
Filter.call(this, vertex, fragment); | ||
Object.assign(this, { | ||
/** | ||
* The amount of luminance | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
gamma: 1, | ||
/** | ||
* The amount of saturation | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
saturation: 1, | ||
/** | ||
* The amount of contrast | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
contrast: 1, | ||
/** | ||
* The amount of brightness | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
brightness: 1, | ||
/** | ||
* The amount of red channel | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
red: 1, | ||
/** | ||
* The amount of green channel | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
green: 1, | ||
/** | ||
* The amount of blue channel | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
blue: 1, | ||
/** | ||
* The amount of alpha channel | ||
* @member {number} | ||
* @memberof PIXI.filters.AdjustmentFilter# | ||
* @default 1 | ||
*/ | ||
alpha: 1, | ||
}, options); | ||
} | ||
if ( Filter ) AdjustmentFilter.__proto__ = Filter; | ||
AdjustmentFilter.prototype = Object.create( Filter && Filter.prototype ); | ||
AdjustmentFilter.prototype.constructor = AdjustmentFilter; | ||
/** | ||
* Override existing apply method in PIXI.Filter | ||
* @private | ||
*/ | ||
AdjustmentFilter.prototype.apply = function apply (filterManager, input, output, clear) { | ||
this.uniforms.gamma = Math.max(this.gamma, 0.0001); | ||
this.uniforms.saturation = this.saturation; | ||
this.uniforms.contrast = this.contrast; | ||
this.uniforms.brightness = this.brightness; | ||
this.uniforms.red = this.red; | ||
this.uniforms.green = this.green; | ||
this.uniforms.blue = this.blue; | ||
this.uniforms.alpha = this.alpha; | ||
filterManager.applyFilter(this, input, output, clear); | ||
}; | ||
return AdjustmentFilter; | ||
}(Filter)); | ||
export { AdjustmentFilter }; | ||
//# sourceMappingURL=filter-adjustment.esm.js.map |
{ | ||
"name": "@pixi/filter-adjustment", | ||
"version": "2.7.0", | ||
"main": "lib/filter-adjustment.js", | ||
"description": "PixiJS v4 filter to adjust gamma, contrast, saturation, brightness or color channels", | ||
"version": "3.0.0", | ||
"main": "lib/filter-adjustment.cjs.js", | ||
"bundle": "dist/filter-adjustment.js", | ||
"description": "PixiJS filter to adjust gamma, contrast, saturation, brightness or color channels", | ||
"author": "finscn <finscn@gmail.com>", | ||
@@ -21,11 +22,12 @@ "module": "lib/filter-adjustment.esm.js", | ||
"lib", | ||
"dist", | ||
"types.d.ts" | ||
], | ||
"peerDependencies": { | ||
"pixi.js": ">=4.5.0" | ||
"dependencies": { | ||
"@pixi/core": "^5.0.0-X" | ||
}, | ||
"devDependencies": { | ||
"@tools/fragments": "^2.0.0" | ||
"@tools/fragments": "^3.0.0" | ||
}, | ||
"gitHead": "a1329fadd2910c48842c92f254be77d971a823ca" | ||
"gitHead": "0902eca3fe476dd7dacc9330f504d8e2ade6c9bd" | ||
} |
# AdjustmentFilter | ||
PixiJS v4 filter to adjust gamma, contrast, saturation, brightness or color channels. | ||
PixiJS filter to adjust gamma, contrast, saturation, brightness or color channels. | ||
@@ -5,0 +5,0 @@ ## Installation |
/// <reference types="pixi.js" /> | ||
declare namespace PIXI.filters { | ||
class AdjustmentFilter extends PIXI.Filter<{}> { | ||
declare module "@pixi/filter-adjustment" { | ||
export class AdjustmentFilter extends PIXI.Filter { | ||
constructor(options?: AdjustmentOptions); | ||
@@ -14,3 +14,3 @@ gamma: number; | ||
} | ||
interface AdjustmentOptions { | ||
export interface AdjustmentOptions { | ||
gamma?: number; | ||
@@ -26,5 +26,1 @@ contrast?: number; | ||
} | ||
declare module "@pixi/filter-adjustment" { | ||
export = PIXI.filters; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
30726
10
278
0
1
+ Added@pixi/core@^5.0.0-X
+ Added@pixi/constants@5.3.12(transitive)
+ Added@pixi/core@5.3.12(transitive)
+ Added@pixi/math@5.3.12(transitive)
+ Added@pixi/runner@5.3.12(transitive)
+ Added@pixi/settings@5.3.12(transitive)
+ Added@pixi/ticker@5.3.12(transitive)
+ Added@pixi/utils@5.3.12(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedeventemitter3@3.1.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedurl@0.11.4(transitive)
- Removed@pixi/colord@2.9.6(transitive)
- Removed@types/css-font-loading-module@0.0.12(transitive)
- Removed@types/earcut@2.1.4(transitive)
- Removed@webgpu/types@0.1.52(transitive)
- Removed@xmldom/xmldom@0.8.10(transitive)
- Removedeventemitter3@5.0.1(transitive)
- Removedparse-svg-path@0.1.2(transitive)
- Removedpixi.js@8.6.6(transitive)