'use client'; import { useGuidesStore } from '@/store'; import { useCanvasStore } from '@/store'; interface RulersAndGuidesProps { canvasWidth: number; canvasHeight: number; } export function RulersAndGuides({ canvasWidth, canvasHeight }: RulersAndGuidesProps) { const { guides, showGuides, showRulers } = useGuidesStore(); const { zoom, offsetX, offsetY } = useCanvasStore(); if (!showGuides && !showRulers) return null; const rulerSize = 20; return ( <> {/* Horizontal Ruler */} {showRulers && (
{Array.from({ length: Math.ceil(canvasWidth / (zoom * 50)) }).map((_, i) => { const x = i * 50 * zoom + offsetX; if (x < 0 || x > canvasWidth) return null; return ( {i * 50} ); })}
)} {/* Vertical Ruler */} {showRulers && (
{Array.from({ length: Math.ceil(canvasHeight / (zoom * 50)) }).map((_, i) => { const y = i * 50 * zoom + offsetY; if (y < 0 || y > canvasHeight) return null; return ( {i * 50} ); })}
)} {/* Guides */} {showGuides && guides.map((guide) => (
))} ); }