Skip to content

Commit 83aa887

Browse files
brucew4yn3rpduckcomfy
andauthored
[Feature] Enhanced MaskEditor to an Image Canvas (#4361)
Co-authored-by: duckcomfy <[email protected]>
1 parent 37bfc53 commit 83aa887

File tree

6 files changed

+1053
-454
lines changed

6 files changed

+1053
-454
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export interface ImageLayerFilenames {
2+
maskedImage: string
3+
paint: string
4+
paintedImage: string
5+
paintedMaskedImage: string
6+
}
7+
8+
const paintedMaskedImagePrefix = 'clipspace-painted-masked-'
9+
10+
export const imageLayerFilenamesByTimestamp = (
11+
timestamp: number
12+
): ImageLayerFilenames => ({
13+
maskedImage: `clipspace-mask-${timestamp}.png`,
14+
paint: `clipspace-paint-${timestamp}.png`,
15+
paintedImage: `clipspace-painted-${timestamp}.png`,
16+
paintedMaskedImage: `${paintedMaskedImagePrefix}${timestamp}.png`
17+
})
18+
19+
export const imageLayerFilenamesIfApplicable = (
20+
inputImageFilename: string
21+
): ImageLayerFilenames | undefined => {
22+
const isPaintedMaskedImageFilename = inputImageFilename.startsWith(
23+
paintedMaskedImagePrefix
24+
)
25+
if (!isPaintedMaskedImageFilename) return undefined
26+
const suffix = inputImageFilename.slice(paintedMaskedImagePrefix.length)
27+
const timestamp = parseInt(suffix.split('.')[0], 10)
28+
return imageLayerFilenamesByTimestamp(timestamp)
29+
}

0 commit comments

Comments
 (0)