import { commandIds } from "@commands/ids"; import type { Asset } from "@core/asset"; import type { LayerId } from "@core/id"; import type { AppStore } from "@editor/store"; import { analyzeMaskSource, applyMaskRasterOperation, createSolidMaskSource, type MaskAnalysis, type MaskRasterOperation } from "@platform/browser/maskRaster"; export type { MaskAnalysis, MaskRasterOperation }; export function analyzeMask(asset: Asset): Promise { return analyzeMaskSource(asset.source, asset.intrinsicSize.w, asset.intrinsicSize.h); } export async function runMaskOperation(maskLayerId: LayerId, asset: Asset, operation: MaskRasterOperation, dispatch: AppStore["dispatch"]) { const source = await applyMaskRasterOperation(asset.source, asset.intrinsicSize.w, asset.intrinsicSize.h, operation); dispatch(commandIds.documentApplyLayerMaskOperation, { maskLayerId, source, mimeType: "image/png", operation }); } export function createRefinementMask(width: number, height: number) { return createSolidMaskSource(width, height, "white"); }