feat: enhance layer masking functionality and brush controls
- Refactor LayersSheet component to support mask editing state and improve layer visibility handling. - Introduce functions to collect mask layer IDs and count display layers excluding masks. - Update BrushControls to include mask view mode options and a Done button for exiting mask editing. - Modify brush session handling to support brush previews when editing masks. - Implement a new BrushPreviewRenderer for rendering brush strokes with visual feedback. - Add document geometry utilities for transforming points and resolving layer bounds. - Ensure proper cleanup of brush preview on pointer leave and other interactions.
This commit is contained in:
@@ -34,13 +34,19 @@ export function selectedTransformTarget(document: ImageDocument, selection: { ar
|
||||
}
|
||||
|
||||
function applyLayerBounds(document: ImageDocument, layerId: LayerId, bounds: Rect): ImageDocument {
|
||||
return {
|
||||
...document,
|
||||
artboards: document.artboards.map((artboard) => ({
|
||||
...artboard,
|
||||
layers: applyLayerBoundsInTree(document, artboard.layers, layerId, bounds),
|
||||
})),
|
||||
};
|
||||
const layer = findLayer(document, layerId);
|
||||
const targetLayerIds = layer?.clippingMask ? [layerId, layer.clippingMask.maskLayerId] : [layerId];
|
||||
|
||||
return targetLayerIds.reduce(
|
||||
(nextDocument, targetLayerId) => ({
|
||||
...nextDocument,
|
||||
artboards: nextDocument.artboards.map((artboard) => ({
|
||||
...artboard,
|
||||
layers: applyLayerBoundsInTree(nextDocument, artboard.layers, targetLayerId, bounds),
|
||||
})),
|
||||
}),
|
||||
document,
|
||||
);
|
||||
}
|
||||
|
||||
function applyLayerBoundsInTree(document: ImageDocument, layers: Layer[], layerId: LayerId, bounds: Rect): Layer[] {
|
||||
|
||||
Reference in New Issue
Block a user