feat(ui): entityRasterized action only needs position, not rect

This makes it a bit easier to call the action
This commit is contained in:
psychedelicious
2024-09-11 21:13:28 +10:00
committed by Kent Keirsey
parent cfb538bdc2
commit 5b8707a74f
4 changed files with 5 additions and 7 deletions

View File

@@ -171,11 +171,9 @@ export class CanvasEntityFilterer extends CanvasModuleBase {
this.manager.stateApi.rasterizeEntity({
entityIdentifier: this.parent.entityIdentifier,
imageObject: imageState,
rect: {
position: {
x: Math.round(rect.x),
y: Math.round(rect.y),
width: imageState.image.height,
height: imageState.image.width,
},
replaceObjects: true,
});

View File

@@ -419,7 +419,7 @@ export class CanvasEntityObjectRenderer extends CanvasModuleBase {
this.manager.stateApi.rasterizeEntity({
entityIdentifier: this.parent.entityIdentifier,
imageObject,
rect: { x: Math.round(rect.x), y: Math.round(rect.y), width: imageDTO.width, height: imageDTO.height },
position: { x: Math.round(rect.x), y: Math.round(rect.y) },
replaceObjects,
});
this.manager.cache.imageNameCache.set(hash, imageDTO.image_name);

View File

@@ -950,7 +950,7 @@ export const canvasSlice = createSlice({
}
},
entityRasterized: (state, action: PayloadAction<EntityRasterizedPayload>) => {
const { entityIdentifier, imageObject, rect, replaceObjects } = action.payload;
const { entityIdentifier, imageObject, position, replaceObjects } = action.payload;
const entity = selectEntity(state, entityIdentifier);
if (!entity) {
return;
@@ -959,7 +959,7 @@ export const canvasSlice = createSlice({
if (isRenderableEntity(entity)) {
if (replaceObjects) {
entity.objects = [imageObject];
entity.position = { x: rect.x, y: rect.y };
entity.position = position;
}
}
},

View File

@@ -353,7 +353,7 @@ export type EntityEraserLineAddedPayload = EntityIdentifierPayload<{ eraserLine:
export type EntityRectAddedPayload = EntityIdentifierPayload<{ rect: CanvasRectState }>;
export type EntityRasterizedPayload = EntityIdentifierPayload<{
imageObject: CanvasImageState;
rect: Rect;
position: Coordinate;
replaceObjects: boolean;
}>;