Skip to content

Commit

Permalink
fix(ui): filter preview offset
Browse files Browse the repository at this point in the history
  • Loading branch information
psychedelicious committed Aug 23, 2024
1 parent a2ad5f1 commit c62ede5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class CanvasFilterModule {
this.imageState = imageDTOToImageObject(imageDTO);
adapter.renderer.clearBuffer();

await adapter.renderer.setBuffer(this.imageState);
await adapter.renderer.setBuffer(this.imageState, true);

adapter.renderer.hideObjects();
this.$isProcessing.set(false);
Expand Down Expand Up @@ -131,6 +131,7 @@ export class CanvasFilterModule {
if (adapter) {
adapter.renderer.clearBuffer();
adapter.renderer.showObjects();
adapter.transformer.updatePosition();
this.$adapter.set(null);
}
this.imageState = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,18 @@ export class CanvasObjectRenderer {
/**
* Sets the buffer object state to render.
* @param objectState The object state to set as the buffer.
* @param resetBufferOffset Whether to reset the buffer's offset to 0,0. This is necessary when previewing filters.
* When previewing a filter, the buffer object is an image of the same size as the entity, so it should be rendered
* at the top-left corner of the entity.
* @returns A promise that resolves to a boolean, indicating if the object was rendered.
*/
setBuffer = async (objectState: AnyObjectState): Promise<boolean> => {
setBuffer = async (objectState: AnyObjectState, resetBufferOffset: boolean = false): Promise<boolean> => {
this.log.trace('Setting buffer');

this.bufferState = objectState;
if (resetBufferOffset) {
this.konva.bufferGroup.offset({ x: 0, y: 0 });
}
return await this.renderBufferObject();
};

Expand Down

0 comments on commit c62ede5

Please sign in to comment.