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

@pixi/filter-crt

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/filter-crt - npm Package Compare versions

Comparing version 4.2.0 to 5.0.0

dist/filter-crt.mjs

86

dist/filter-crt.js

@@ -1,9 +0,85 @@

/*!
* @pixi/filter-crt - v4.2.0
* Compiled Fri, 05 Aug 2022 19:53:35 UTC
"use strict";/*!
* @pixi/filter-crt - v5.0.0
* Compiled Fri, 23 Sep 2022 20:48:56 UTC
*
* @pixi/filter-crt is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
var __filters=function(n,e){"use strict";var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])})(n,e)};Object.create;Object.create;var i=function(n){function e(t){var i=n.call(this,"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}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec2 dimensions;\n\nconst float SQRT_2 = 1.414213;\n\nconst float light = 1.0;\n\nuniform float curvature;\nuniform float lineWidth;\nuniform float lineContrast;\nuniform bool verticalLine;\nuniform float noise;\nuniform float noiseSize;\n\nuniform float vignetting;\nuniform float vignettingAlpha;\nuniform float vignettingBlur;\n\nuniform float seed;\nuniform float time;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n vec2 dir = vec2(vTextureCoord.xy * filterArea.xy / dimensions - vec2(0.5, 0.5));\n \n gl_FragColor = texture2D(uSampler, vTextureCoord);\n vec3 rgb = gl_FragColor.rgb;\n\n if (noise > 0.0 && noiseSize > 0.0)\n {\n pixelCoord.x = floor(pixelCoord.x / noiseSize);\n pixelCoord.y = floor(pixelCoord.y / noiseSize);\n float _noise = rand(pixelCoord * noiseSize * seed) - 0.5;\n rgb += _noise * noise;\n }\n\n if (lineWidth > 0.0)\n {\n float _c = curvature > 0. ? curvature : 1.;\n float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.;\n vec2 uv = dir * k;\n\n float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c;\n float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast;\n rgb *= j;\n float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.);\n rgb *= 0.99 + ceil(segment) * 0.015;\n }\n\n if (vignetting > 0.0)\n {\n float outter = SQRT_2 - vignetting * SQRT_2;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0);\n rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha);\n }\n\n gl_FragColor.rgb = rgb;\n}\n")||this;return i.time=0,i.seed=0,i.uniforms.dimensions=new Float32Array(2),Object.assign(i,e.defaults,t),i}return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(e,n),e.prototype.apply=function(n,e,t,i){var r=e.filterFrame,o=r.width,u=r.height;this.uniforms.dimensions[0]=o,this.uniforms.dimensions[1]=u,this.uniforms.seed=this.seed,this.uniforms.time=this.time,n.applyFilter(this,e,t,i)},Object.defineProperty(e.prototype,"curvature",{get:function(){return this.uniforms.curvature},set:function(n){this.uniforms.curvature=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return this.uniforms.lineWidth},set:function(n){this.uniforms.lineWidth=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineContrast",{get:function(){return this.uniforms.lineContrast},set:function(n){this.uniforms.lineContrast=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalLine",{get:function(){return this.uniforms.verticalLine},set:function(n){this.uniforms.verticalLine=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"noise",{get:function(){return this.uniforms.noise},set:function(n){this.uniforms.noise=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"noiseSize",{get:function(){return this.uniforms.noiseSize},set:function(n){this.uniforms.noiseSize=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vignetting",{get:function(){return this.uniforms.vignetting},set:function(n){this.uniforms.vignetting=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vignettingAlpha",{get:function(){return this.uniforms.vignettingAlpha},set:function(n){this.uniforms.vignettingAlpha=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vignettingBlur",{get:function(){return this.uniforms.vignettingBlur},set:function(n){this.uniforms.vignettingBlur=n},enumerable:!1,configurable:!0}),e.defaults={curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},e}(e.Filter);return n.CRTFilter=i,Object.defineProperty(n,"__esModule",{value:!0}),n}({},PIXI);Object.assign(PIXI.filters,__filters);
*/Object.defineProperty(exports,"__esModule",{value:!0});var l=require("@pixi/core"),a=`attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;
uniform mat3 projectionMatrix;
varying vec2 vTextureCoord;
void main(void)
{
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
vTextureCoord = aTextureCoord;
}`,g=`varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform vec4 filterArea;
uniform vec2 dimensions;
const float SQRT_2 = 1.414213;
const float light = 1.0;
uniform float curvature;
uniform float lineWidth;
uniform float lineContrast;
uniform bool verticalLine;
uniform float noise;
uniform float noiseSize;
uniform float vignetting;
uniform float vignettingAlpha;
uniform float vignettingBlur;
uniform float seed;
uniform float time;
float rand(vec2 co) {
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
void main(void)
{
vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;
vec2 dir = vec2(vTextureCoord.xy * filterArea.xy / dimensions - vec2(0.5, 0.5));
gl_FragColor = texture2D(uSampler, vTextureCoord);
vec3 rgb = gl_FragColor.rgb;
if (noise > 0.0 && noiseSize > 0.0)
{
pixelCoord.x = floor(pixelCoord.x / noiseSize);
pixelCoord.y = floor(pixelCoord.y / noiseSize);
float _noise = rand(pixelCoord * noiseSize * seed) - 0.5;
rgb += _noise * noise;
}
if (lineWidth > 0.0)
{
float _c = curvature > 0. ? curvature : 1.;
float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.;
vec2 uv = dir * k;
float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c;
float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast;
rgb *= j;
float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.);
rgb *= 0.99 + ceil(segment) * 0.015;
}
if (vignetting > 0.0)
{
float outter = SQRT_2 - vignetting * SQRT_2;
float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0);
rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha);
}
gl_FragColor.rgb = rgb;
}
`;const e=class extends l.Filter{constructor(n){super(a,g),this.time=0,this.seed=0,this.uniforms.dimensions=new Float32Array(2),Object.assign(this,e.defaults,n)}apply(n,i,r,o){const{width:s,height:u}=i.filterFrame;this.uniforms.dimensions[0]=s,this.uniforms.dimensions[1]=u,this.uniforms.seed=this.seed,this.uniforms.time=this.time,n.applyFilter(this,i,r,o)}set curvature(n){this.uniforms.curvature=n}get curvature(){return this.uniforms.curvature}set lineWidth(n){this.uniforms.lineWidth=n}get lineWidth(){return this.uniforms.lineWidth}set lineContrast(n){this.uniforms.lineContrast=n}get lineContrast(){return this.uniforms.lineContrast}set verticalLine(n){this.uniforms.verticalLine=n}get verticalLine(){return this.uniforms.verticalLine}set noise(n){this.uniforms.noise=n}get noise(){return this.uniforms.noise}set noiseSize(n){this.uniforms.noiseSize=n}get noiseSize(){return this.uniforms.noiseSize}set vignetting(n){this.uniforms.vignetting=n}get vignetting(){return this.uniforms.vignetting}set vignettingAlpha(n){this.uniforms.vignettingAlpha=n}get vignettingAlpha(){return this.uniforms.vignettingAlpha}set vignettingBlur(n){this.uniforms.vignettingBlur=n}get vignettingBlur(){return this.uniforms.vignettingBlur}};let t=e;t.defaults={curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},exports.CRTFilter=t;
//# sourceMappingURL=filter-crt.js.map

3

index.d.ts

@@ -1,2 +0,2 @@

import type { CLEAR_MODES } from '@pixi/constants';
import type { CLEAR_MODES } from '@pixi/core';
import { Filter } from '@pixi/core';

@@ -12,3 +12,2 @@ import type { FilterSystem } from '@pixi/core';

* @extends PIXI.Filter
* @memberof PIXI.filters
* @see {@link https://www.npmjs.com/package/@pixi/filter-crt|@pixi/filter-crt}

@@ -15,0 +14,0 @@ * @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters}

{
"name": "@pixi/filter-crt",
"version": "4.2.0",
"main": "dist/filter-crt.cjs.js",
"bundle": "dist/filter-crt.js",
"version": "5.0.0",
"main": "./dist/filter-crt.js",
"description": "PixiJS filter to apply an effect resembling old CRT monitors",
"author": "finscn <finscn@gmail.com>",
"module": "dist/filter-crt.esm.mjs",
"module": "./dist/filter-crt.mjs",
"exports": {
".": {
"import": "./dist/filter-crt.esm.mjs",
"require": "./dist/filter-crt.cjs.js",
"import": "./dist/filter-crt.mjs",
"require": "./dist/filter-crt.js",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"types": "./index.d.ts",
"homepage": "http://pixijs.com/",

@@ -33,13 +32,9 @@ "bugs": "https://github.com/pixijs/filters/issues",

"peerDependencies": {
"@pixi/constants": "^6.0.0",
"@pixi/core": "^6.0.0",
"@pixi/math": "^6.0.0"
"@pixi/core": "^7.0.0-X"
},
"devDependencies": {
"@pixi/constants": "^6.0.0",
"@pixi/core": "^6.0.0",
"@pixi/math": "^6.0.0",
"@tools/fragments": "4.1.3"
"@pixi/core": "^7.0.0-X",
"@tools/fragments": "5.0.0"
},
"gitHead": "dc16782d00fffb8c02d30cc32146d9c6a40599cb"
"gitHead": "2bec8c5024e4086e5aada8e471820bddc8ede687"
}

@@ -23,2 +23,2 @@ # CRTFilter

See https://pixijs.github.io/pixi-filters/docs
See https://filters.pixijs.download/main/docs/CRTFilter.html

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