@thi.ng/pixel
Advanced tools
Comparing version 3.3.2 to 3.4.0
# Change Log | ||
- **Last updated**: 2022-03-11T12:13:49Z | ||
- **Last updated**: 2022-04-07T14:17:30Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,10 @@ | ||
## [3.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/pixel@3.4.0) (2022-04-07) | ||
#### 🚀 Features | ||
- buffer method additions, internal checks ([a70b3c1](https://github.com/thi-ng/umbrella/commit/a70b3c1)) | ||
- add FloatBuffer.premultiply/postmultiply() | ||
- add Int/FloatBuffer.fill() | ||
## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/pixel@3.3.0) (2021-12-13) | ||
@@ -14,0 +22,0 @@ |
@@ -9,2 +9,4 @@ import type { TypedArray } from "@thi.ng/api"; | ||
export declare const ensureSingleChannel: (fmt: IntFormat | FloatFormat) => void; | ||
/** @internal */ | ||
export declare const ensureAlpha: (fmt: IntFormat | FloatFormat) => void; | ||
//# sourceMappingURL=checks.d.ts.map |
@@ -12,1 +12,3 @@ import { assert } from "@thi.ng/errors/assert"; | ||
export const ensureSingleChannel = (fmt) => assert(fmt.channels.length === 1, `require single channel buffer`); | ||
/** @internal */ | ||
export const ensureAlpha = (fmt) => assert(!!fmt.alpha, "missing alpha channel"); |
@@ -61,2 +61,5 @@ import type { Fn2, ICopy, IEmpty, NumericArray } from "@thi.ng/api"; | ||
forEach(f: Fn2<NumericArray, number, NumericArray>): this; | ||
fill(x: NumericArray): void; | ||
premultiply(): this; | ||
postmultiply(): this; | ||
clamp(): this; | ||
@@ -73,3 +76,4 @@ clampChannel(id: number): void; | ||
protected ensureFormat(dest: FloatBuffer): void; | ||
protected ensureRGBA(): void; | ||
} | ||
//# sourceMappingURL=float.d.ts.map |
27
float.js
@@ -9,2 +9,3 @@ var FloatBuffer_1; | ||
import { clamp01 } from "@thi.ng/math/interval"; | ||
import { postmultiply, premultiply } from "@thi.ng/porter-duff/premultiply"; | ||
import { ensureChannel, ensureSize } from "./checks.js"; | ||
@@ -215,2 +216,25 @@ import { defFloatFormat } from "./format/float-format.js"; | ||
} | ||
fill(x) { | ||
assert(x.length <= this.format.channels.length, `fill value has too many channels`); | ||
const { data, stride: [stride], } = this; | ||
for (let i = 0, n = data.length; i < n; i += stride) { | ||
data.set(x, i); | ||
} | ||
} | ||
premultiply() { | ||
this.ensureRGBA(); | ||
const { data, stride: [stride], } = this; | ||
for (let i = 0, n = data.length; i < n; i += stride) { | ||
premultiply(null, data.subarray(i, i + stride)); | ||
} | ||
return this; | ||
} | ||
postmultiply() { | ||
this.ensureRGBA(); | ||
const { data, stride: [stride], } = this; | ||
for (let i = 0, n = data.length; i < n; i += stride) { | ||
postmultiply(null, data.subarray(i, i + stride)); | ||
} | ||
return this; | ||
} | ||
clamp() { | ||
@@ -291,2 +315,5 @@ const data = this.data; | ||
} | ||
ensureRGBA() { | ||
assert(this.format === FLOAT_RGBA, "require FLOAT_RGBA format"); | ||
} | ||
}; | ||
@@ -293,0 +320,0 @@ __decorate([ |
@@ -69,2 +69,3 @@ import type { Fn2, ICopy, IEmpty } from "@thi.ng/api"; | ||
forEach(f: Fn2<number, number, number>): this; | ||
fill(x: number): void; | ||
/** | ||
@@ -71,0 +72,0 @@ * Flips image vertically. |
@@ -11,3 +11,3 @@ var IntBuffer_1; | ||
import { canvasPixels, imageCanvas } from "./canvas.js"; | ||
import { ensureChannel, ensureSize } from "./checks.js"; | ||
import { ensureAlpha, ensureChannel, ensureSize } from "./checks.js"; | ||
import { ABGR8888 } from "./format/abgr8888.js"; | ||
@@ -233,2 +233,3 @@ import { defIntFormat } from "./format/int-format.js"; | ||
premultiply() { | ||
ensureAlpha(this.format); | ||
__transformABGR(this.data, this.format, premultiplyInt); | ||
@@ -258,2 +259,5 @@ return this; | ||
} | ||
fill(x) { | ||
this.data.fill(x); | ||
} | ||
/** | ||
@@ -260,0 +264,0 @@ * Flips image vertically. |
{ | ||
"name": "@thi.ng/pixel", | ||
"version": "3.3.2", | ||
"version": "3.4.0", | ||
"description": "Typedarray integer & float pixel buffers w/ customizable formats, blitting, drawing, convolution", | ||
@@ -37,14 +37,14 @@ "type": "module", | ||
"dependencies": { | ||
"@thi.ng/api": "^8.3.4", | ||
"@thi.ng/binary": "^3.2.0", | ||
"@thi.ng/checks": "^3.1.4", | ||
"@thi.ng/distance": "^2.1.8", | ||
"@thi.ng/errors": "^2.1.4", | ||
"@thi.ng/k-means": "^0.5.8", | ||
"@thi.ng/math": "^5.3.0", | ||
"@thi.ng/porter-duff": "^2.1.4" | ||
"@thi.ng/api": "^8.3.5", | ||
"@thi.ng/binary": "^3.2.1", | ||
"@thi.ng/checks": "^3.1.5", | ||
"@thi.ng/distance": "^2.1.9", | ||
"@thi.ng/errors": "^2.1.5", | ||
"@thi.ng/k-means": "^0.5.9", | ||
"@thi.ng/math": "^5.3.1", | ||
"@thi.ng/porter-duff": "^2.1.5" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.19.4", | ||
"@thi.ng/testament": "^0.2.4", | ||
"@thi.ng/testament": "^0.2.5", | ||
"rimraf": "^3.0.2", | ||
@@ -107,99 +107,99 @@ "tools": "^0.0.1", | ||
".": { | ||
"import": "./index.js" | ||
"default": "./index.js" | ||
}, | ||
"./api": { | ||
"import": "./api.js" | ||
"default": "./api.js" | ||
}, | ||
"./canvas": { | ||
"import": "./canvas.js" | ||
"default": "./canvas.js" | ||
}, | ||
"./checks": { | ||
"import": "./checks.js" | ||
"default": "./checks.js" | ||
}, | ||
"./convolve": { | ||
"import": "./convolve.js" | ||
"default": "./convolve.js" | ||
}, | ||
"./dominant-colors": { | ||
"import": "./dominant-colors.js" | ||
"default": "./dominant-colors.js" | ||
}, | ||
"./float": { | ||
"import": "./float.js" | ||
"default": "./float.js" | ||
}, | ||
"./format/abgr8888": { | ||
"import": "./format/abgr8888.js" | ||
"default": "./format/abgr8888.js" | ||
}, | ||
"./format/alpha8": { | ||
"import": "./format/alpha8.js" | ||
"default": "./format/alpha8.js" | ||
}, | ||
"./format/argb1555": { | ||
"import": "./format/argb1555.js" | ||
"default": "./format/argb1555.js" | ||
}, | ||
"./format/argb4444": { | ||
"import": "./format/argb4444.js" | ||
"default": "./format/argb4444.js" | ||
}, | ||
"./format/argb8888": { | ||
"import": "./format/argb8888.js" | ||
"default": "./format/argb8888.js" | ||
}, | ||
"./format/bgr888": { | ||
"import": "./format/bgr888.js" | ||
"default": "./format/bgr888.js" | ||
}, | ||
"./format/float-format": { | ||
"import": "./format/float-format.js" | ||
"default": "./format/float-format.js" | ||
}, | ||
"./format/float-gray-alpha": { | ||
"import": "./format/float-gray-alpha.js" | ||
"default": "./format/float-gray-alpha.js" | ||
}, | ||
"./format/float-gray": { | ||
"import": "./format/float-gray.js" | ||
"default": "./format/float-gray.js" | ||
}, | ||
"./format/float-hsva": { | ||
"import": "./format/float-hsva.js" | ||
"default": "./format/float-hsva.js" | ||
}, | ||
"./format/float-norm": { | ||
"import": "./format/float-norm.js" | ||
"default": "./format/float-norm.js" | ||
}, | ||
"./format/float-rgb": { | ||
"import": "./format/float-rgb.js" | ||
"default": "./format/float-rgb.js" | ||
}, | ||
"./format/float-rgba": { | ||
"import": "./format/float-rgba.js" | ||
"default": "./format/float-rgba.js" | ||
}, | ||
"./format/gray-alpha16": { | ||
"import": "./format/gray-alpha16.js" | ||
"default": "./format/gray-alpha16.js" | ||
}, | ||
"./format/gray-alpha8": { | ||
"import": "./format/gray-alpha8.js" | ||
"default": "./format/gray-alpha8.js" | ||
}, | ||
"./format/gray16": { | ||
"import": "./format/gray16.js" | ||
"default": "./format/gray16.js" | ||
}, | ||
"./format/gray8": { | ||
"import": "./format/gray8.js" | ||
"default": "./format/gray8.js" | ||
}, | ||
"./format/indexed": { | ||
"import": "./format/indexed.js" | ||
"default": "./format/indexed.js" | ||
}, | ||
"./format/int-format": { | ||
"import": "./format/int-format.js" | ||
"default": "./format/int-format.js" | ||
}, | ||
"./format/rgb565": { | ||
"import": "./format/rgb565.js" | ||
"default": "./format/rgb565.js" | ||
}, | ||
"./format/rgb888": { | ||
"import": "./format/rgb888.js" | ||
"default": "./format/rgb888.js" | ||
}, | ||
"./int": { | ||
"import": "./int.js" | ||
"default": "./int.js" | ||
}, | ||
"./normal-map": { | ||
"import": "./normal-map.js" | ||
"default": "./normal-map.js" | ||
}, | ||
"./pyramid": { | ||
"import": "./pyramid.js" | ||
"default": "./pyramid.js" | ||
}, | ||
"./range": { | ||
"import": "./range.js" | ||
"default": "./range.js" | ||
}, | ||
"./sample": { | ||
"import": "./sample.js" | ||
"default": "./sample.js" | ||
} | ||
@@ -217,3 +217,3 @@ }, | ||
}, | ||
"gitHead": "0fc692a3225c068aacafdc4cb6140cf603c67ad8\n" | ||
"gitHead": "5ee1feb590dd935593b1dd4e7f38a3ed3ba64765\n" | ||
} |
@@ -336,3 +336,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (gzipped, pre-treeshake): ESM: 9.43 KB | ||
Package sizes (gzipped, pre-treeshake): ESM: 9.59 KB | ||
@@ -339,0 +339,0 @@ ## Dependencies |
166377
3047
Updated@thi.ng/api@^8.3.5
Updated@thi.ng/binary@^3.2.1
Updated@thi.ng/checks@^3.1.5
Updated@thi.ng/distance@^2.1.9
Updated@thi.ng/errors@^2.1.5
Updated@thi.ng/k-means@^0.5.9
Updated@thi.ng/math@^5.3.1
Updated@thi.ng/porter-duff@^2.1.5