Skip to content

Commit

Permalink
Improves layout quality grid smoothness
Browse files Browse the repository at this point in the history
  • Loading branch information
jacomyal committed Jun 14, 2024
1 parent b5bcfed commit e3fb0a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/views/graphPage/controllers/GridController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ export const GridController: FC<{ size: number; opacity: number; color: string }
const stageSize = Math.sqrt(width ** 2 + height ** 2) / 2;
const gridSize = slowedSize / ratio;

const finalOpacity =
gridSize > MIN_GRID_SIZE ? slowedOpacity : (slowedOpacity * (gridSize - MIN_GRID_SIZE / 2)) / (MIN_GRID_SIZE / 2);

ctx.clearRect(0, 0, width, height);
if (slowedOpacity <= 0 || gridSize < MIN_GRID_SIZE) return;
if (finalOpacity <= 0) return;

ctx.save();

Expand All @@ -63,8 +66,9 @@ export const GridController: FC<{ size: number; opacity: number; color: string }
gridSize * Math.round((height / 2 - center.y) / gridSize),
);

ctx.globalAlpha = slowedOpacity;
ctx.globalAlpha = finalOpacity;
ctx.strokeStyle = color;
ctx.lineWidth = 1;

for (let x = gridSize / 2; x <= stageSize; x += gridSize) {
for (let r = -1; r <= 1; r += 2) {
Expand Down

0 comments on commit e3fb0a0

Please sign in to comment.