mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): move resetScale to transformer
This commit is contained in:
parent
8e2b7845e1
commit
ab16976084
@ -145,17 +145,6 @@ export class CanvasLayer {
|
|||||||
this.konva.objectGroup.opacity(opacity);
|
this.konva.objectGroup.opacity(opacity);
|
||||||
};
|
};
|
||||||
|
|
||||||
resetScale = () => {
|
|
||||||
const attrs = {
|
|
||||||
scaleX: 1,
|
|
||||||
scaleY: 1,
|
|
||||||
rotation: 0,
|
|
||||||
};
|
|
||||||
this.konva.objectGroup.setAttrs(attrs);
|
|
||||||
this.transformer.konva.bboxOutline.setAttrs(attrs);
|
|
||||||
this.transformer.konva.proxyRect.setAttrs(attrs);
|
|
||||||
};
|
|
||||||
|
|
||||||
rasterize = async () => {
|
rasterize = async () => {
|
||||||
this.log.debug('Rasterizing layer');
|
this.log.debug('Rasterizing layer');
|
||||||
|
|
||||||
@ -169,7 +158,6 @@ export class CanvasLayer {
|
|||||||
const imageDTO = await uploadImage(blob, `${this.id}_rasterized.png`, 'other', true);
|
const imageDTO = await uploadImage(blob, `${this.id}_rasterized.png`, 'other', true);
|
||||||
const imageObject = imageDTOToImageObject(imageDTO);
|
const imageObject = imageDTOToImageObject(imageDTO);
|
||||||
await this.renderer.renderObject(imageObject, true);
|
await this.renderer.renderObject(imageObject, true);
|
||||||
this.resetScale();
|
|
||||||
this.manager.stateApi.rasterizeEntity(
|
this.manager.stateApi.rasterizeEntity(
|
||||||
{ id: this.id, imageObject, position: { x: Math.round(rect.x), y: Math.round(rect.y) } },
|
{ id: this.id, imageObject, position: { x: Math.round(rect.x), y: Math.round(rect.y) } },
|
||||||
this.type
|
this.type
|
||||||
|
@ -512,12 +512,32 @@ export class CanvasTransformer {
|
|||||||
|
|
||||||
this.isTransforming = false;
|
this.isTransforming = false;
|
||||||
this.setInteractionMode('off');
|
this.setInteractionMode('off');
|
||||||
this.parent.resetScale();
|
|
||||||
|
// Reset the scale of the the entity. We've either replaced the transformed objects with a rasterized image, or
|
||||||
|
// canceled a transformation. In either case, the scale should be reset.
|
||||||
|
this.resetScale();
|
||||||
|
|
||||||
this.parent.updatePosition();
|
this.parent.updatePosition();
|
||||||
this.updateBbox();
|
this.updateBbox();
|
||||||
this.syncInteractionState();
|
this.syncInteractionState();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the scale of the transformer and the entity.
|
||||||
|
* When the entity is transformed, it's scale and rotation are modified by the transformer. After canceling or applying
|
||||||
|
* a transformation, the scale and rotation should be reset to the original values.
|
||||||
|
*/
|
||||||
|
resetScale = () => {
|
||||||
|
const attrs = {
|
||||||
|
scaleX: 1,
|
||||||
|
scaleY: 1,
|
||||||
|
rotation: 0,
|
||||||
|
};
|
||||||
|
this.parent.konva.objectGroup.setAttrs(attrs);
|
||||||
|
this.konva.bboxOutline.setAttrs(attrs);
|
||||||
|
this.konva.proxyRect.setAttrs(attrs);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the transformer to a specific interaction mode.
|
* Sets the transformer to a specific interaction mode.
|
||||||
* @param interactionMode The mode to set the transformer to. The transformer can be in one of three modes:
|
* @param interactionMode The mode to set the transformer to. The transformer can be in one of three modes:
|
||||||
|
Loading…
Reference in New Issue
Block a user