-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #617 from Lemoncode/dev
new icons
- Loading branch information
Showing
20 changed files
with
183 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useMemo } from 'react'; | ||
import { Layer, Line } from 'react-konva'; | ||
import { Size } from '@/core/model'; | ||
|
||
const gridSize = 40; // Default grid size (no scaling) | ||
|
||
const GridLine = React.memo( | ||
({ points }: { points: number[] }) => ( | ||
<Line points={points} stroke="rgba(0, 0, 0, 0.1)" strokeWidth={1} /> | ||
), | ||
(prevProps, nextProps) => prevProps.points.join() === nextProps.points.join() | ||
); | ||
|
||
interface Props { | ||
// scale: number; | ||
canvasSize: Size; | ||
} | ||
|
||
export const CanvasGridLayer: React.FC<Props> = ({ canvasSize }) => { | ||
const gridSpacing = gridSize; // Use the original grid size, let Konva handle scaling | ||
const width = canvasSize.width; | ||
const height = canvasSize.height; | ||
|
||
// Memoize the grid lines computation to avoid unnecessary recalculations | ||
const { verticalLines, horizontalLines } = useMemo(() => { | ||
const verticalLines = Array.from( | ||
{ length: Math.ceil(width / gridSpacing) }, | ||
(_, i) => [i * gridSpacing, 0, i * gridSpacing, height] | ||
); | ||
|
||
const horizontalLines = Array.from( | ||
{ length: Math.ceil(height / gridSpacing) }, | ||
(_, i) => [0, i * gridSpacing, width, i * gridSpacing] | ||
); | ||
|
||
return { verticalLines, horizontalLines }; | ||
}, [width, height, gridSpacing]); | ||
|
||
return ( | ||
<Layer> | ||
{/* Render vertical lines */} | ||
{verticalLines.map((points, index) => ( | ||
<GridLine key={`v-line-${index}`} points={points} /> | ||
))} | ||
{/* Render horizontal lines */} | ||
{horizontalLines.map((points, index) => ( | ||
<GridLine key={`h-line-${index}`} points={points} /> | ||
))} | ||
</Layer> | ||
); | ||
}; | ||
|
||
export default CanvasGridLayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters