@flighthq/bitmap 0.3.0-edge.1458.0c01b63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bitmap.d.ts +17 -0
- package/dist/bitmap.d.ts.map +1 -0
- package/dist/bitmap.js +87 -0
- package/dist/bitmap.js.map +1 -0
- package/dist/bitmapAffine.d.ts +27 -0
- package/dist/bitmapAffine.d.ts.map +1 -0
- package/dist/bitmapAffine.js +159 -0
- package/dist/bitmapAffine.js.map +1 -0
- package/dist/bitmapAlpha.d.ts +27 -0
- package/dist/bitmapAlpha.d.ts.map +1 -0
- package/dist/bitmapAlpha.js +83 -0
- package/dist/bitmapAlpha.js.map +1 -0
- package/dist/bitmapBevel.d.ts +24 -0
- package/dist/bitmapBevel.d.ts.map +1 -0
- package/dist/bitmapBevel.js +102 -0
- package/dist/bitmapBevel.js.map +1 -0
- package/dist/bitmapBlur.d.ts +57 -0
- package/dist/bitmapBlur.d.ts.map +1 -0
- package/dist/bitmapBlur.js +263 -0
- package/dist/bitmapBlur.js.map +1 -0
- package/dist/bitmapChannel.d.ts +24 -0
- package/dist/bitmapChannel.d.ts.map +1 -0
- package/dist/bitmapChannel.js +127 -0
- package/dist/bitmapChannel.js.map +1 -0
- package/dist/bitmapColorMatrix.d.ts +57 -0
- package/dist/bitmapColorMatrix.d.ts.map +1 -0
- package/dist/bitmapColorMatrix.js +127 -0
- package/dist/bitmapColorMatrix.js.map +1 -0
- package/dist/bitmapCompare.d.ts +18 -0
- package/dist/bitmapCompare.d.ts.map +1 -0
- package/dist/bitmapCompare.js +64 -0
- package/dist/bitmapCompare.js.map +1 -0
- package/dist/bitmapComposite.d.ts +54 -0
- package/dist/bitmapComposite.d.ts.map +1 -0
- package/dist/bitmapComposite.js +262 -0
- package/dist/bitmapComposite.js.map +1 -0
- package/dist/bitmapConvolution.d.ts +17 -0
- package/dist/bitmapConvolution.d.ts.map +1 -0
- package/dist/bitmapConvolution.js +103 -0
- package/dist/bitmapConvolution.js.map +1 -0
- package/dist/bitmapCopy.d.ts +23 -0
- package/dist/bitmapCopy.d.ts.map +1 -0
- package/dist/bitmapCopy.js +78 -0
- package/dist/bitmapCopy.js.map +1 -0
- package/dist/bitmapCoverage.d.ts +11 -0
- package/dist/bitmapCoverage.d.ts.map +1 -0
- package/dist/bitmapCoverage.js +29 -0
- package/dist/bitmapCoverage.js.map +1 -0
- package/dist/bitmapCrop.d.ts +33 -0
- package/dist/bitmapCrop.d.ts.map +1 -0
- package/dist/bitmapCrop.js +175 -0
- package/dist/bitmapCrop.js.map +1 -0
- package/dist/bitmapDisplacement.d.ts +22 -0
- package/dist/bitmapDisplacement.d.ts.map +1 -0
- package/dist/bitmapDisplacement.js +111 -0
- package/dist/bitmapDisplacement.js.map +1 -0
- package/dist/bitmapDissolve.d.ts +21 -0
- package/dist/bitmapDissolve.d.ts.map +1 -0
- package/dist/bitmapDissolve.js +97 -0
- package/dist/bitmapDissolve.js.map +1 -0
- package/dist/bitmapDraw.d.ts +8 -0
- package/dist/bitmapDraw.d.ts.map +1 -0
- package/dist/bitmapDraw.js +14 -0
- package/dist/bitmapDraw.js.map +1 -0
- package/dist/bitmapEncode.d.ts +3 -0
- package/dist/bitmapEncode.d.ts.map +1 -0
- package/dist/bitmapEncode.js +18 -0
- package/dist/bitmapEncode.js.map +1 -0
- package/dist/bitmapFill.d.ts +12 -0
- package/dist/bitmapFill.d.ts.map +1 -0
- package/dist/bitmapFill.js +85 -0
- package/dist/bitmapFill.js.map +1 -0
- package/dist/bitmapFingerprint.d.ts +26 -0
- package/dist/bitmapFingerprint.d.ts.map +1 -0
- package/dist/bitmapFingerprint.js +99 -0
- package/dist/bitmapFingerprint.js.map +1 -0
- package/dist/bitmapFlip.d.ts +16 -0
- package/dist/bitmapFlip.d.ts.map +1 -0
- package/dist/bitmapFlip.js +98 -0
- package/dist/bitmapFlip.js.map +1 -0
- package/dist/bitmapFormat.d.ts +26 -0
- package/dist/bitmapFormat.d.ts.map +1 -0
- package/dist/bitmapFormat.js +80 -0
- package/dist/bitmapFormat.js.map +1 -0
- package/dist/bitmapFrom.d.ts +23 -0
- package/dist/bitmapFrom.d.ts.map +1 -0
- package/dist/bitmapFrom.js +90 -0
- package/dist/bitmapFrom.js.map +1 -0
- package/dist/bitmapGradient.d.ts +36 -0
- package/dist/bitmapGradient.d.ts.map +1 -0
- package/dist/bitmapGradient.js +176 -0
- package/dist/bitmapGradient.js.map +1 -0
- package/dist/bitmapGradientFill.d.ts +32 -0
- package/dist/bitmapGradientFill.d.ts.map +1 -0
- package/dist/bitmapGradientFill.js +120 -0
- package/dist/bitmapGradientFill.js.map +1 -0
- package/dist/bitmapHistogram.d.ts +20 -0
- package/dist/bitmapHistogram.d.ts.map +1 -0
- package/dist/bitmapHistogram.js +61 -0
- package/dist/bitmapHistogram.js.map +1 -0
- package/dist/bitmapImageChannel.d.ts +2 -0
- package/dist/bitmapImageChannel.d.ts.map +1 -0
- package/dist/bitmapImageChannel.js +2 -0
- package/dist/bitmapImageChannel.js.map +1 -0
- package/dist/bitmapMedian.d.ts +14 -0
- package/dist/bitmapMedian.d.ts.map +1 -0
- package/dist/bitmapMedian.js +77 -0
- package/dist/bitmapMedian.js.map +1 -0
- package/dist/bitmapMorphological.d.ts +29 -0
- package/dist/bitmapMorphological.d.ts.map +1 -0
- package/dist/bitmapMorphological.js +81 -0
- package/dist/bitmapMorphological.js.map +1 -0
- package/dist/bitmapNoise.d.ts +48 -0
- package/dist/bitmapNoise.d.ts.map +1 -0
- package/dist/bitmapNoise.js +245 -0
- package/dist/bitmapNoise.js.map +1 -0
- package/dist/bitmapPaletteMap.d.ts +17 -0
- package/dist/bitmapPaletteMap.d.ts.map +1 -0
- package/dist/bitmapPaletteMap.js +45 -0
- package/dist/bitmapPaletteMap.js.map +1 -0
- package/dist/bitmapPixel.d.ts +9 -0
- package/dist/bitmapPixel.d.ts.map +1 -0
- package/dist/bitmapPixel.js +36 -0
- package/dist/bitmapPixel.js.map +1 -0
- package/dist/bitmapPixelate.d.ts +13 -0
- package/dist/bitmapPixelate.d.ts.map +1 -0
- package/dist/bitmapPixelate.js +61 -0
- package/dist/bitmapPixelate.js.map +1 -0
- package/dist/bitmapQuery.d.ts +13 -0
- package/dist/bitmapQuery.d.ts.map +1 -0
- package/dist/bitmapQuery.js +46 -0
- package/dist/bitmapQuery.js.map +1 -0
- package/dist/bitmapRegion.d.ts +20 -0
- package/dist/bitmapRegion.d.ts.map +1 -0
- package/dist/bitmapRegion.js +28 -0
- package/dist/bitmapRegion.js.map +1 -0
- package/dist/bitmapResize.d.ts +17 -0
- package/dist/bitmapResize.d.ts.map +1 -0
- package/dist/bitmapResize.js +191 -0
- package/dist/bitmapResize.js.map +1 -0
- package/dist/bitmapRotate.d.ts +32 -0
- package/dist/bitmapRotate.d.ts.map +1 -0
- package/dist/bitmapRotate.js +143 -0
- package/dist/bitmapRotate.js.map +1 -0
- package/dist/bitmapShadow.d.ts +72 -0
- package/dist/bitmapShadow.d.ts.map +1 -0
- package/dist/bitmapShadow.js +175 -0
- package/dist/bitmapShadow.js.map +1 -0
- package/dist/bitmapSharpen.d.ts +16 -0
- package/dist/bitmapSharpen.d.ts.map +1 -0
- package/dist/bitmapSharpen.js +47 -0
- package/dist/bitmapSharpen.js.map +1 -0
- package/dist/bitmapTone.d.ts +28 -0
- package/dist/bitmapTone.d.ts.map +1 -0
- package/dist/bitmapTone.js +69 -0
- package/dist/bitmapTone.js.map +1 -0
- package/dist/bitmapTransform.d.ts +40 -0
- package/dist/bitmapTransform.d.ts.map +1 -0
- package/dist/bitmapTransform.js +163 -0
- package/dist/bitmapTransform.js.map +1 -0
- package/dist/bitmapWarp.d.ts +48 -0
- package/dist/bitmapWarp.d.ts.map +1 -0
- package/dist/bitmapWarp.js +284 -0
- package/dist/bitmapWarp.js.map +1 -0
- package/dist/contract.d.ts +43 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +43 -0
- package/dist/contract.js.map +1 -0
- package/dist/explainBitmapReadback.d.ts +3 -0
- package/dist/explainBitmapReadback.d.ts.map +1 -0
- package/dist/explainBitmapReadback.js +39 -0
- package/dist/explainBitmapReadback.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
- package/src/bitmap.test.ts +88 -0
- package/src/bitmapAffine.test.ts +98 -0
- package/src/bitmapAlpha.test.ts +110 -0
- package/src/bitmapBevel.test.ts +61 -0
- package/src/bitmapBlur.test.ts +234 -0
- package/src/bitmapChannel.test.ts +97 -0
- package/src/bitmapColorMatrix.test.ts +214 -0
- package/src/bitmapCompare.test.ts +92 -0
- package/src/bitmapComposite.test.ts +259 -0
- package/src/bitmapConvolution.test.ts +130 -0
- package/src/bitmapCopy.test.ts +48 -0
- package/src/bitmapCoverage.test.ts +39 -0
- package/src/bitmapCrop.test.ts +116 -0
- package/src/bitmapDisplacement.test.ts +181 -0
- package/src/bitmapDissolve.test.ts +99 -0
- package/src/bitmapDraw.test.ts +68 -0
- package/src/bitmapEncode.test.ts +18 -0
- package/src/bitmapFill.test.ts +83 -0
- package/src/bitmapFingerprint.test.ts +103 -0
- package/src/bitmapFlip.test.ts +53 -0
- package/src/bitmapFormat.test.ts +124 -0
- package/src/bitmapFrom.test.ts +86 -0
- package/src/bitmapGradient.test.ts +85 -0
- package/src/bitmapGradientFill.test.ts +107 -0
- package/src/bitmapHistogram.test.ts +64 -0
- package/src/bitmapImageChannel.test.ts +19 -0
- package/src/bitmapMedian.test.ts +39 -0
- package/src/bitmapMorphological.test.ts +69 -0
- package/src/bitmapNoise.test.ts +163 -0
- package/src/bitmapPaletteMap.test.ts +49 -0
- package/src/bitmapPixel.test.ts +117 -0
- package/src/bitmapPixelate.test.ts +40 -0
- package/src/bitmapQuery.test.ts +42 -0
- package/src/bitmapRegion.test.ts +34 -0
- package/src/bitmapResize.test.ts +106 -0
- package/src/bitmapRotate.test.ts +108 -0
- package/src/bitmapShadow.test.ts +159 -0
- package/src/bitmapSharpen.test.ts +44 -0
- package/src/bitmapTone.test.ts +104 -0
- package/src/bitmapTransform.test.ts +128 -0
- package/src/bitmapWarp.test.ts +118 -0
- package/src/explainBitmapReadback.test.ts +84 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { invalidateBitmap } from './bitmap';
|
|
2
|
+
import { transformBitmap } from './bitmapAffine';
|
|
3
|
+
/**
|
|
4
|
+
* Rotates the `source` region by `angle` radians into the `dest` region, around
|
|
5
|
+
* a pivot point in source coordinates. `pivotX` and `pivotY` default to the
|
|
6
|
+
* source region centre. `edgeMode` controls out-of-bounds source positions
|
|
7
|
+
* (default `'clamp'`). `sampleMode` controls interpolation quality (default
|
|
8
|
+
* `'bilinear'`).
|
|
9
|
+
*
|
|
10
|
+
* `dest` must not alias `source`.
|
|
11
|
+
*/
|
|
12
|
+
export function rotateBitmap(dest, source, angle, pivotX = (source.width - 1) / 2, pivotY = (source.height - 1) / 2, edgeMode = 'clamp', sampleMode = 'bilinear') {
|
|
13
|
+
const cosA = Math.cos(-angle);
|
|
14
|
+
const sinA = Math.sin(-angle);
|
|
15
|
+
const destPivotX = (dest.width - 1) / 2;
|
|
16
|
+
const destPivotY = (dest.height - 1) / 2;
|
|
17
|
+
const e = pivotX - cosA * destPivotX + sinA * destPivotY;
|
|
18
|
+
const f = pivotY - sinA * destPivotX - cosA * destPivotY;
|
|
19
|
+
transformBitmap(dest, source, [cosA, sinA, -sinA, cosA, e, f], edgeMode, sampleMode);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Rotates the `source` region 180° into the `dest` region. `dest` and `source`
|
|
23
|
+
* must have the same dimensions. Safe to pass the same bitmap and region in
|
|
24
|
+
* `dest` and `source` for an in-place rotation — when aliased, opposite pixels
|
|
25
|
+
* are swapped in pairs; otherwise the regions must not overlap.
|
|
26
|
+
*/
|
|
27
|
+
export function rotateBitmap180(dest, source) {
|
|
28
|
+
const w = Math.min(dest.width, source.width);
|
|
29
|
+
const h = Math.min(dest.height, source.height);
|
|
30
|
+
if (isSameRegion(dest, source)) {
|
|
31
|
+
const data = dest.bitmap.data;
|
|
32
|
+
const stride = dest.bitmap.width;
|
|
33
|
+
const total = w * h;
|
|
34
|
+
const half = total >> 1;
|
|
35
|
+
for (let k = 0; k < half; k++) {
|
|
36
|
+
const ax = dest.x + (k % w);
|
|
37
|
+
const ay = dest.y + Math.floor(k / w);
|
|
38
|
+
const bx = dest.x + (w - 1 - (k % w));
|
|
39
|
+
const by = dest.y + (h - 1 - Math.floor(k / w));
|
|
40
|
+
if (!inBounds(ax, ay, stride, dest.bitmap.height) || !inBounds(bx, by, stride, dest.bitmap.height))
|
|
41
|
+
continue;
|
|
42
|
+
swapPixels(data, (ay * stride + ax) * 4, (by * stride + bx) * 4);
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const sd = source.bitmap.data;
|
|
47
|
+
const dd = dest.bitmap.data;
|
|
48
|
+
const sStride = source.bitmap.width;
|
|
49
|
+
const dStride = dest.bitmap.width;
|
|
50
|
+
for (let py = 0; py < h; py++) {
|
|
51
|
+
const sy = source.y + (h - 1 - py);
|
|
52
|
+
const dy = dest.y + py;
|
|
53
|
+
if (!inBounds(0, sy, sStride, source.bitmap.height) || !inBounds(0, dy, dStride, dest.bitmap.height))
|
|
54
|
+
continue;
|
|
55
|
+
for (let px = 0; px < w; px++) {
|
|
56
|
+
const sx = source.x + (w - 1 - px);
|
|
57
|
+
const dx = dest.x + px;
|
|
58
|
+
if (sx < 0 || sx >= sStride || dx < 0 || dx >= dStride)
|
|
59
|
+
continue;
|
|
60
|
+
copyPixel(dd, (dy * dStride + dx) * 4, sd, (sy * sStride + sx) * 4);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
invalidateBitmap(dest.bitmap);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Rotates the `source` region 90° clockwise into the `dest` region. `dest`'s
|
|
67
|
+
* dimensions must be swapped relative to `source` (`dest.width === source.height`,
|
|
68
|
+
* `dest.height === source.width`). `dest` must not alias `source`.
|
|
69
|
+
*/
|
|
70
|
+
export function rotateBitmapClockwise(dest, source) {
|
|
71
|
+
const sw = source.width;
|
|
72
|
+
const sh = source.height;
|
|
73
|
+
const sd = source.bitmap.data;
|
|
74
|
+
const dd = dest.bitmap.data;
|
|
75
|
+
const sStride = source.bitmap.width;
|
|
76
|
+
const dStride = dest.bitmap.width;
|
|
77
|
+
for (let py = 0; py < sh; py++) {
|
|
78
|
+
const sy = source.y + py;
|
|
79
|
+
if (sy < 0 || sy >= source.bitmap.height)
|
|
80
|
+
continue;
|
|
81
|
+
for (let px = 0; px < sw; px++) {
|
|
82
|
+
const sx = source.x + px;
|
|
83
|
+
if (sx < 0 || sx >= sStride)
|
|
84
|
+
continue;
|
|
85
|
+
const dx = dest.x + (sh - 1 - py);
|
|
86
|
+
const dy = dest.y + px;
|
|
87
|
+
if (dx < 0 || dx >= dStride || dy < 0 || dy >= dest.bitmap.height)
|
|
88
|
+
continue;
|
|
89
|
+
copyPixel(dd, (dy * dStride + dx) * 4, sd, (sy * sStride + sx) * 4);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
invalidateBitmap(dest.bitmap);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Rotates the `source` region 90° counter-clockwise into the `dest` region.
|
|
96
|
+
* `dest`'s dimensions must be swapped relative to `source`
|
|
97
|
+
* (`dest.width === source.height`, `dest.height === source.width`). `dest` must
|
|
98
|
+
* not alias `source`.
|
|
99
|
+
*/
|
|
100
|
+
export function rotateBitmapCounterClockwise(dest, source) {
|
|
101
|
+
const sw = source.width;
|
|
102
|
+
const sh = source.height;
|
|
103
|
+
const sd = source.bitmap.data;
|
|
104
|
+
const dd = dest.bitmap.data;
|
|
105
|
+
const sStride = source.bitmap.width;
|
|
106
|
+
const dStride = dest.bitmap.width;
|
|
107
|
+
for (let py = 0; py < sh; py++) {
|
|
108
|
+
const sy = source.y + py;
|
|
109
|
+
if (sy < 0 || sy >= source.bitmap.height)
|
|
110
|
+
continue;
|
|
111
|
+
for (let px = 0; px < sw; px++) {
|
|
112
|
+
const sx = source.x + px;
|
|
113
|
+
if (sx < 0 || sx >= sStride)
|
|
114
|
+
continue;
|
|
115
|
+
const dx = dest.x + py;
|
|
116
|
+
const dy = dest.y + (sw - 1 - px);
|
|
117
|
+
if (dx < 0 || dx >= dStride || dy < 0 || dy >= dest.bitmap.height)
|
|
118
|
+
continue;
|
|
119
|
+
copyPixel(dd, (dy * dStride + dx) * 4, sd, (sy * sStride + sx) * 4);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
invalidateBitmap(dest.bitmap);
|
|
123
|
+
}
|
|
124
|
+
function copyPixel(dest, di, source, si) {
|
|
125
|
+
dest[di] = source[si];
|
|
126
|
+
dest[di + 1] = source[si + 1];
|
|
127
|
+
dest[di + 2] = source[si + 2];
|
|
128
|
+
dest[di + 3] = source[si + 3];
|
|
129
|
+
}
|
|
130
|
+
function inBounds(x, y, width, height) {
|
|
131
|
+
return x >= 0 && x < width && y >= 0 && y < height;
|
|
132
|
+
}
|
|
133
|
+
function isSameRegion(a, b) {
|
|
134
|
+
return a.bitmap === b.bitmap && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
135
|
+
}
|
|
136
|
+
function swapPixels(data, a, b) {
|
|
137
|
+
for (let c = 0; c < 4; c++) {
|
|
138
|
+
const t = data[a + c];
|
|
139
|
+
data[a + c] = data[b + c];
|
|
140
|
+
data[b + c] = t;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=bitmapRotate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitmapRotate.js","sourceRoot":"","sources":["../src/bitmapRotate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAA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AC,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC;AAC7G,CAAC;AAED,SAAS,UAAU,CAAC,IAAuB,EAAE,CAAS,EAAE,CAAS;IAC/D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { BitmapDropShadowOptions, BitmapGlowOptions, BitmapInnerGlowOptions, BitmapInnerShadowOptions, BitmapRegion } from '@flighthq/types/contract';
|
|
2
|
+
/**
|
|
3
|
+
* Produces the blurred shadow mask for a drop shadow effect, writing into
|
|
4
|
+
* `out`. The result is a tinted, blurred alpha mask derived from `source`.
|
|
5
|
+
*
|
|
6
|
+
* To complete the effect, composite `out` onto the destination at the shadow
|
|
7
|
+
* offset, then apply source compositing:
|
|
8
|
+
*
|
|
9
|
+
* compositeBitmapPixels(destRegion, out); // shadow at (dx+offsetX, dy+offsetY)
|
|
10
|
+
* compositeBitmapRegion(destRegion, source); // sourceMode 'draw'
|
|
11
|
+
* // sourceMode 'hide': omit source; sourceMode 'knockout': destination-out source alpha.
|
|
12
|
+
*
|
|
13
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes.
|
|
14
|
+
* Its contents are undefined after the call.
|
|
15
|
+
*
|
|
16
|
+
* Safe to pass `source.bitmap.data` as `out` when the region covers the
|
|
17
|
+
* full bitmap.
|
|
18
|
+
*/
|
|
19
|
+
export declare function dropShadowBitmap(out: Uint8ClampedArray, scratch: Uint8ClampedArray, source: Readonly<BitmapRegion>, options?: Readonly<BitmapDropShadowOptions>): void;
|
|
20
|
+
/**
|
|
21
|
+
* Produces the blurred glow mask for a glow effect, writing into `out`.
|
|
22
|
+
* The result is a tinted, blurred alpha mask derived from `source`.
|
|
23
|
+
*
|
|
24
|
+
* To complete the effect, composite `out` onto the destination, then
|
|
25
|
+
* apply source compositing:
|
|
26
|
+
*
|
|
27
|
+
* compositeBitmapPixels(destRegion, out); // glow
|
|
28
|
+
* compositeBitmapRegion(destRegion, source); // sourceMode 'draw'
|
|
29
|
+
* // sourceMode 'hide': omit source; sourceMode 'knockout': destination-out source alpha.
|
|
30
|
+
*
|
|
31
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes.
|
|
32
|
+
* Its contents are undefined after the call.
|
|
33
|
+
*
|
|
34
|
+
* Safe to pass `source.bitmap.data` as `out` when the region covers the
|
|
35
|
+
* full bitmap.
|
|
36
|
+
*/
|
|
37
|
+
export declare function glowBitmap(out: Uint8ClampedArray, scratch: Uint8ClampedArray, source: Readonly<BitmapRegion>, options?: Readonly<BitmapGlowOptions>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Produces the inner glow mask for a glow that hugs the inside of the source's
|
|
40
|
+
* alpha boundary, writing into `out`. The inverted source alpha is blurred so
|
|
41
|
+
* that the "outside" bleeds inward, then clipped by the original source alpha so
|
|
42
|
+
* the effect stays within the shape, then tinted.
|
|
43
|
+
*
|
|
44
|
+
* To complete the effect, composite `out` over the original source:
|
|
45
|
+
*
|
|
46
|
+
* compositeBitmapRegion(destRegion, source);
|
|
47
|
+
* compositeBitmapPixels(destRegion, out); // glow on top, inside the shape
|
|
48
|
+
*
|
|
49
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes; its
|
|
50
|
+
* contents are undefined after the call.
|
|
51
|
+
*
|
|
52
|
+
* `out` must NOT alias `source.bitmap.data`: the original source alpha is read
|
|
53
|
+
* again after blurring, so overwriting the source destroys the clip mask.
|
|
54
|
+
*/
|
|
55
|
+
export declare function innerGlowBitmap(out: Uint8ClampedArray, scratch: Uint8ClampedArray, source: Readonly<BitmapRegion>, options?: Readonly<BitmapInnerGlowOptions>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Produces the inner shadow mask for a shadow that hugs the inside of the
|
|
58
|
+
* source's alpha boundary, writing into `out`. Like `innerGlowBitmap` but with
|
|
59
|
+
* an opaque-black default color and a directional `offsetX`/`offsetY`: the
|
|
60
|
+
* inverted-alpha field is sampled shifted by the offset before blurring, so the
|
|
61
|
+
* shadow gathers toward one edge instead of ringing the boundary evenly.
|
|
62
|
+
*
|
|
63
|
+
* To complete the effect, composite `out` over the original source.
|
|
64
|
+
*
|
|
65
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes; its
|
|
66
|
+
* contents are undefined after the call.
|
|
67
|
+
*
|
|
68
|
+
* `out` must NOT alias `source.bitmap.data` — the original source alpha is read
|
|
69
|
+
* again after blurring to clip the result.
|
|
70
|
+
*/
|
|
71
|
+
export declare function innerShadowBitmap(out: Uint8ClampedArray, scratch: Uint8ClampedArray, source: Readonly<BitmapRegion>, options?: Readonly<BitmapInnerShadowOptions>): void;
|
|
72
|
+
//# sourceMappingURL=bitmapShadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitmapShadow.d.ts","sourceRoot":"","sources":["../src/bitmapShadow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EAEb,MAAM,0BAA0B,CAAC;AAIlC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,OAAO,GAAE,QAAQ,CAAC,uBAAuB,CAAM,GAC9C,IAAI,CAGN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,OAAO,GAAE,QAAQ,CAAC,iBAAiB,CAAM,GACxC,IAAI,CAGN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,OAAO,GAAE,QAAQ,CAAC,sBAAsB,CAAM,GAC7C,IAAI,CAGN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,OAAO,GAAE,QAAQ,CAAC,wBAAwB,CAAM,GAC/C,IAAI,CAUN"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { blurBitmapPixelsHorizontal, blurBitmapPixelsVertical } from './bitmapBlur';
|
|
2
|
+
/**
|
|
3
|
+
* Produces the blurred shadow mask for a drop shadow effect, writing into
|
|
4
|
+
* `out`. The result is a tinted, blurred alpha mask derived from `source`.
|
|
5
|
+
*
|
|
6
|
+
* To complete the effect, composite `out` onto the destination at the shadow
|
|
7
|
+
* offset, then apply source compositing:
|
|
8
|
+
*
|
|
9
|
+
* compositeBitmapPixels(destRegion, out); // shadow at (dx+offsetX, dy+offsetY)
|
|
10
|
+
* compositeBitmapRegion(destRegion, source); // sourceMode 'draw'
|
|
11
|
+
* // sourceMode 'hide': omit source; sourceMode 'knockout': destination-out source alpha.
|
|
12
|
+
*
|
|
13
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes.
|
|
14
|
+
* Its contents are undefined after the call.
|
|
15
|
+
*
|
|
16
|
+
* Safe to pass `source.bitmap.data` as `out` when the region covers the
|
|
17
|
+
* full bitmap.
|
|
18
|
+
*/
|
|
19
|
+
export function dropShadowBitmap(out, scratch, source, options = {}) {
|
|
20
|
+
tintBitmapAlphaMask(out, source, options.color ?? 0x000000ff, options.intensity ?? 1);
|
|
21
|
+
applyBlurPasses(out, scratch, source.width, source.height, options);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Produces the blurred glow mask for a glow effect, writing into `out`.
|
|
25
|
+
* The result is a tinted, blurred alpha mask derived from `source`.
|
|
26
|
+
*
|
|
27
|
+
* To complete the effect, composite `out` onto the destination, then
|
|
28
|
+
* apply source compositing:
|
|
29
|
+
*
|
|
30
|
+
* compositeBitmapPixels(destRegion, out); // glow
|
|
31
|
+
* compositeBitmapRegion(destRegion, source); // sourceMode 'draw'
|
|
32
|
+
* // sourceMode 'hide': omit source; sourceMode 'knockout': destination-out source alpha.
|
|
33
|
+
*
|
|
34
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes.
|
|
35
|
+
* Its contents are undefined after the call.
|
|
36
|
+
*
|
|
37
|
+
* Safe to pass `source.bitmap.data` as `out` when the region covers the
|
|
38
|
+
* full bitmap.
|
|
39
|
+
*/
|
|
40
|
+
export function glowBitmap(out, scratch, source, options = {}) {
|
|
41
|
+
tintBitmapAlphaMask(out, source, options.color ?? 0xff0000ff, options.intensity ?? 1);
|
|
42
|
+
applyBlurPasses(out, scratch, source.width, source.height, options);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Produces the inner glow mask for a glow that hugs the inside of the source's
|
|
46
|
+
* alpha boundary, writing into `out`. The inverted source alpha is blurred so
|
|
47
|
+
* that the "outside" bleeds inward, then clipped by the original source alpha so
|
|
48
|
+
* the effect stays within the shape, then tinted.
|
|
49
|
+
*
|
|
50
|
+
* To complete the effect, composite `out` over the original source:
|
|
51
|
+
*
|
|
52
|
+
* compositeBitmapRegion(destRegion, source);
|
|
53
|
+
* compositeBitmapPixels(destRegion, out); // glow on top, inside the shape
|
|
54
|
+
*
|
|
55
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes; its
|
|
56
|
+
* contents are undefined after the call.
|
|
57
|
+
*
|
|
58
|
+
* `out` must NOT alias `source.bitmap.data`: the original source alpha is read
|
|
59
|
+
* again after blurring, so overwriting the source destroys the clip mask.
|
|
60
|
+
*/
|
|
61
|
+
export function innerGlowBitmap(out, scratch, source, options = {}) {
|
|
62
|
+
// Inner glow hugs the boundary symmetrically, so no directional offset (0, 0).
|
|
63
|
+
applyInnerEffect(out, scratch, source, options.color ?? 0xff0000ff, options, 0, 0);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Produces the inner shadow mask for a shadow that hugs the inside of the
|
|
67
|
+
* source's alpha boundary, writing into `out`. Like `innerGlowBitmap` but with
|
|
68
|
+
* an opaque-black default color and a directional `offsetX`/`offsetY`: the
|
|
69
|
+
* inverted-alpha field is sampled shifted by the offset before blurring, so the
|
|
70
|
+
* shadow gathers toward one edge instead of ringing the boundary evenly.
|
|
71
|
+
*
|
|
72
|
+
* To complete the effect, composite `out` over the original source.
|
|
73
|
+
*
|
|
74
|
+
* `scratch` must be at least `source.width * source.height * 4` bytes; its
|
|
75
|
+
* contents are undefined after the call.
|
|
76
|
+
*
|
|
77
|
+
* `out` must NOT alias `source.bitmap.data` — the original source alpha is read
|
|
78
|
+
* again after blurring to clip the result.
|
|
79
|
+
*/
|
|
80
|
+
export function innerShadowBitmap(out, scratch, source, options = {}) {
|
|
81
|
+
applyInnerEffect(out, scratch, source, options.color ?? 0x000000ff, options, options.offsetX ?? 0, options.offsetY ?? 0);
|
|
82
|
+
}
|
|
83
|
+
function applyBlurPasses(out, scratch, width, height, options) {
|
|
84
|
+
const radiusX = Math.max(0, Math.round(options.radiusX ?? 2));
|
|
85
|
+
const radiusY = Math.max(0, Math.round(options.radiusY ?? 2));
|
|
86
|
+
const passes = Math.max(1, Math.round(options.passes ?? 1));
|
|
87
|
+
let a = out;
|
|
88
|
+
let b = scratch;
|
|
89
|
+
for (let pass = 0; pass < passes; pass++) {
|
|
90
|
+
if (radiusX > 0) {
|
|
91
|
+
blurBitmapPixelsHorizontal(b, a, width, height, radiusX);
|
|
92
|
+
const t = a;
|
|
93
|
+
a = b;
|
|
94
|
+
b = t;
|
|
95
|
+
}
|
|
96
|
+
if (radiusY > 0) {
|
|
97
|
+
blurBitmapPixelsVertical(b, a, width, height, radiusY);
|
|
98
|
+
const t = a;
|
|
99
|
+
a = b;
|
|
100
|
+
b = t;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (a !== out) {
|
|
104
|
+
out.set(a.subarray(0, width * height * 4));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function applyInnerEffect(out, scratch, source, color, options, offsetX, offsetY) {
|
|
108
|
+
const w = source.width;
|
|
109
|
+
const h = source.height;
|
|
110
|
+
// Step 1: write the inverted source alpha into out (rgb 0). High outside the
|
|
111
|
+
// shape, low inside — so the blur bleeds the exterior inward across the edge.
|
|
112
|
+
// The field is sampled shifted by (offsetX, offsetY): a nonzero offset pulls the
|
|
113
|
+
// exterior in from one side, so the blurred shadow gathers against the opposite
|
|
114
|
+
// edge (the inner-shadow direction). Zero offset rings the boundary evenly (glow).
|
|
115
|
+
for (let py = 0; py < h; py++) {
|
|
116
|
+
for (let px = 0; px < w; px++) {
|
|
117
|
+
const di = (py * w + px) * 4;
|
|
118
|
+
out[di] = 0;
|
|
119
|
+
out[di + 1] = 0;
|
|
120
|
+
out[di + 2] = 0;
|
|
121
|
+
out[di + 3] = 255 - readSourceAlpha(source, px - offsetX, py - offsetY);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Step 2: blur the inverted-alpha field in place (ping-ponging through scratch).
|
|
125
|
+
applyBlurPasses(out, scratch, w, h, options);
|
|
126
|
+
// Step 3: tint, and clip by the original source alpha so the glow stays inside.
|
|
127
|
+
const cr = (color >>> 24) & 0xff;
|
|
128
|
+
const cg = (color >> 16) & 0xff;
|
|
129
|
+
const cb = (color >> 8) & 0xff;
|
|
130
|
+
const ca = (color & 0xff) / 255;
|
|
131
|
+
const scale = Math.max(0, options.intensity ?? 1) * ca;
|
|
132
|
+
for (let py = 0; py < h; py++) {
|
|
133
|
+
for (let px = 0; px < w; px++) {
|
|
134
|
+
const di = (py * w + px) * 4;
|
|
135
|
+
const blurred = out[di + 3];
|
|
136
|
+
const sourceAlpha = readSourceAlpha(source, px, py);
|
|
137
|
+
out[di] = cr;
|
|
138
|
+
out[di + 1] = cg;
|
|
139
|
+
out[di + 2] = cb;
|
|
140
|
+
out[di + 3] = Math.min(255, Math.round((blurred * sourceAlpha * scale) / 255));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function readSourceAlpha(source, px, py) {
|
|
145
|
+
const sx = source.x + px;
|
|
146
|
+
const sy = source.y + py;
|
|
147
|
+
if (sx < 0 || sx >= source.bitmap.width || sy < 0 || sy >= source.bitmap.height)
|
|
148
|
+
return 0;
|
|
149
|
+
return source.bitmap.data[(sy * source.bitmap.width + sx) * 4 + 3];
|
|
150
|
+
}
|
|
151
|
+
// Used internally by drop-shadow and glow effects.
|
|
152
|
+
function tintBitmapAlphaMask(out, source, color, intensity) {
|
|
153
|
+
const cr = (color >>> 24) & 0xff;
|
|
154
|
+
const cg = (color >> 16) & 0xff;
|
|
155
|
+
const cb = (color >> 8) & 0xff;
|
|
156
|
+
const ca = (color & 0xff) / 255;
|
|
157
|
+
const alphaScale = Math.max(0, intensity) * ca;
|
|
158
|
+
for (let py = 0; py < source.height; py++) {
|
|
159
|
+
const sourceY = source.y + py;
|
|
160
|
+
if (sourceY < 0 || sourceY >= source.bitmap.height)
|
|
161
|
+
continue;
|
|
162
|
+
for (let px = 0; px < source.width; px++) {
|
|
163
|
+
const sourceX = source.x + px;
|
|
164
|
+
if (sourceX < 0 || sourceX >= source.bitmap.width)
|
|
165
|
+
continue;
|
|
166
|
+
const si = (sourceY * source.bitmap.width + sourceX) * 4;
|
|
167
|
+
const di = (py * source.width + px) * 4;
|
|
168
|
+
out[di] = cr;
|
|
169
|
+
out[di + 1] = cg;
|
|
170
|
+
out[di + 2] = cb;
|
|
171
|
+
out[di + 3] = Math.min(255, Math.round(source.bitmap.data[si + 3] * alphaScale));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=bitmapShadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitmapShadow.js","sourceRoot":"","sources":["../src/bitmapShadow.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEpF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAsB,EACtB,OAA0B,EAC1B,MAA8B,EAC9B,UAA6C,EAAE;IAE/C,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,UAAU,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;IACtF,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,UAAU,CACxB,GAAsB,EACtB,OAA0B,EAC1B,MAA8B,EAC9B,UAAuC,EAAE;IAEzC,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,UAAU,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;IACtF,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAsB,EACtB,OAA0B,EAC1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} from '@flighthq/types/contract';
|
|
2
|
+
/**
|
|
3
|
+
* Sharpens `source` into `out` using an unsharp mask: it blurs the source, then
|
|
4
|
+
* adds back `amount × (source − blurred)` so edges are accentuated. This is the
|
|
5
|
+
* radius-based sharpen photo tools use; a fixed 3×3 sharpen is also available
|
|
6
|
+
* via `convolveBitmap`.
|
|
7
|
+
*
|
|
8
|
+
* `scratch` is ping-pong scratch, at least `source.width * source.height * 4`
|
|
9
|
+
* bytes; its contents are undefined after the call. Alpha is left as the source
|
|
10
|
+
* alpha (only RGB is sharpened).
|
|
11
|
+
*
|
|
12
|
+
* `out` must NOT alias `source.bitmap.data`: `out` holds the blurred image
|
|
13
|
+
* while the original source pixels are read again to form the mask.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sharpenBitmap(out: Uint8ClampedArray, scratch: Uint8ClampedArray, source: Readonly<BitmapRegion>, options?: Readonly<BitmapSharpenOptions>): void;
|
|
16
|
+
//# sourceMappingURL=bitmapSharpen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitmapSharpen.d.ts","sourceRoot":"","sources":["../src/bitmapSharpen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAInF;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,OAAO,GAAE,QAAQ,CAAC,oBAAoB,CAAM,GAC3C,IAAI,CA8BN"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { boxBlurBitmap } from './bitmapBlur';
|
|
2
|
+
/**
|
|
3
|
+
* Sharpens `source` into `out` using an unsharp mask: it blurs the source, then
|
|
4
|
+
* adds back `amount × (source − blurred)` so edges are accentuated. This is the
|
|
5
|
+
* radius-based sharpen photo tools use; a fixed 3×3 sharpen is also available
|
|
6
|
+
* via `convolveBitmap`.
|
|
7
|
+
*
|
|
8
|
+
* `scratch` is ping-pong scratch, at least `source.width * source.height * 4`
|
|
9
|
+
* bytes; its contents are undefined after the call. Alpha is left as the source
|
|
10
|
+
* alpha (only RGB is sharpened).
|
|
11
|
+
*
|
|
12
|
+
* `out` must NOT alias `source.bitmap.data`: `out` holds the blurred image
|
|
13
|
+
* while the original source pixels are read again to form the mask.
|
|
14
|
+
*/
|
|
15
|
+
export function sharpenBitmap(out, scratch, source, options = {}) {
|
|
16
|
+
const amount = options.amount ?? 1;
|
|
17
|
+
boxBlurBitmap(out, scratch, source, {
|
|
18
|
+
radiusX: options.radiusX ?? 2,
|
|
19
|
+
radiusY: options.radiusY ?? 2,
|
|
20
|
+
passes: options.passes ?? 1,
|
|
21
|
+
});
|
|
22
|
+
const w = source.width;
|
|
23
|
+
const h = source.height;
|
|
24
|
+
const bitmapWidth = source.bitmap.width;
|
|
25
|
+
const bitmapHeight = source.bitmap.height;
|
|
26
|
+
const data = source.bitmap.data;
|
|
27
|
+
for (let py = 0; py < h; py++) {
|
|
28
|
+
const sy = source.y + py;
|
|
29
|
+
if (sy < 0 || sy >= bitmapHeight)
|
|
30
|
+
continue;
|
|
31
|
+
for (let px = 0; px < w; px++) {
|
|
32
|
+
const sx = source.x + px;
|
|
33
|
+
if (sx < 0 || sx >= bitmapWidth)
|
|
34
|
+
continue;
|
|
35
|
+
const si = (sy * bitmapWidth + sx) * 4;
|
|
36
|
+
const di = (py * w + px) * 4;
|
|
37
|
+
const r = data[si];
|
|
38
|
+
const g = data[si + 1];
|
|
39
|
+
const b = data[si + 2];
|
|
40
|
+
out[di] = r + amount * (r - out[di]);
|
|
41
|
+
out[di + 1] = g + amount * (g - out[di + 1]);
|
|
42
|
+
out[di + 2] = b + amount * (b - out[di + 2]);
|
|
43
|
+
out[di + 3] = data[si + 3];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMapp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EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,WAAW;gBAAE,SAAS;YAC1C,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YACnB,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACvB,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACvB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACrC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;YAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;YAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BitmapRegion } from '@flighthq/types/contract';
|
|
2
|
+
/**
|
|
3
|
+
* Applies a 256-entry per-channel lookup table (LUT) to `out`. The LUT maps
|
|
4
|
+
* each channel's input value (0–255) to an output value (0–255). To apply
|
|
5
|
+
* a single curve to all RGB channels, pass the same array for R, G, and B.
|
|
6
|
+
* To leave a channel unchanged, pass `null`; that channel is copied unchanged.
|
|
7
|
+
*
|
|
8
|
+
* All non-null LUT arrays must have exactly 256 entries. The alpha channel
|
|
9
|
+
* is never remapped unless `alpha` is provided.
|
|
10
|
+
*
|
|
11
|
+
* `out` and `source` may alias the same region — each pixel is read before
|
|
12
|
+
* it is written.
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyBitmapCurve(out: Readonly<BitmapRegion>, source: Readonly<BitmapRegion>, redLut: Readonly<Uint8Array | Uint8ClampedArray | null>, greenLut: Readonly<Uint8Array | Uint8ClampedArray | null>, blueLut: Readonly<Uint8Array | Uint8ClampedArray | null>, alphaLut?: Readonly<Uint8Array | Uint8ClampedArray | null>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Applies a levels adjustment to `out`, stretching pixel values from the input
|
|
17
|
+
* range `[blackPoint, whitePoint]` to the full 0–255 output range, with a
|
|
18
|
+
* mid-tone `gamma` correction applied before the output stretch.
|
|
19
|
+
*
|
|
20
|
+
* - `blackPoint` (default 0): input value that maps to 0 (blacks point).
|
|
21
|
+
* - `whitePoint` (default 255): input value that maps to 255 (whites point).
|
|
22
|
+
* - `gamma` (default 1): exponent for the midtone curve. Values < 1 lighten
|
|
23
|
+
* midtones; values > 1 darken them.
|
|
24
|
+
*
|
|
25
|
+
* Alpha channel is passed through unchanged. `out` and `source` may alias.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyBitmapLevels(out: Readonly<BitmapRegion>, source: Readonly<BitmapRegion>, blackPoint?: number, whitePoint?: number, gamma?: number): void;
|
|
28
|
+
//# sourceMappingURL=bitmapTone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitmapTone.d.ts","sourceRoot":"","sources":["../src/bitmapTone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC3B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,MAAM,EAAE,QAAQ,CAAC,UAAU,GAAG,iBAAiB,GAAG,IAAI,CAAC,EACvD,QAAQ,EAAE,QAAQ,CAAC,UAAU,GAAG,iBAAiB,GAAG,IAAI,CAAC,EACzD,OAAO,EAAE,QAAQ,CAAC,UAAU,GAAG,iBAAiB,GAAG,IAAI,CAAC,EACxD,QAAQ,GAAE,QAAQ,CAAC,UAAU,GAAG,iBAAiB,GAAG,IAAI,CAAQ,GAC/D,IAAI,CA2BN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC3B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,UAAU,GAAE,MAAU,EACtB,UAAU,GAAE,MAAY,EACxB,KAAK,GAAE,MAAU,GAChB,IAAI,CAYN"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { invalidateBitmap } from './bitmap';
|
|
2
|
+
/**
|
|
3
|
+
* Applies a 256-entry per-channel lookup table (LUT) to `out`. The LUT maps
|
|
4
|
+
* each channel's input value (0–255) to an output value (0–255). To apply
|
|
5
|
+
* a single curve to all RGB channels, pass the same array for R, G, and B.
|
|
6
|
+
* To leave a channel unchanged, pass `null`; that channel is copied unchanged.
|
|
7
|
+
*
|
|
8
|
+
* All non-null LUT arrays must have exactly 256 entries. The alpha channel
|
|
9
|
+
* is never remapped unless `alpha` is provided.
|
|
10
|
+
*
|
|
11
|
+
* `out` and `source` may alias the same region — each pixel is read before
|
|
12
|
+
* it is written.
|
|
13
|
+
*/
|
|
14
|
+
export function applyBitmapCurve(out, source, redLut, greenLut, blueLut, alphaLut = null) {
|
|
15
|
+
const w = Math.min(out.width, source.width);
|
|
16
|
+
const h = Math.min(out.height, source.height);
|
|
17
|
+
const od = out.bitmap.data;
|
|
18
|
+
const sd = source.bitmap.data;
|
|
19
|
+
for (let py = 0; py < h; py++) {
|
|
20
|
+
const sy = source.y + py;
|
|
21
|
+
const oy = out.y + py;
|
|
22
|
+
if (sy < 0 || sy >= source.bitmap.height || oy < 0 || oy >= out.bitmap.height)
|
|
23
|
+
continue;
|
|
24
|
+
for (let px = 0; px < w; px++) {
|
|
25
|
+
const sx = source.x + px;
|
|
26
|
+
const ox = out.x + px;
|
|
27
|
+
if (sx < 0 || sx >= source.bitmap.width || ox < 0 || ox >= out.bitmap.width)
|
|
28
|
+
continue;
|
|
29
|
+
const si = (sy * source.bitmap.width + sx) * 4;
|
|
30
|
+
const oi = (oy * out.bitmap.width + ox) * 4;
|
|
31
|
+
// Read inputs before writing (alias-safe).
|
|
32
|
+
const r = sd[si];
|
|
33
|
+
const g = sd[si + 1];
|
|
34
|
+
const b = sd[si + 2];
|
|
35
|
+
const a = sd[si + 3];
|
|
36
|
+
od[oi] = redLut !== null ? redLut[r] : r;
|
|
37
|
+
od[oi + 1] = greenLut !== null ? greenLut[g] : g;
|
|
38
|
+
od[oi + 2] = blueLut !== null ? blueLut[b] : b;
|
|
39
|
+
od[oi + 3] = alphaLut !== null ? alphaLut[a] : a;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
invalidateBitmap(out.bitmap);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Applies a levels adjustment to `out`, stretching pixel values from the input
|
|
46
|
+
* range `[blackPoint, whitePoint]` to the full 0–255 output range, with a
|
|
47
|
+
* mid-tone `gamma` correction applied before the output stretch.
|
|
48
|
+
*
|
|
49
|
+
* - `blackPoint` (default 0): input value that maps to 0 (blacks point).
|
|
50
|
+
* - `whitePoint` (default 255): input value that maps to 255 (whites point).
|
|
51
|
+
* - `gamma` (default 1): exponent for the midtone curve. Values < 1 lighten
|
|
52
|
+
* midtones; values > 1 darken them.
|
|
53
|
+
*
|
|
54
|
+
* Alpha channel is passed through unchanged. `out` and `source` may alias.
|
|
55
|
+
*/
|
|
56
|
+
export function applyBitmapLevels(out, source, blackPoint = 0, whitePoint = 255, gamma = 1) {
|
|
57
|
+
const bp = Math.max(0, Math.min(254, blackPoint));
|
|
58
|
+
const wp = Math.max(bp + 1, Math.min(255, whitePoint));
|
|
59
|
+
const span = wp - bp;
|
|
60
|
+
const invGamma = gamma > 0 ? 1 / gamma : 1;
|
|
61
|
+
// Build a 256-entry LUT so the pixel loop is a fast table lookup.
|
|
62
|
+
const lut = new Uint8ClampedArray(256);
|
|
63
|
+
for (let i = 0; i < 256; i++) {
|
|
64
|
+
const normalized = Math.max(0, Math.min(1, (i - bp) / span));
|
|
65
|
+
lut[i] = Math.round(Math.pow(normalized, invGamma) * 255);
|
|
66
|
+
}
|
|
67
|
+
applyBitmapCurve(out, source, lut, lut, lut, null);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=bitmapTone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitmapTone.js","sourceRoot":"","sources":["../src/bitmapTone.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAA2B,EAC3B,MAA8B,EAC9B,MAAuD,EACvD,QAAyD,EACzD,OAAwD,EACxD,WAA4D,IAAI;IAEhE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC3B,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,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,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC7D,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5D,CAAC;IACD,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ColorScaleBiasLike, Bitmap, BitmapRegion, ThresholdOperation } from '@flighthq/types/contract';
|
|
2
|
+
/**
|
|
3
|
+
* Applies normalized-linear color scale/bias to `source`, writing into `dest`. The transformed
|
|
4
|
+
* size is the overlap of the two regions; pixels outside either bitmap are
|
|
5
|
+
* skipped. Safe to pass the same bitmap and region in `dest` and `source` for
|
|
6
|
+
* in-place modification (each pixel is read before it is written).
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyBitmapColorScaleBias(dest: Readonly<BitmapRegion>, source: Readonly<BitmapRegion>, ct: Readonly<ColorScaleBiasLike>): void;
|
|
9
|
+
/**
|
|
10
|
+
* Tests each pixel of `source` and writes `color` into `dest` where the test
|
|
11
|
+
* passes, or optionally copies the source pixel where it fails. The tested size
|
|
12
|
+
* is the overlap of the two regions. Returns the number of pixels that passed.
|
|
13
|
+
*
|
|
14
|
+
* The comparison is performed on the full packed 0xRRGGBBAA pixel value under
|
|
15
|
+
* `mask`. To test a single channel, supply a mask that isolates it — for
|
|
16
|
+
* example 0x000000ff tests only the alpha byte, and 0xff000000 tests only red.
|
|
17
|
+
*
|
|
18
|
+
* Safe to pass the same bitmap and region in `dest` and `source` (each pixel
|
|
19
|
+
* is read before it is written).
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyBitmapThreshold(dest: Readonly<BitmapRegion>, source: Readonly<BitmapRegion>, operation: ThresholdOperation, thresholdValue: number, color?: number, mask?: number, copySource?: boolean): number;
|
|
22
|
+
/**
|
|
23
|
+
* Blends each channel of `source` into `dest` using per-channel multipliers in
|
|
24
|
+
* [0, 1]: 0 keeps `dest`, 1 replaces with `source`, intermediate values blend
|
|
25
|
+
* proportionally. The blended size is the overlap of the two regions; pixels
|
|
26
|
+
* outside either bitmap are skipped.
|
|
27
|
+
*
|
|
28
|
+
* `dest` and `source` must not reference the same bitmap when their regions
|
|
29
|
+
* overlap at different offsets — the blend reads both, so a write to `dest`
|
|
30
|
+
* corrupts later reads from `source`. The same region in both is safe (the
|
|
31
|
+
* result equals `dest` for every multiplier).
|
|
32
|
+
*/
|
|
33
|
+
export declare function mergeBitmap(dest: Readonly<BitmapRegion>, source: Readonly<BitmapRegion>, redScale: number, greenScale: number, blueScale: number, alphaScale: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Scrolls the content of `out` by `(dx, dy)`, wrapping at the edges.
|
|
36
|
+
* Uses a module-level scratch buffer that grows as needed and is reused
|
|
37
|
+
* across calls.
|
|
38
|
+
*/
|
|
39
|
+
export declare function scrollBitmap(out: Bitmap, dx: number, dy: number): void;
|
|
40
|
+
//# sourceMappingURL=bitmapTransform.d.ts.map
|