Skip to content

Commit 78b4291

Browse files
authored
Merge pull request #52 from MarkE16/quick-fix
quick functionality and style fixes
2 parents 7237fa6 + 7cc18ee commit 78b4291

10 files changed

Lines changed: 15 additions & 9 deletions

File tree

9.65 KB
Loading
-9.61 KB
Loading
-65.3 KB
Binary file not shown.

src/components/Canvas/Canvas.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const Canvas = forwardRef<HTMLCanvasElement, CanvasProps>(function Canvas(
8989
throw new Error("Couldn't get the 2D context of the canvas.");
9090
}
9191

92-
ctx.globalAlpha = opacity.current;
92+
ctx.globalAlpha = mode === "eraser" ? 1 : opacity.current;
9393

9494
// Clip the drawing to the bounds of the canvas
9595
ctx.save();
@@ -157,7 +157,6 @@ const Canvas = forwardRef<HTMLCanvasElement, CanvasProps>(function Canvas(
157157
mode === "eraser" ? "destination-out" : "source-over";
158158
ctx.fillStyle = color.current;
159159
ctx.strokeStyle = color.current;
160-
// ctx.globalAlpha = mode === "eraser" ? 0 : opacity.current;
161160
ctx.lineWidth = strokeWidth.current * dpi;
162161
const currentShapeMode = shapeMode.current;
163162

src/components/CanvasPane/CanvasPane.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,13 @@ function CanvasPane({ loading }: CanvasPaneProps): ReactNode {
190190
if (!canvasSpace) return;
191191

192192
if (e instanceof WheelEvent) {
193-
console.log(e.deltaY);
194-
performZoom(e.clientX, e.clientY, e.deltaY / 10);
193+
if (e.ctrlKey) {
194+
// Ctrl key means we are zooming.
195+
performZoom(e.clientX, e.clientY, e.deltaY / 10);
196+
} else if (e.shiftKey) {
197+
// Shift key means we are panning horizontally.
198+
changeX(-e.deltaY);
199+
}
195200
// Handle the click event
196201
} else if (e instanceof MouseEvent) {
197202
if (!isClickingOnSpace(e)) return;

src/components/DrawingToolbar/DrawingToolbar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ function DrawingToolbar(): ReactNode {
115115
<Fragment key="settings_Strength">
116116
<span className="text-sm">Stroke Width</span>
117117
<input
118+
className="mx-2"
118119
name={`${mode}_strength`.toUpperCase()}
119120
type="range"
120121
min={strengthSettings.min}
@@ -137,6 +138,7 @@ function DrawingToolbar(): ReactNode {
137138
<Fragment key="settings_Brush">
138139
<Brush />
139140
<input
141+
className="mx-2"
140142
type="range"
141143
id="brush-size"
142144
min={0.01}

src/components/LayerPane/LayerPane.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function LayerPane(): ReactNode {
3434
}
3535
};
3636
const newLayerButtonCss =
37-
"inline-flex justify-center p-1 text-lg bg-[rgb(36,36,36)] hover:bg-[#d1836a] rounded-t-[5px] border border-[rgb(56,55,55)] disabled:bg-[#242424] disabled:text-gray-500";
37+
"inline-flex justify-center p-1 text-lg bg-[rgb(36,36,36)] hover:bg-accent rounded-t-[5px] border border-[rgb(56,55,55)] disabled:bg-[#242424] disabled:text-gray-500";
3838

3939
const newLayerButton =
4040
totalLayers >= MAX_LAYERS ? (

src/components/Navbar/Navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Lib
2-
import logo from "@/assets/icons/IdeaDrawnNewLogo_transparent.png";
2+
import logo from "@/assets/icons/IdeaDrawnNewLogo.png";
33
import { useRef, useCallback, useEffect, useState } from "react";
44
import { useShallow } from "zustand/shallow";
55
import useStore from "@/state/hooks/useStore";

src/state/slices/canvasElementsSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const createCanvasElementsSlice: StateCreator<
4444
...properties, // Override the default properties with the provided properties, if any.
4545
drawType: shapeMode,
4646
strokeWidth,
47-
opacity
47+
opacity: type === "eraser" ? 1 : opacity
4848
};
4949

5050
set((state) => ({

src/state/slices/canvasSlice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ export const createCanvasSlice: StateCreator<
425425
ctx.beginPath();
426426
ctx.rect(x, y, width, height);
427427
ctx.globalCompositeOperation = "destination-over";
428+
ctx.globalAlpha = 1;
428429

429430
if (background === "transparent" && !preview) {
430431
// If the background is transparent, fill with a checkerboard pattern.
@@ -649,8 +650,7 @@ export const createCanvasSlice: StateCreator<
649650
width: 400,
650651
height: 400,
651652
mode: "move",
652-
// background: "#00FFFF",
653-
background: "transparent",
653+
background: "#ffffff",
654654
shape: "rectangle",
655655
shapeMode: "fill",
656656
color: "#000000",

0 commit comments

Comments
 (0)