Skip to content

Commit

Permalink
Fix resizing for triangle shape
Browse files Browse the repository at this point in the history
  • Loading branch information
low-earth-orbit committed Sep 22, 2024
1 parent dfb6e66 commit 3248c6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Project management is handled through [Issues](https://github.com/low-earth-orbi
- Front-end: `React`, `Redux`, `Next.js`, `Konva.js`,`Material UI`
- Programming language: `TypeScript`

## Planning
## Roadmap

Although there isn’t a strict timeline, the project is divided into three phases:

Expand All @@ -23,14 +23,17 @@ Although there isn’t a strict timeline, the project is divided into three phas

- Canvas objects

- Pen & eraser
- Draw
- Text fields
- Shapes
- Rectangle
- Oval
- Triangle
- Star
- Adjustable shape borders (width & color)

- Canvas
- Select object
- History (undo & redo)
- Delete an object or clear the entire canvas
- Keyboard shortcuts for delete/undo/redo actions
Expand Down
1 change: 1 addition & 0 deletions components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export default function Canvas() {
case "triangle":
newShape = {
...baseShape,
height: 43.3, // equilateral triangle
};
break;
case "star":
Expand Down
12 changes: 6 additions & 6 deletions components/shapes/TriangleShape.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export default function TriangleShape({

const adjustedStrokeWidth = getStrokeWidth(strokeWidth, width, height);

// Coordinates for a triangle (equilateral triangle)
// Coordinates for a triangle
const points = [
0,
0, // Top point
width! / 2,
height!, // Bottom-right point
-width! / 2,
height!, // Bottom-left point
adjustedStrokeWidth! / 2, // Top point
width! - adjustedStrokeWidth! / 2,
height! - adjustedStrokeWidth! / 2, // Bottom-right point
adjustedStrokeWidth! / 2,
height! - adjustedStrokeWidth! / 2, // Bottom-left point
];

return (
Expand Down

0 comments on commit 3248c6e

Please sign in to comment.