feat: add non-destructive adjustment layers

This commit is contained in:
syntaxbullet
2026-07-11 12:31:06 +02:00
parent b928fb599b
commit 606426c885
30 changed files with 427 additions and 49 deletions

26
core/adjustment-layer.ts Normal file
View File

@@ -0,0 +1,26 @@
import type { BaseLayer } from "./base-layer";
export type ColorAdjustment = {
brightness: number;
contrast: number;
saturation: number;
colorBalance: { red: number; green: number; blue: number };
};
/**
* A non-destructive adjustment affecting pixels already composited beneath it
* on its artboard. Adjustment layers are top-level artboard nodes so live WebGL
* and exported PNG compositing have identical scope. Transform and masks are
* intentionally unsupported.
*/
export type AdjustmentLayer = BaseLayer & {
type: "adjustment";
adjustment: ColorAdjustment;
};
export const neutralColorAdjustment: ColorAdjustment = {
brightness: 0,
contrast: 0,
saturation: 0,
colorBalance: { red: 0, green: 0, blue: 0 },
};

View File

@@ -15,6 +15,8 @@ export type {
} from "./geometry";
export type { ArtboardId, AssetId, DocumentId, GenerationCandidateId, GenerationJobId, LayerId } from "./id";
export type { ImageLayer } from "./image-layer";
export type { AdjustmentLayer, ColorAdjustment } from "./adjustment-layer";
export { neutralColorAdjustment } from "./adjustment-layer";
export type { Layer } from "./layer";
export type { LayerMask } from "./layer-mask";
export { getLayerMask, hasLayerMask } from "./layer-mask-utils";

View File

@@ -1,5 +1,6 @@
import type { ImageLayer } from "./image-layer";
import type { LayerGroup } from "./layer-group";
import type { RasterLayer } from "./raster-layer";
import type { AdjustmentLayer } from "./adjustment-layer";
export type Layer = ImageLayer | RasterLayer | LayerGroup;
export type Layer = ImageLayer | RasterLayer | LayerGroup | AdjustmentLayer;