@thi.ng/pixel
Advanced tools
Comparing version 0.3.6 to 0.4.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/pixel@0.3.6...@thi.ng/pixel@0.4.0) (2020-07-22) | ||
### Features | ||
* **pixel:** add flipY() ([a5593c0](https://github.com/thi-ng/umbrella/commit/a5593c06a6ae61eccb9ecbaa4b3828ce0b29fbc0)) | ||
## [0.3.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/pixel@0.3.5...@thi.ng/pixel@0.3.6) (2020-07-17) | ||
@@ -8,0 +19,0 @@ |
@@ -36,4 +36,8 @@ import { Fn, NumericArray } from "@thi.ng/api"; | ||
clampChannel(id: number): void; | ||
/** | ||
* Flips image vertically. | ||
*/ | ||
flipY(): this; | ||
protected ensureFormat(dest: FloatBuffer): void; | ||
} | ||
//# sourceMappingURL=float.d.ts.map |
13
float.js
@@ -171,2 +171,15 @@ import { assert } from "@thi.ng/api"; | ||
} | ||
/** | ||
* Flips image vertically. | ||
*/ | ||
flipY() { | ||
const { pixels, rowStride } = this; | ||
const tmp = new Float32Array(rowStride); | ||
for (let i = 0, j = pixels.length - rowStride; i < j; i += rowStride, j -= rowStride) { | ||
tmp.set(pixels.subarray(i, i + rowStride)); | ||
pixels.copyWithin(i, j, j + rowStride); | ||
pixels.set(tmp, j); | ||
} | ||
return this; | ||
} | ||
ensureFormat(dest) { | ||
@@ -173,0 +186,0 @@ assert(dest.format === this.format, `dest buffer format must be same as src`); |
@@ -688,2 +688,12 @@ 'use strict'; | ||
} | ||
flipY() { | ||
const { pixels, width } = this; | ||
const tmp = new CTORS[this.format.type](width); | ||
for (let i = 0, j = pixels.length - width; i < j; i += width, j -= width) { | ||
tmp.set(pixels.subarray(i, i + width)); | ||
pixels.copyWithin(i, j, j + width); | ||
pixels.set(tmp, j); | ||
} | ||
return this; | ||
} | ||
} | ||
@@ -847,2 +857,12 @@ | ||
} | ||
flipY() { | ||
const { pixels, rowStride } = this; | ||
const tmp = new Float32Array(rowStride); | ||
for (let i = 0, j = pixels.length - rowStride; i < j; i += rowStride, j -= rowStride) { | ||
tmp.set(pixels.subarray(i, i + rowStride)); | ||
pixels.copyWithin(i, j, j + rowStride); | ||
pixels.set(tmp, j); | ||
} | ||
return this; | ||
} | ||
ensureFormat(dest) { | ||
@@ -849,0 +869,0 @@ api.assert(dest.format === this.format, `dest buffer format must be same as src`); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/checks"),require("@thi.ng/api"),require("@thi.ng/math"),require("@thi.ng/porter-duff")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/checks","@thi.ng/api","@thi.ng/math","@thi.ng/porter-duff"],e):e(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.pixel={}),t.thi.ng.checks,t.thi.ng.api,t.thi.ng.math,t.thi.ng.porterDuff)}(this,(function(t,e,s,i,n){"use strict";var r,a,h;(r=t.Lane||(t.Lane={}))[r.ALPHA=0]="ALPHA",r[r.BLUE=1]="BLUE",r[r.GREEN=2]="GREEN",r[r.RED=3]="RED",(a=t.Wrap||(t.Wrap={}))[a.NONE=0]="NONE",a[a.U=1]="U",a[a.V=2]="V",a[a.UV=3]="UV",(h=t.Filter||(t.Filter={}))[h.NEAREST=0]="NEAREST",h[h.LINEAR=1]="LINEAR";const l=(t,e=t,s)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,s&&s.appendChild(i),{canvas:i,ctx:i.getContext("2d")}};function o(t,s){let i,n;if(e.isNumber(t)){const e=l(t,s);i=e.canvas,n=e.ctx}else i=t,n=i.getContext("2d");const r=n.getImageData(0,0,i.width,i.height);return{canvas:i,ctx:n,img:r,pixels:new Uint32Array(r.data.buffer)}}const c=(t,s,i=s,n)=>{const r=e.isNumber(s)?l(s,i,n):l(t.width,t.height,n);return r.ctx.drawImage(t,0,0,r.canvas.width,r.canvas.height),r},f=(t,e,i,n=1)=>s.assert(t.length>=e*i*n,"pixel buffer too small"),p=(t,e)=>{const i=t.channels[e];return s.assert(null!=i,"invalid channel ID: "+e),i},u=t=>(29*(t>>>16&255)+150*(t>>>8&255)+76*(255&t))/255,m=(t,e,s,n,r,a,h=0,l=0)=>(s|=0,n|=0,(t|=0)<0&&(s+=t,h-=t,t=0),(e|=0)<0&&(n+=e,l-=e,e=0),[t,e,i.clamp(s,0,r-t),i.clamp(n,0,a-e),h,l]),A=(t,e,s={})=>{let i,n,r,a,h,l,o=t.width,c=e.width;return[i,n,h,l]=m(s.sx||0,s.sy||0,s.w||o,s.h||t.height,o,t.height),[r,a,h,l,i,n]=m(s.dx||0,s.dy||0,h,l,c,e.height,i,n),{sx:i,sy:n,dx:r,dy:a,rw:h,rh:l}},d=(t,e,s)=>{for(let i=t.length;--i>=0;)t[i]=s(t[i],e)},g=(t,e,s,i)=>{for(let n=t.length;--n>=0;)t[n]=i(t[n],s(e[n]))},R=(t,e,s,i,n)=>{const r=~n;for(let a=t.length;--a>=0;)t[a]=t[a]&r|s(i(e[a]))&n},x=(t,e,s)=>{const i=e.fromABGR,n=e.toABGR;for(let e=t.length;--e>=0;)t[e]=i(s(n(t[e])))},y=(t,e)=>e>0?`(${t} << ${e})`:e<0?`(${t} >>> ${-e})`:""+t,w=(t,e)=>y(t,-e),G=t=>"0x"+t.toString(16),L=t=>{const e=(1<<t)-1;return new Function("luma",`return (x) => ${w("luma(x)",8-t)} & ${e};`)(u)},B=t=>{let e;if(8!==t){const s=(1<<t)-1;e=`(((x & ${s}) * ${255/s}) | 0)`}else e="x";return new Function("x",`return 0xff000000 | (${e} * 0x010101);`)},z=t=>new Function("x","return ("+t.map(t=>{const e=t.abgrShift+(8-t.size);return`(${w("x",e)} & ${G(t.maskA)})`}).join(" | ")+") >>> 0;"),E=(t,e)=>{const s=t.map(t=>{if(8!==t.size){const e=t.mask0,s=255/e,i=w("x",t.shift);return y(`((${i} & ${e}) * ${s})`,24-8*t.lane)}return y(`(x & ${G(t.maskA)})`,t.abgrShift)}).join(" | ");return new Function("x",`return (${e?"":"0xff000000 | "}${s}) >>> 0;`)},U=(t,e,s,i,n,r)=>{if(1===s)return!r[e]&&(r[e]=[]),r[e][t]=i,r;const a=n<<2;return U(t,e,s>>=1,i,a,r),U(t+s,e+s,s,i+n,a,r),U(t+s,e,s,i+2*n,a,r),U(t,e+s,s,i+3*n,a,r),r},b=t=>({mat:U(0,0,t,0,1,[]),invSize:1/(t*t),mask:t-1}),D=({mat:t,mask:e,invSize:s},n,r,a,h,l,o)=>(o=n*(o/a)+t[l&e][h&e]*s-.5|0,n--,i.clamp(o,0,n)*((r-1)/n)),T=t=>{s.assert(t.channels.length>0,"no channel specs given");const e=t.channels.reduce(([t,e],s,n)=>(e-=s.size,t.push(((t,e,s)=>{const n=1<<t.size,r=n-1,a=r<<s>>>0,h=~a>>>0,l=null!=t.lane?t.lane:e,o=t=>t>>>s&r,c=(t,e)=>t&h|(e&r)<<s;return{size:t.size,abgrShift:24-8*l-s,lane:l,shift:s,mask0:r,maskA:a,int:o,setInt:c,float:t=>o(t)/r,setFloat:(t,e)=>c(t,i.clamp01(e)*r),dither:(t,e,s,i,r)=>D(t,e,n,n,s,i,r)}})(s,n,e)),[t,e]),[[],t.size])[0];return{__packed:!0,type:t.type,size:t.size,alpha:t.alpha||0,channels:e,fromABGR:t.fromABGR||z(e),toABGR:t.toABGR||E(e,!!t.alpha)}},N=T({type:s.Type.U8,size:8,alpha:8,channels:[{size:8,lane:0}]}),C=T({type:s.Type.U8,size:8,channels:[{size:8,lane:t.Lane.RED}],fromABGR:t=>u(t),toABGR:t=>(4278190080|65793*(255&t))>>>0}),F=T({type:s.Type.U16,size:16,alpha:8,channels:[{size:8,lane:t.Lane.ALPHA},{size:8,lane:t.Lane.RED}],fromABGR:t=>u(t)|t>>>16&65280,toABGR:t=>((65280&t)<<16|65793*(255&t))>>>0}),P=T({type:s.Type.U16,size:16,channels:[{size:16,lane:t.Lane.RED}],fromABGR:t=>257*(u(t)+.5|0),toABGR:t=>(4278190080|65793*(t>>>8))>>>0}),v=T({type:s.Type.U32,size:32,channels:[{size:8,lane:t.Lane.ALPHA},{size:16,lane:t.Lane.RED}],fromABGR:t=>257*(u(t)+.5|0)|257*(t>>>8&16711680),toABGR:t=>(4278190080&t|65793*(t>>>8&255))>>>0}),I=T({type:s.Type.U16,size:16,channels:[{size:5,lane:t.Lane.RED},{size:6,lane:t.Lane.GREEN},{size:5,lane:t.Lane.BLUE}]}),S=T({type:s.Type.U16,size:16,alpha:1,channels:[{size:1,lane:t.Lane.ALPHA},{size:5,lane:t.Lane.RED},{size:5,lane:t.Lane.GREEN},{size:5,lane:t.Lane.BLUE}]}),k=T({type:s.Type.U16,size:16,alpha:4,channels:[{size:4,lane:t.Lane.ALPHA},{size:4,lane:t.Lane.RED},{size:4,lane:t.Lane.GREEN},{size:4,lane:t.Lane.BLUE}]}),$=T({type:s.Type.U32,size:24,channels:[{size:8,lane:t.Lane.RED},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.BLUE}]}),_=T({type:s.Type.U32,size:32,alpha:8,channels:[{size:8,lane:t.Lane.ALPHA},{size:8,lane:t.Lane.RED},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.BLUE}]}),H=T({type:s.Type.U32,size:24,channels:[{size:8,lane:t.Lane.BLUE},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.RED}],fromABGR:t=>16777215&t,toABGR:t=>4278190080|t}),O=T({type:s.Type.U32,size:32,alpha:8,channels:[{size:8,lane:t.Lane.ALPHA},{size:8,lane:t.Lane.BLUE},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.RED}],fromABGR:t=>t,toABGR:t=>t}),j=e=>{const s=e.channels,i=s.reduce((t,e)=>(t[e]=3-e<<3,t),{}),n=Object.assign(Object.assign({},e),{size:s.length,shift:i,__float:!0}),r=(t,e)=>(255*t[e]+.5|0)<<i[s[e]],a=(t,e)=>(t>>>i[s[e]]&255)/255;switch(s.length){case 1:e.gray?(n.toABGR=t=>(65793*(255*t[0]+.5|0)|4278190080)>>>0,n.fromABGR=(t,e=[])=>(e[0]=u(t)/255,e)):(n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e));break;case 2:if(e.gray){const e=~~(s[0]===t.Lane.ALPHA),i=1^e;n.toABGR=t=>{let s=65793*(255*t[e]+.5|0);return s|=(255*t[i]+.5|0)<<24,s>>>0},n.fromABGR=(t,s=[])=>(s[e]=u(t)/255,s[i]=a(t,i),s)}else n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s|=r(t,1),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e[1]=a(t,1),e);break;case 3:n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s|=r(t,1),s|=r(t,2),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e[1]=a(t,1),e[2]=a(t,2),e);break;case 4:n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s|=r(t,1),s|=r(t,2),s|=r(t,3),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e[1]=a(t,1),e[2]=a(t,2),e[3]=a(t,3),e)}return n},Y=j({gray:!0,channels:[t.Lane.RED]}),q=j({gray:!0,alpha:!0,channels:[t.Lane.RED,t.Lane.ALPHA]}),V=j({channels:[t.Lane.RED,t.Lane.GREEN,t.Lane.BLUE]}),M=j({alpha:!0,channels:[t.Lane.RED,t.Lane.GREEN,t.Lane.BLUE,t.Lane.ALPHA]}),W={[s.Type.U8]:Uint8Array,[s.Type.U16]:Uint16Array,[s.Type.U32]:Uint32Array};class J{constructor(t,e,s,i){this.width=t,this.height=e,this.format=s.__packed?s:T(s),this.pixels=i||new W[s.type](t*e)}static fromImage(t,e,s,i=s){const n=c(t,s,i),r=n.canvas.width,a=n.canvas.height,h=new Uint32Array(n.ctx.getImageData(0,0,r,a).data.buffer),l=new W[e.type](r*a),o=e.fromABGR;for(let t=l.length;--t>=0;)l[t]=o(h[t]);return new J(r,a,e,l)}static fromCanvas(t){return new J(t.width,t.height,O,o(t).pixels)}as(t){return this.getRegion(0,0,this.width,this.height,t)}copy(){const t=new J(this.width,this.height,this.format);return t.pixels.set(this.pixels),t}getAt(t,e){return t>=0&&t<this.width&&e>=0&&e<this.height?this.pixels[(0|t)+(0|e)*this.width]:0}setAt(t,e,s){return t>=0&&t<this.width&&e>=0&&e<this.height&&(this.pixels[(0|t)+(0|e)*this.width]=s),this}getChannelAt(t,e,s,i=!1){const n=p(this.format,s),r=this.getAt(t,e);return i?n.float(r):n.int(r)}setChannelAt(t,e,s,i,n=!1){const r=p(this.format,s),a=this.getAt(t,e);return n?r.setFloat(a,i):r.setInt(a,i),this}blend(t,e,s){let i=this.width,n=e.width;const{sx:r,sy:a,dx:h,dy:l,rw:o,rh:c}=A(this,e,s);if(o<1||c<1)return e;const f=this.pixels,p=e.pixels,u=this.format.toABGR,m=e.format.toABGR,d=e.format.fromABGR;for(let e=(0|r)+(0|a)*i,s=(0|h)+(0|l)*n,A=0;A<c;A++,e+=i,s+=n)for(let i=0;i<o;i++)p[s+i]=d(t(u(f[e+i]),m(p[s+i])));return e}blit(t,e){let s=this.width,i=t.width;const{sx:n,sy:r,dx:a,dy:h,rw:l,rh:o}=A(this,t,e);if(l<1||o<1)return t;const c=this.pixels,f=t.pixels,p=this.format.toABGR,u=t.format.fromABGR,m=this.format!==t.format?(t,e)=>{for(let s=0;s<l;s++)f[e+s]=u(p(c[t+s]))}:(t,e)=>f.set(c.subarray(t,t+l),e);for(let t=(0|n)+(0|r)*s,e=(0|a)+(0|h)*i,l=0;l<o;l++,t+=s,e+=i)m(t,e);return t}blitCanvas(t,e=0,s=0){const i=t.getContext("2d"),n=new ImageData(this.width,this.height),r=new Uint32Array(n.data.buffer),a=this.pixels,h=this.format.toABGR;for(let t=r.length;--t>=0;)r[t]=h(a[t]);return i.putImageData(n,e,s),t}getRegion(t,e,s,i,n){const[r,a,h,l]=m(t,e,s,i,this.width,this.height);return this.blit(new J(h,l,n||this.format),{sx:r,sy:a,w:h,h:l})}getChannel(e){const i=p(this.format,e),n=new J(this.width,this.height,{type:i.size>16?s.Type.U32:i.size>8?s.Type.U16:s.Type.U8,size:i.size,channels:[{size:i.size,lane:t.Lane.RED}],fromABGR:L(i.size),toABGR:B(i.size)}),r=this.pixels,a=n.pixels,h=i.int;for(let t=r.length;--t>=0;)a[t]=h(r[t]);return n}setChannel(t,s){const i=p(this.format,t),n=this.pixels,r=i.setInt;if(e.isNumber(s))d(n,s,r);else{const t=s.pixels,e=s.format.channels[0];f(t,this.width,this.height),i.size===e.size?g(n,t,e.int,r):R(n,t,this.format.fromABGR,s.format.toABGR,i.maskA)}return this}invert(){const t=this.pixels,e=this.format,s=Math.pow(2,e.size-e.alpha)-1;for(let e=t.length;--e>=0;)t[e]^=s;return this}premultiply(){return x(this.pixels,this.format,n.premultiplyInt),this}postmultiply(){return x(this.pixels,this.format,n.postmultiplyInt),this}isPremultiplied(){const t=this.pixels,e=this.format.toABGR;for(let s=t.length;--s>=0;)if(!n.isPremultipliedInt(e(t[s])))return!1;return!0}forEach(t){const e=this.pixels;for(let s=e.length;--s>=0;)e[s]=t(e[s]);return this}dither(t,s){const{pixels:i,format:n,width:r}=this,a=e.isNumber(s)?new Array(n.channels.length).fill(s):s,h=e.isNumber(t)?b(t):t;for(let t=0,e=i.length,s=n.channels.length,l=0,o=0;t<e;t++){let e=i[t];for(let t=0;t<s;t++){const s=n.channels[t],i=a[t];i>0&&(e=s.setInt(e,s.dither(h,i,l,o,s.int(e))))}i[t]=e,++l===r&&(l=0,o++)}return this}}class K{constructor(t,e,s,i){this.width=t,this.height=e,this.format=s.__float?s:j(s),this.stride=s.channels.length,this.rowStride=t*this.stride,this.pixels=i||new Float32Array(t*e*this.stride)}as(t){const{width:e,height:s,stride:i,pixels:n,format:r}=this,a=new J(e,s,t),h=a.pixels;for(let e=0,s=0,a=n.length;e<a;e+=i,s++)h[s]=t.fromABGR(r.toABGR(n.subarray(e,e+i)));return a}copy(){const t=new K(this.width,this.height,this.format);return t.pixels.set(this.pixels),t}getAt(t,e){const{width:s,stride:i}=this;if(t>=0&&t<s&&e>=0&&e<this.height){const s=(0|t)*i+(0|e)*this.rowStride;return this.pixels.subarray(s,s+i)}}setAt(t,e,s){return t>=0&&t<this.width&&e>=0&&e<this.height&&this.pixels.set(s,(0|t)*this.stride+(0|e)*this.rowStride),this}getChannelAt(t,e,s){p(this.format,s);const{width:i,stride:n}=this;if(t>=0&&t<i&&e>=0&&e<this.height)return this.pixels[(0|t)*n+(0|e)*this.rowStride+s]}setChannelAt(t,e,s,i){p(this.format,s);const{width:n,stride:r}=this;return t>=0&&t<n&&e>=0&&e<this.height&&(this.pixels[(0|t)*r+(0|e)*this.rowStride+s]=i),this}getChannel(t){p(this.format,t);const{pixels:e,stride:s}=this,n=new Float32Array(this.width*this.height);for(let r=t,a=0,h=e.length;r<h;r+=s,a++)n[a]=i.clamp01(e[r]);return new K(this.width,this.height,Y,n)}setChannel(t,s){p(this.format,t);const{pixels:i,stride:n}=this;if(e.isNumber(s))for(let e=t,r=i.length;e<r;e+=n)i[e]=s;else{const{pixels:e,stride:r}=s;f(e,this.width,this.height,r);for(let s=t,a=0,h=i.length;s<h;s+=n,a+=r)i[s]=e[a]}return this}blend(t,e,s){this.ensureFormat(e);const{sx:i,sy:n,dx:r,dy:a,rw:h,rh:l}=A(this,e,s);if(h<1||l<1)return e;const o=this.pixels,c=e.pixels,f=this.rowStride,p=e.rowStride,u=this.stride;for(let e=(0|i)*u+(0|n)*f,s=(0|r)*u+(0|a)*p,m=0;m<l;m++,e+=f,s+=p)for(let i=h,n=e,r=s;--i>=0;n+=u,r+=u){const e=c.subarray(r,r+u);t(e,o.subarray(n,n+u),e)}return e}blit(t,e){this.ensureFormat(t);const{sx:s,sy:i,dx:n,dy:r,rw:a,rh:h}=A(this,t,e);if(a<1||h<1)return t;const l=this.pixels,o=t.pixels,c=this.rowStride,f=t.rowStride,p=a*this.stride;for(let t=(0|s)*this.stride+(0|i)*c,e=(0|n)*this.stride+(0|r)*f,a=0;a<h;a++,t+=c,e+=f)o.set(l.subarray(t,t+p),e);return t}blitCanvas(t,e=0,s=0){const i=t.getContext("2d"),n=new ImageData(this.width,this.height),r=new Uint32Array(n.data.buffer),{stride:a,pixels:h,format:l}=this;for(let t=0,e=0,s=h.length;t<s;t+=a,e++)r[e]=l.toABGR(h.subarray(t,t+a));return i.putImageData(n,e,s),t}getRegion(t,e,s,i){const[n,r,a,h]=m(t,e,s,i,this.width,this.height);return this.blit(new K(a,h,this.format),{sx:n,sy:r,w:a,h})}forEach(t){const{pixels:e,stride:s}=this;for(let i=0,n=e.length;i<n;i+s)t(e.subarray(i,i+s));return this}clamp(){const t=this.pixels;for(let e=t.length;--e>=0;)t[e]=i.clamp01(t[e]);return this}clampChannel(t){p(this.format,t);const{pixels:e,stride:s}=this;for(let n=t,r=e.length;n<r;n+=s)e[n]=i.clamp01(e[n])}ensureFormat(t){s.assert(t.format===this.format,"dest buffer format must be same as src")}}t.ABGR8888=O,t.ALPHA8=N,t.ARGB1555=S,t.ARGB4444=k,t.ARGB8888=_,t.BGR888=H,t.FLOAT_GRAY=Y,t.FLOAT_GRAY_ALPHA=q,t.FLOAT_RGB=V,t.FLOAT_RGBA=M,t.FloatBuffer=K,t.GRAY16=P,t.GRAY8=C,t.GRAY_ALPHA16=v,t.GRAY_ALPHA8=F,t.PackedBuffer=J,t.RGB565=I,t.RGB888=$,t.buffer=(t,e,s,i)=>new J(t,e,s,i),t.canvas2d=l,t.canvasPixels=o,t.clampRegion=m,t.compileFromABGR=z,t.compileGrayFromABGR=L,t.compileGrayToABGR=B,t.compileToABGR=E,t.defBayer=b,t.defFloatFormat=j,t.defPackedFormat=T,t.ditherPixels=(t,e,s,i,n,r,a,h)=>{!t&&(t=e.slice()),a--;for(let l=0,o=0;l<i;l++)for(let i=0;i<s;i++)t[o]=D(n,r,a,h,i,l,e[o]),o++;return t},t.ensureChannel=p,t.ensureSize=f,t.floatBuffer=(t,e,s,i)=>new K(t,e,s,i),t.imageCanvas=c,t.imagePromise=async t=>{const e=new Image;return e.src=t,await e.decode(),e},t.luminanceABGR=u,t.orderedDither=D,t.prepRegions=A,t.setChannelConvert=R,t.setChannelSame=g,t.setChannelUni=d,t.transformABGR=x,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/checks"),require("@thi.ng/api"),require("@thi.ng/math"),require("@thi.ng/porter-duff")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/checks","@thi.ng/api","@thi.ng/math","@thi.ng/porter-duff"],e):e(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.pixel={}),t.thi.ng.checks,t.thi.ng.api,t.thi.ng.math,t.thi.ng.porterDuff)}(this,(function(t,e,s,i,n){"use strict";var r,a,h;(r=t.Lane||(t.Lane={}))[r.ALPHA=0]="ALPHA",r[r.BLUE=1]="BLUE",r[r.GREEN=2]="GREEN",r[r.RED=3]="RED",(a=t.Wrap||(t.Wrap={}))[a.NONE=0]="NONE",a[a.U=1]="U",a[a.V=2]="V",a[a.UV=3]="UV",(h=t.Filter||(t.Filter={}))[h.NEAREST=0]="NEAREST",h[h.LINEAR=1]="LINEAR";const l=(t,e=t,s)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,s&&s.appendChild(i),{canvas:i,ctx:i.getContext("2d")}};function o(t,s){let i,n;if(e.isNumber(t)){const e=l(t,s);i=e.canvas,n=e.ctx}else i=t,n=i.getContext("2d");const r=n.getImageData(0,0,i.width,i.height);return{canvas:i,ctx:n,img:r,pixels:new Uint32Array(r.data.buffer)}}const c=(t,s,i=s,n)=>{const r=e.isNumber(s)?l(s,i,n):l(t.width,t.height,n);return r.ctx.drawImage(t,0,0,r.canvas.width,r.canvas.height),r},f=(t,e,i,n=1)=>s.assert(t.length>=e*i*n,"pixel buffer too small"),p=(t,e)=>{const i=t.channels[e];return s.assert(null!=i,"invalid channel ID: "+e),i},u=t=>(29*(t>>>16&255)+150*(t>>>8&255)+76*(255&t))/255,m=(t,e,s,n,r,a,h=0,l=0)=>(s|=0,n|=0,(t|=0)<0&&(s+=t,h-=t,t=0),(e|=0)<0&&(n+=e,l-=e,e=0),[t,e,i.clamp(s,0,r-t),i.clamp(n,0,a-e),h,l]),A=(t,e,s={})=>{let i,n,r,a,h,l,o=t.width,c=e.width;return[i,n,h,l]=m(s.sx||0,s.sy||0,s.w||o,s.h||t.height,o,t.height),[r,a,h,l,i,n]=m(s.dx||0,s.dy||0,h,l,c,e.height,i,n),{sx:i,sy:n,dx:r,dy:a,rw:h,rh:l}},d=(t,e,s)=>{for(let i=t.length;--i>=0;)t[i]=s(t[i],e)},g=(t,e,s,i)=>{for(let n=t.length;--n>=0;)t[n]=i(t[n],s(e[n]))},R=(t,e,s,i,n)=>{const r=~n;for(let a=t.length;--a>=0;)t[a]=t[a]&r|s(i(e[a]))&n},y=(t,e,s)=>{const i=e.fromABGR,n=e.toABGR;for(let e=t.length;--e>=0;)t[e]=i(s(n(t[e])))},w=(t,e)=>e>0?`(${t} << ${e})`:e<0?`(${t} >>> ${-e})`:""+t,x=(t,e)=>w(t,-e),G=t=>"0x"+t.toString(16),L=t=>{const e=(1<<t)-1;return new Function("luma",`return (x) => ${x("luma(x)",8-t)} & ${e};`)(u)},B=t=>{let e;if(8!==t){const s=(1<<t)-1;e=`(((x & ${s}) * ${255/s}) | 0)`}else e="x";return new Function("x",`return 0xff000000 | (${e} * 0x010101);`)},z=t=>new Function("x","return ("+t.map(t=>{const e=t.abgrShift+(8-t.size);return`(${x("x",e)} & ${G(t.maskA)})`}).join(" | ")+") >>> 0;"),E=(t,e)=>{const s=t.map(t=>{if(8!==t.size){const e=t.mask0,s=255/e,i=x("x",t.shift);return w(`((${i} & ${e}) * ${s})`,24-8*t.lane)}return w(`(x & ${G(t.maskA)})`,t.abgrShift)}).join(" | ");return new Function("x",`return (${e?"":"0xff000000 | "}${s}) >>> 0;`)},b=(t,e,s,i,n,r)=>{if(1===s)return!r[e]&&(r[e]=[]),r[e][t]=i,r;const a=n<<2;return b(t,e,s>>=1,i,a,r),b(t+s,e+s,s,i+n,a,r),b(t+s,e,s,i+2*n,a,r),b(t,e+s,s,i+3*n,a,r),r},U=t=>({mat:b(0,0,t,0,1,[]),invSize:1/(t*t),mask:t-1}),D=({mat:t,mask:e,invSize:s},n,r,a,h,l,o)=>(o=n*(o/a)+t[l&e][h&e]*s-.5|0,n--,i.clamp(o,0,n)*((r-1)/n)),T=t=>{s.assert(t.channels.length>0,"no channel specs given");const e=t.channels.reduce(([t,e],s,n)=>(e-=s.size,t.push(((t,e,s)=>{const n=1<<t.size,r=n-1,a=r<<s>>>0,h=~a>>>0,l=null!=t.lane?t.lane:e,o=t=>t>>>s&r,c=(t,e)=>t&h|(e&r)<<s;return{size:t.size,abgrShift:24-8*l-s,lane:l,shift:s,mask0:r,maskA:a,int:o,setInt:c,float:t=>o(t)/r,setFloat:(t,e)=>c(t,i.clamp01(e)*r),dither:(t,e,s,i,r)=>D(t,e,n,n,s,i,r)}})(s,n,e)),[t,e]),[[],t.size])[0];return{__packed:!0,type:t.type,size:t.size,alpha:t.alpha||0,channels:e,fromABGR:t.fromABGR||z(e),toABGR:t.toABGR||E(e,!!t.alpha)}},N=T({type:s.Type.U8,size:8,alpha:8,channels:[{size:8,lane:0}]}),F=T({type:s.Type.U8,size:8,channels:[{size:8,lane:t.Lane.RED}],fromABGR:t=>u(t),toABGR:t=>(4278190080|65793*(255&t))>>>0}),C=T({type:s.Type.U16,size:16,alpha:8,channels:[{size:8,lane:t.Lane.ALPHA},{size:8,lane:t.Lane.RED}],fromABGR:t=>u(t)|t>>>16&65280,toABGR:t=>((65280&t)<<16|65793*(255&t))>>>0}),P=T({type:s.Type.U16,size:16,channels:[{size:16,lane:t.Lane.RED}],fromABGR:t=>257*(u(t)+.5|0),toABGR:t=>(4278190080|65793*(t>>>8))>>>0}),v=T({type:s.Type.U32,size:32,channels:[{size:8,lane:t.Lane.ALPHA},{size:16,lane:t.Lane.RED}],fromABGR:t=>257*(u(t)+.5|0)|257*(t>>>8&16711680),toABGR:t=>(4278190080&t|65793*(t>>>8&255))>>>0}),S=T({type:s.Type.U16,size:16,channels:[{size:5,lane:t.Lane.RED},{size:6,lane:t.Lane.GREEN},{size:5,lane:t.Lane.BLUE}]}),I=T({type:s.Type.U16,size:16,alpha:1,channels:[{size:1,lane:t.Lane.ALPHA},{size:5,lane:t.Lane.RED},{size:5,lane:t.Lane.GREEN},{size:5,lane:t.Lane.BLUE}]}),k=T({type:s.Type.U16,size:16,alpha:4,channels:[{size:4,lane:t.Lane.ALPHA},{size:4,lane:t.Lane.RED},{size:4,lane:t.Lane.GREEN},{size:4,lane:t.Lane.BLUE}]}),$=T({type:s.Type.U32,size:24,channels:[{size:8,lane:t.Lane.RED},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.BLUE}]}),_=T({type:s.Type.U32,size:32,alpha:8,channels:[{size:8,lane:t.Lane.ALPHA},{size:8,lane:t.Lane.RED},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.BLUE}]}),H=T({type:s.Type.U32,size:24,channels:[{size:8,lane:t.Lane.BLUE},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.RED}],fromABGR:t=>16777215&t,toABGR:t=>4278190080|t}),O=T({type:s.Type.U32,size:32,alpha:8,channels:[{size:8,lane:t.Lane.ALPHA},{size:8,lane:t.Lane.BLUE},{size:8,lane:t.Lane.GREEN},{size:8,lane:t.Lane.RED}],fromABGR:t=>t,toABGR:t=>t}),Y=e=>{const s=e.channels,i=s.reduce((t,e)=>(t[e]=3-e<<3,t),{}),n=Object.assign(Object.assign({},e),{size:s.length,shift:i,__float:!0}),r=(t,e)=>(255*t[e]+.5|0)<<i[s[e]],a=(t,e)=>(t>>>i[s[e]]&255)/255;switch(s.length){case 1:e.gray?(n.toABGR=t=>(65793*(255*t[0]+.5|0)|4278190080)>>>0,n.fromABGR=(t,e=[])=>(e[0]=u(t)/255,e)):(n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e));break;case 2:if(e.gray){const e=~~(s[0]===t.Lane.ALPHA),i=1^e;n.toABGR=t=>{let s=65793*(255*t[e]+.5|0);return s|=(255*t[i]+.5|0)<<24,s>>>0},n.fromABGR=(t,s=[])=>(s[e]=u(t)/255,s[i]=a(t,i),s)}else n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s|=r(t,1),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e[1]=a(t,1),e);break;case 3:n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s|=r(t,1),s|=r(t,2),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e[1]=a(t,1),e[2]=a(t,2),e);break;case 4:n.toABGR=t=>{let s=e.alpha?0:4278190080;return s|=r(t,0),s|=r(t,1),s|=r(t,2),s|=r(t,3),s>>>0},n.fromABGR=(t,e=[])=>(e[0]=a(t,0),e[1]=a(t,1),e[2]=a(t,2),e[3]=a(t,3),e)}return n},j=Y({gray:!0,channels:[t.Lane.RED]}),q=Y({gray:!0,alpha:!0,channels:[t.Lane.RED,t.Lane.ALPHA]}),V=Y({channels:[t.Lane.RED,t.Lane.GREEN,t.Lane.BLUE]}),W=Y({alpha:!0,channels:[t.Lane.RED,t.Lane.GREEN,t.Lane.BLUE,t.Lane.ALPHA]}),M={[s.Type.U8]:Uint8Array,[s.Type.U16]:Uint16Array,[s.Type.U32]:Uint32Array};class J{constructor(t,e,s,i){this.width=t,this.height=e,this.format=s.__packed?s:T(s),this.pixels=i||new M[s.type](t*e)}static fromImage(t,e,s,i=s){const n=c(t,s,i),r=n.canvas.width,a=n.canvas.height,h=new Uint32Array(n.ctx.getImageData(0,0,r,a).data.buffer),l=new M[e.type](r*a),o=e.fromABGR;for(let t=l.length;--t>=0;)l[t]=o(h[t]);return new J(r,a,e,l)}static fromCanvas(t){return new J(t.width,t.height,O,o(t).pixels)}as(t){return this.getRegion(0,0,this.width,this.height,t)}copy(){const t=new J(this.width,this.height,this.format);return t.pixels.set(this.pixels),t}getAt(t,e){return t>=0&&t<this.width&&e>=0&&e<this.height?this.pixels[(0|t)+(0|e)*this.width]:0}setAt(t,e,s){return t>=0&&t<this.width&&e>=0&&e<this.height&&(this.pixels[(0|t)+(0|e)*this.width]=s),this}getChannelAt(t,e,s,i=!1){const n=p(this.format,s),r=this.getAt(t,e);return i?n.float(r):n.int(r)}setChannelAt(t,e,s,i,n=!1){const r=p(this.format,s),a=this.getAt(t,e);return n?r.setFloat(a,i):r.setInt(a,i),this}blend(t,e,s){let i=this.width,n=e.width;const{sx:r,sy:a,dx:h,dy:l,rw:o,rh:c}=A(this,e,s);if(o<1||c<1)return e;const f=this.pixels,p=e.pixels,u=this.format.toABGR,m=e.format.toABGR,d=e.format.fromABGR;for(let e=(0|r)+(0|a)*i,s=(0|h)+(0|l)*n,A=0;A<c;A++,e+=i,s+=n)for(let i=0;i<o;i++)p[s+i]=d(t(u(f[e+i]),m(p[s+i])));return e}blit(t,e){let s=this.width,i=t.width;const{sx:n,sy:r,dx:a,dy:h,rw:l,rh:o}=A(this,t,e);if(l<1||o<1)return t;const c=this.pixels,f=t.pixels,p=this.format.toABGR,u=t.format.fromABGR,m=this.format!==t.format?(t,e)=>{for(let s=0;s<l;s++)f[e+s]=u(p(c[t+s]))}:(t,e)=>f.set(c.subarray(t,t+l),e);for(let t=(0|n)+(0|r)*s,e=(0|a)+(0|h)*i,l=0;l<o;l++,t+=s,e+=i)m(t,e);return t}blitCanvas(t,e=0,s=0){const i=t.getContext("2d"),n=new ImageData(this.width,this.height),r=new Uint32Array(n.data.buffer),a=this.pixels,h=this.format.toABGR;for(let t=r.length;--t>=0;)r[t]=h(a[t]);return i.putImageData(n,e,s),t}getRegion(t,e,s,i,n){const[r,a,h,l]=m(t,e,s,i,this.width,this.height);return this.blit(new J(h,l,n||this.format),{sx:r,sy:a,w:h,h:l})}getChannel(e){const i=p(this.format,e),n=new J(this.width,this.height,{type:i.size>16?s.Type.U32:i.size>8?s.Type.U16:s.Type.U8,size:i.size,channels:[{size:i.size,lane:t.Lane.RED}],fromABGR:L(i.size),toABGR:B(i.size)}),r=this.pixels,a=n.pixels,h=i.int;for(let t=r.length;--t>=0;)a[t]=h(r[t]);return n}setChannel(t,s){const i=p(this.format,t),n=this.pixels,r=i.setInt;if(e.isNumber(s))d(n,s,r);else{const t=s.pixels,e=s.format.channels[0];f(t,this.width,this.height),i.size===e.size?g(n,t,e.int,r):R(n,t,this.format.fromABGR,s.format.toABGR,i.maskA)}return this}invert(){const t=this.pixels,e=this.format,s=Math.pow(2,e.size-e.alpha)-1;for(let e=t.length;--e>=0;)t[e]^=s;return this}premultiply(){return y(this.pixels,this.format,n.premultiplyInt),this}postmultiply(){return y(this.pixels,this.format,n.postmultiplyInt),this}isPremultiplied(){const t=this.pixels,e=this.format.toABGR;for(let s=t.length;--s>=0;)if(!n.isPremultipliedInt(e(t[s])))return!1;return!0}forEach(t){const e=this.pixels;for(let s=e.length;--s>=0;)e[s]=t(e[s]);return this}dither(t,s){const{pixels:i,format:n,width:r}=this,a=e.isNumber(s)?new Array(n.channels.length).fill(s):s,h=e.isNumber(t)?U(t):t;for(let t=0,e=i.length,s=n.channels.length,l=0,o=0;t<e;t++){let e=i[t];for(let t=0;t<s;t++){const s=n.channels[t],i=a[t];i>0&&(e=s.setInt(e,s.dither(h,i,l,o,s.int(e))))}i[t]=e,++l===r&&(l=0,o++)}return this}flipY(){const{pixels:t,width:e}=this,s=new M[this.format.type](e);for(let i=0,n=t.length-e;i<n;i+=e,n-=e)s.set(t.subarray(i,i+e)),t.copyWithin(i,n,n+e),t.set(s,n);return this}}class K{constructor(t,e,s,i){this.width=t,this.height=e,this.format=s.__float?s:Y(s),this.stride=s.channels.length,this.rowStride=t*this.stride,this.pixels=i||new Float32Array(t*e*this.stride)}as(t){const{width:e,height:s,stride:i,pixels:n,format:r}=this,a=new J(e,s,t),h=a.pixels;for(let e=0,s=0,a=n.length;e<a;e+=i,s++)h[s]=t.fromABGR(r.toABGR(n.subarray(e,e+i)));return a}copy(){const t=new K(this.width,this.height,this.format);return t.pixels.set(this.pixels),t}getAt(t,e){const{width:s,stride:i}=this;if(t>=0&&t<s&&e>=0&&e<this.height){const s=(0|t)*i+(0|e)*this.rowStride;return this.pixels.subarray(s,s+i)}}setAt(t,e,s){return t>=0&&t<this.width&&e>=0&&e<this.height&&this.pixels.set(s,(0|t)*this.stride+(0|e)*this.rowStride),this}getChannelAt(t,e,s){p(this.format,s);const{width:i,stride:n}=this;if(t>=0&&t<i&&e>=0&&e<this.height)return this.pixels[(0|t)*n+(0|e)*this.rowStride+s]}setChannelAt(t,e,s,i){p(this.format,s);const{width:n,stride:r}=this;return t>=0&&t<n&&e>=0&&e<this.height&&(this.pixels[(0|t)*r+(0|e)*this.rowStride+s]=i),this}getChannel(t){p(this.format,t);const{pixels:e,stride:s}=this,n=new Float32Array(this.width*this.height);for(let r=t,a=0,h=e.length;r<h;r+=s,a++)n[a]=i.clamp01(e[r]);return new K(this.width,this.height,j,n)}setChannel(t,s){p(this.format,t);const{pixels:i,stride:n}=this;if(e.isNumber(s))for(let e=t,r=i.length;e<r;e+=n)i[e]=s;else{const{pixels:e,stride:r}=s;f(e,this.width,this.height,r);for(let s=t,a=0,h=i.length;s<h;s+=n,a+=r)i[s]=e[a]}return this}blend(t,e,s){this.ensureFormat(e);const{sx:i,sy:n,dx:r,dy:a,rw:h,rh:l}=A(this,e,s);if(h<1||l<1)return e;const o=this.pixels,c=e.pixels,f=this.rowStride,p=e.rowStride,u=this.stride;for(let e=(0|i)*u+(0|n)*f,s=(0|r)*u+(0|a)*p,m=0;m<l;m++,e+=f,s+=p)for(let i=h,n=e,r=s;--i>=0;n+=u,r+=u){const e=c.subarray(r,r+u);t(e,o.subarray(n,n+u),e)}return e}blit(t,e){this.ensureFormat(t);const{sx:s,sy:i,dx:n,dy:r,rw:a,rh:h}=A(this,t,e);if(a<1||h<1)return t;const l=this.pixels,o=t.pixels,c=this.rowStride,f=t.rowStride,p=a*this.stride;for(let t=(0|s)*this.stride+(0|i)*c,e=(0|n)*this.stride+(0|r)*f,a=0;a<h;a++,t+=c,e+=f)o.set(l.subarray(t,t+p),e);return t}blitCanvas(t,e=0,s=0){const i=t.getContext("2d"),n=new ImageData(this.width,this.height),r=new Uint32Array(n.data.buffer),{stride:a,pixels:h,format:l}=this;for(let t=0,e=0,s=h.length;t<s;t+=a,e++)r[e]=l.toABGR(h.subarray(t,t+a));return i.putImageData(n,e,s),t}getRegion(t,e,s,i){const[n,r,a,h]=m(t,e,s,i,this.width,this.height);return this.blit(new K(a,h,this.format),{sx:n,sy:r,w:a,h})}forEach(t){const{pixels:e,stride:s}=this;for(let i=0,n=e.length;i<n;i+s)t(e.subarray(i,i+s));return this}clamp(){const t=this.pixels;for(let e=t.length;--e>=0;)t[e]=i.clamp01(t[e]);return this}clampChannel(t){p(this.format,t);const{pixels:e,stride:s}=this;for(let n=t,r=e.length;n<r;n+=s)e[n]=i.clamp01(e[n])}flipY(){const{pixels:t,rowStride:e}=this,s=new Float32Array(e);for(let i=0,n=t.length-e;i<n;i+=e,n-=e)s.set(t.subarray(i,i+e)),t.copyWithin(i,n,n+e),t.set(s,n);return this}ensureFormat(t){s.assert(t.format===this.format,"dest buffer format must be same as src")}}t.ABGR8888=O,t.ALPHA8=N,t.ARGB1555=I,t.ARGB4444=k,t.ARGB8888=_,t.BGR888=H,t.FLOAT_GRAY=j,t.FLOAT_GRAY_ALPHA=q,t.FLOAT_RGB=V,t.FLOAT_RGBA=W,t.FloatBuffer=K,t.GRAY16=P,t.GRAY8=F,t.GRAY_ALPHA16=v,t.GRAY_ALPHA8=C,t.PackedBuffer=J,t.RGB565=S,t.RGB888=$,t.buffer=(t,e,s,i)=>new J(t,e,s,i),t.canvas2d=l,t.canvasPixels=o,t.clampRegion=m,t.compileFromABGR=z,t.compileGrayFromABGR=L,t.compileGrayToABGR=B,t.compileToABGR=E,t.defBayer=U,t.defFloatFormat=Y,t.defPackedFormat=T,t.ditherPixels=(t,e,s,i,n,r,a,h)=>{!t&&(t=e.slice()),a--;for(let l=0,o=0;l<i;l++)for(let i=0;i<s;i++)t[o]=D(n,r,a,h,i,l,e[o]),o++;return t},t.ensureChannel=p,t.ensureSize=f,t.floatBuffer=(t,e,s,i)=>new K(t,e,s,i),t.imageCanvas=c,t.imagePromise=async t=>{const e=new Image;return e.src=t,await e.decode(),e},t.luminanceABGR=u,t.orderedDither=D,t.prepRegions=A,t.setChannelConvert=R,t.setChannelSame=g,t.setChannelUni=d,t.transformABGR=y,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@thi.ng/pixel", | ||
"version": "0.3.6", | ||
"version": "0.4.0", | ||
"description": "Typed array backed, packed integer and unpacked floating point pixel buffers w/ customizable formats, blitting, dithering, conversions", | ||
@@ -88,3 +88,3 @@ "module": "./index.js", | ||
}, | ||
"gitHead": "ca21a57b0c9b12244dc501a160b7f70f2002d973" | ||
"gitHead": "79a7de5b8a87dcabc62841f7cc5c97e7b5377800" | ||
} |
@@ -55,3 +55,7 @@ import { Fn, UIntArray } from "@thi.ng/api"; | ||
dither(size: BayerSize | BayerMatrix, numColors: number | number[]): this; | ||
/** | ||
* Flips image vertically. | ||
*/ | ||
flipY(): this; | ||
} | ||
//# sourceMappingURL=packed.d.ts.map |
@@ -251,2 +251,15 @@ import { Type } from "@thi.ng/api"; | ||
} | ||
/** | ||
* Flips image vertically. | ||
*/ | ||
flipY() { | ||
const { pixels, width } = this; | ||
const tmp = new CTORS[this.format.type](width); | ||
for (let i = 0, j = pixels.length - width; i < j; i += width, j -= width) { | ||
tmp.set(pixels.subarray(i, i + width)); | ||
pixels.copyWithin(i, j, j + width); | ||
pixels.set(tmp, j); | ||
} | ||
return this; | ||
} | ||
} |
@@ -134,3 +134,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (gzipped, pre-treeshake): ESM: 4.70 KB / CJS: 4.88 KB / UMD: 4.79 KB | ||
Package sizes (gzipped, pre-treeshake): ESM: 4.78 KB / CJS: 4.96 KB / UMD: 4.87 KB | ||
@@ -137,0 +137,0 @@ ## Dependencies |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
214067
2453