diff --git a/frontend/apps/editor3d/app/src/pages/PageEdit/EditPaintSurface.tsx b/frontend/apps/editor3d/app/src/pages/PageEdit/EditPaintSurface.tsx index 0a77f5a0b4..59dd030507 100644 --- a/frontend/apps/editor3d/app/src/pages/PageEdit/EditPaintSurface.tsx +++ b/frontend/apps/editor3d/app/src/pages/PageEdit/EditPaintSurface.tsx @@ -20,6 +20,8 @@ import { useGlobalMouseUp } from "../PageDraw/hooks/useGlobalMouseUp"; import { useRightPanelLayoutManagement } from "../PageDraw/hooks/useRightPanelLayoutManagement"; import { LineNode } from "../PageDraw/stores/SceneState"; import { Node } from "../PageDraw/Node"; +import { checkerboard } from "@storyteller/common"; +import { loadImageFromUrl } from "~/Helpers/ImageHelpers"; export type EditPaintSurfaceProps = { nodes: Node[]; @@ -58,6 +60,9 @@ export const EditPaintSurface = ({ const [snapshotImage, setSnapshotImage] = useState( null, ); + // TODO: Polish this by using canvas graphics instead of a bitmap + // Or at least manually do the pattern fill to avoid image interpolation + const [checkerImage, setCheckerImage] = useState(null); const rightContainerRef = React.useRef(null); const cursorLayerRef = React.useRef(null); const cursorShapeRef = React.useRef(null); @@ -975,6 +980,11 @@ export const EditPaintSurface = ({ } }, [selectedNodeIds, stageRef, transformerRefs]); + // Load the checkboard image for transparency background + useEffect(() => { + loadImageFromUrl(checkerboard).then(setCheckerImage); + }, []); + return ( + { + ctx.rect(0, 0, store.getAspectRatioDimensions().width, store.getAspectRatioDimensions().height); // leftPanelWidth, leftPanelHeight); + }} + imageSmoothingEnabled={false} // Disable image smoothing for pixel art + > + + { ctx.rect(0, 0, store.getAspectRatioDimensions().width, store.getAspectRatioDimensions().height); // leftPanelWidth, leftPanelHeight); diff --git a/frontend/libs/common/src/index.ts b/frontend/libs/common/src/index.ts index 9840691184..86bf6b115f 100644 --- a/frontend/libs/common/src/index.ts +++ b/frontend/libs/common/src/index.ts @@ -1,3 +1,4 @@ +export * from "./lib/assets"; export * from "./lib/enums"; export * from "./lib/interfaces"; export * from "./lib/types"; diff --git a/frontend/libs/common/src/lib/assets/images/checkerboard.png b/frontend/libs/common/src/lib/assets/images/checkerboard.png new file mode 100644 index 0000000000..44638977cb Binary files /dev/null and b/frontend/libs/common/src/lib/assets/images/checkerboard.png differ diff --git a/frontend/libs/common/src/lib/assets/images/index.ts b/frontend/libs/common/src/lib/assets/images/index.ts new file mode 100644 index 0000000000..0e0f2c1704 --- /dev/null +++ b/frontend/libs/common/src/lib/assets/images/index.ts @@ -0,0 +1,3 @@ +import checkerboard from './checkerboard.png'; + +export { checkerboard }; diff --git a/frontend/libs/common/src/lib/assets/index.ts b/frontend/libs/common/src/lib/assets/index.ts new file mode 100644 index 0000000000..b5ee1278a5 --- /dev/null +++ b/frontend/libs/common/src/lib/assets/index.ts @@ -0,0 +1 @@ +export * from "./images";