Line data Source code
1 : interface ImageLayerFilenames {
2 : maskedImage: string
3 : paint: string
4 : paintedImage: string
5 : paintedMaskedImage: string
6 : }
7 :
8 30 : const paintedMaskedImagePrefix = 'clipspace-painted-masked-'
9 :
10 9 : export function imageLayerFilenamesByTimestamp(
11 : timestamp: number
12 : ): ImageLayerFilenames {
13 9 : return {
14 : maskedImage: `clipspace-mask-${timestamp}.png`,
15 : paint: `clipspace-paint-${timestamp}.png`,
16 : paintedImage: `clipspace-painted-${timestamp}.png`,
17 : paintedMaskedImage: `${paintedMaskedImagePrefix}${timestamp}.png`
18 : }
19 : }
20 :
21 30 : export function imageLayerFilenamesIfApplicable(
22 : inputImageFilename: string
23 : ): ImageLayerFilenames | undefined {
24 30 : if (!inputImageFilename.startsWith(paintedMaskedImagePrefix)) return undefined
25 1 : const suffix = inputImageFilename.slice(paintedMaskedImagePrefix.length)
26 : const timestamp = parseInt(suffix.split('.')[0], 10)
27 1 : return imageLayerFilenamesByTimestamp(timestamp)
28 : }
|