pixel-data-js 0.25.0 → 0.25.2
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/index.dev.cjs +221 -165
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +215 -161
- package/dist/index.dev.js.map +1 -1
- package/dist/index.prod.cjs +221 -165
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +74 -43
- package/dist/index.prod.js +216 -162
- package/dist/index.prod.js.map +1 -1
- package/package.json +1 -1
- package/src/History/PixelMutator/mutatorBlendPaintMask.ts +60 -0
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type Color32, type HistoryMutator, MaskType, type PaintMask } from '../../_types'
|
|
2
|
+
import { sourceOverPerfect } from '../../BlendModes/blend-modes-perfect'
|
|
3
|
+
import { blendColorPixelDataAlphaMask } from '../../PixelData/blendColorPixelDataAlphaMask'
|
|
4
|
+
import { blendColorPixelDataBinaryMask } from '../../PixelData/blendColorPixelDataBinaryMask'
|
|
5
|
+
import { PixelWriter } from '../PixelWriter'
|
|
6
|
+
|
|
7
|
+
const defaults = {
|
|
8
|
+
blendColorPixelDataAlphaMask,
|
|
9
|
+
blendColorPixelDataBinaryMask,
|
|
10
|
+
}
|
|
11
|
+
type Deps = Partial<typeof defaults>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param deps - @hidden
|
|
15
|
+
*/
|
|
16
|
+
export const mutatorBlendPaintMask = ((writer: PixelWriter<any>, deps: Partial<Deps> = defaults) => {
|
|
17
|
+
const {
|
|
18
|
+
blendColorPixelDataBinaryMask = defaults.blendColorPixelDataBinaryMask,
|
|
19
|
+
blendColorPixelDataAlphaMask = defaults.blendColorPixelDataAlphaMask,
|
|
20
|
+
} = deps
|
|
21
|
+
|
|
22
|
+
const OPTS = {
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0,
|
|
25
|
+
blendFn: sourceOverPerfect,
|
|
26
|
+
alpha: 255,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
blendColorPaintMask(
|
|
31
|
+
color: Color32,
|
|
32
|
+
mask: PaintMask,
|
|
33
|
+
x: number,
|
|
34
|
+
y: number,
|
|
35
|
+
alpha = 255,
|
|
36
|
+
blendFn = sourceOverPerfect,
|
|
37
|
+
): boolean {
|
|
38
|
+
const tx = x + mask.centerOffsetX
|
|
39
|
+
const ty = y + mask.centerOffsetY
|
|
40
|
+
|
|
41
|
+
const didChange = writer.accumulator.storeRegionBeforeState(tx, ty, mask.w, mask.h)
|
|
42
|
+
|
|
43
|
+
OPTS.x = tx
|
|
44
|
+
OPTS.y = ty
|
|
45
|
+
OPTS.alpha = alpha
|
|
46
|
+
OPTS.blendFn = blendFn
|
|
47
|
+
|
|
48
|
+
if (mask.type === MaskType.BINARY) {
|
|
49
|
+
return didChange(
|
|
50
|
+
blendColorPixelDataBinaryMask(writer.config.target, color, mask, OPTS),
|
|
51
|
+
)
|
|
52
|
+
} else {
|
|
53
|
+
return didChange(
|
|
54
|
+
blendColorPixelDataAlphaMask(writer.config.target, color, mask, OPTS),
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}) satisfies HistoryMutator<any, Deps>
|
|
60
|
+
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './BlendModes/BlendModeRegistry'
|
|
|
12
12
|
export * from './BlendModes/toBlendModeIndexAndName'
|
|
13
13
|
|
|
14
14
|
export * from './Canvas/_constants'
|
|
15
|
+
export * from './Canvas/canvas-blend-modes'
|
|
15
16
|
export * from './Canvas/CanvasFrameRenderer'
|
|
16
17
|
export * from './Canvas/PixelCanvas'
|
|
17
18
|
export * from './Canvas/ReusableCanvas'
|
|
@@ -31,6 +32,7 @@ export * from './History/PixelWriter'
|
|
|
31
32
|
export * from './History/PixelMutator/mutatorApplyAlphaMask'
|
|
32
33
|
export * from './History/PixelMutator/mutatorApplyBinaryMask'
|
|
33
34
|
export * from './History/PixelMutator/mutatorBlendColor'
|
|
35
|
+
export * from './History/PixelMutator/mutatorBlendPaintMask'
|
|
34
36
|
export * from './History/PixelMutator/mutatorBlendPixel'
|
|
35
37
|
export * from './History/PixelMutator/mutatorBlendPixelData'
|
|
36
38
|
export * from './History/PixelMutator/mutatorBlendPixelDataAlphaMask'
|