mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
remove background from preview images
This commit is contained in:
1 parent
1028e04e02
commit
28a5ff2f9f
4 files changed
+56
-4
No files matched your search
@@ -2,5 +2,6 @@ export { NodeType } from "./constants";
|
||||
export { BaseNode } from "./BaseNode";
|
||||
export { ImageNode } from "./ImageNode";
|
||||
export { VideoNode } from "./VideoNode";
|
||||
export { PreviewCopyNode } from "./PreviewCopy";
|
||||
export { TextNode } from "./TextNode";
|
||||
export { ShapeNode , ShapeType} from "./ShapeNode";
|
||||
@@ -4,11 +4,11 @@ import { MediaNode, Position, Transformation } from "../types";
|
||||
import { uiAccess, uiEvents } from "~/signals";
|
||||
import { NetworkedNode } from "../Nodes/NetworkedNode";
|
||||
import { LoadingBarStatus } from "~/components/ui";
|
||||
import { ImageNode, ShapeNode, TextNode, VideoNode } from "../Nodes";
|
||||
import { ImageNode, ShapeNode, TextNode, VideoNode, PreviewCopyNode } from "../Nodes";
|
||||
import {
|
||||
calculateContextualsPosition,
|
||||
getImageNodeButtonStates,
|
||||
getMultiSelectButtonStates,
|
||||
getMultiSelectButtonStates, getPreviewCopyNodeButtonStates,
|
||||
getShapeNodeButtonStates,
|
||||
getTextNodeButtonStates,
|
||||
getVideoNodeButtonStates,
|
||||
@@ -292,8 +292,15 @@ export class SelectionManager {
|
||||
position: position
|
||||
});
|
||||
}
|
||||
if (node instanceof PreviewCopyNode) {
|
||||
showOrUpdate({
|
||||
knodeIds: [node.kNode.id()],
|
||||
locked: node.isLocked(),
|
||||
buttonStates: getPreviewCopyNodeButtonStates({ locked: node.isLocked() }),
|
||||
position: position
|
||||
});
|
||||
}
|
||||
else if (node instanceof ShapeNode) {
|
||||
console.debug("Selected node is of type ShapeNode", node.kNode.id())
|
||||
showOrUpdate({
|
||||
knodeIds: [node.kNode.id()],
|
||||
locked: node.isLocked(),
|
||||
|
||||
@@ -30,6 +30,7 @@ export function calculateContextualsPosition(kNode: Konva.Transformer) {
|
||||
}
|
||||
return { x: px, y: py };
|
||||
}
|
||||
|
||||
export function getImageNodeButtonStates(
|
||||
props: { locked?: boolean | "unknown" } = {},
|
||||
) {
|
||||
@@ -73,6 +74,50 @@ export function getImageNodeButtonStates(
|
||||
{} as ContextualToolbarProps["buttonStates"],
|
||||
);
|
||||
}
|
||||
|
||||
export function getPreviewCopyNodeButtonStates(
|
||||
props: { locked?: boolean | "unknown" } = {},
|
||||
) {
|
||||
const ButtonNames = ToolbarNodeButtonNames;
|
||||
return Object.values(ButtonNames).reduce(
|
||||
(buttonStates, buttonName) => {
|
||||
// transform button depends on locked state
|
||||
if (props.locked !== undefined && buttonName === ButtonNames.TRANSFORM) {
|
||||
buttonStates.TRANSFORM = {
|
||||
disabled: props.locked === "unknown" || props.locked === true,
|
||||
hidden: false,
|
||||
active: true,
|
||||
};
|
||||
return buttonStates;
|
||||
}
|
||||
|
||||
switch (buttonName) {
|
||||
case ButtonNames.AI_STYLIZE:
|
||||
case ButtonNames.SEGMENTATION:
|
||||
case ButtonNames.DOWNLOAD:
|
||||
case ButtonNames.CHROMA:
|
||||
case ButtonNames.COLOR:
|
||||
// hidden buttons
|
||||
buttonStates[buttonName] = {
|
||||
disabled: true,
|
||||
hidden: true,
|
||||
active: false,
|
||||
};
|
||||
return buttonStates;
|
||||
|
||||
default:
|
||||
// all other buttons
|
||||
buttonStates[buttonName] = {
|
||||
disabled: false,
|
||||
hidden: false,
|
||||
active: false,
|
||||
};
|
||||
return buttonStates;
|
||||
}
|
||||
},
|
||||
{} as ContextualToolbarProps["buttonStates"],
|
||||
);
|
||||
}
|
||||
export function getTextNodeButtonStates(
|
||||
props: { locked?: boolean | "unknown" } = {},
|
||||
) {
|
||||
|
||||
@@ -217,7 +217,6 @@ export class RealTimeDrawEngine {
|
||||
this.previewCopyListener();
|
||||
|
||||
this.listenToServerEvents();
|
||||
|
||||
}
|
||||
|
||||
public async listenToServerEvents() {
|
||||
|
||||
Reference in new issue
Block a user