mirror of
https://github.com/igorski/bitmappery.git
synced 2026-06-16 19:25:38 +02:00
Update to clipping context while drawing
This commit is contained in:
@@ -728,7 +728,7 @@ export default class LayerRenderer extends ZoomableSprite {
|
||||
if ( clipContext ) {
|
||||
// when the layer if offset/transformed and there is no active selection, clip the out of bounds content
|
||||
documentContext.save();
|
||||
clipLayer( documentContext, this.layer, this._bounds, viewport, this._invertSelection );
|
||||
clipLayer( documentContext, this.layer, this._bounds, viewport, false );
|
||||
}
|
||||
renderDrawableCanvas(
|
||||
isDrawingOnMask ? drawContext : documentContext, this.getPaintSize(), this.canvas, this._brush.options.opacity,
|
||||
|
||||
@@ -80,8 +80,9 @@ export const createInverseClipping = ( ctx: CanvasRenderingContext2D, shape: Sha
|
||||
|
||||
/**
|
||||
* Clip the output of a LayerRenderer to not exceed the Layers bounds (in case it is offset or transformed).
|
||||
* This is not necessary as zCanvas will automatically crop the bitmaps, however during live preview while
|
||||
* drawing on the Layer, it helps to clip the contents of the overlaid drawable Canvas.
|
||||
* This is not necessary as zCanvas will automatically crop the bitmaps on render, however during live preview while
|
||||
* drawing on the Layer, we should clip the contents of the overlaid drawable Canvas to hide content that will
|
||||
* be clipped after committing the drawing.
|
||||
*/
|
||||
export const clipLayer = ( ctx: CanvasRenderingContext2D, layer: Layer, rendererBounds: Rectangle, viewport: Viewport, invert = false ): void => {
|
||||
const { scale, rotation, mirrorY } = layer.effects;
|
||||
|
||||
@@ -366,7 +366,7 @@ describe( "LayerRenderer", () => {
|
||||
renderer.draw( ctx, viewport );
|
||||
|
||||
expect( mockRenderOperation ).toHaveBeenCalledWith(
|
||||
"clipLayer", ctx, renderer.layer, renderer.getBounds(), viewport, undefined
|
||||
"clipLayer", ctx, renderer.layer, renderer.getBounds(), viewport, false
|
||||
);
|
||||
});
|
||||
|
||||
@@ -376,7 +376,7 @@ describe( "LayerRenderer", () => {
|
||||
renderer.draw( ctx, viewport );
|
||||
|
||||
expect( mockRenderOperation ).toHaveBeenCalledWith(
|
||||
"clipLayer", ctx, renderer.layer, renderer.getBounds(), viewport, undefined
|
||||
"clipLayer", ctx, renderer.layer, renderer.getBounds(), viewport, false
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user