{"version":3,"file":"CircuitGrid.CeaTHyWY.mjs","names":["React.useRef"],"sources":["https:/framerusercontent.com/modules/f4C24D2nhS4yZlqvlhZm/h2g5zRoham0VfM5wElPd/CircuitGrid.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function CircuitGrid(props){const canvasRef=React.useRef(null);React.useEffect(()=>{const canvas=canvasRef.current;const ctx=canvas.getContext(\"2d\");let animationFrameId;// Configuration from Props\nconst{columns,rows,particleCount,speed,gridColor,particleColor,particleSize}=props;// Set Canvas Size\nconst resizeCanvas=()=>{canvas.width=canvas.offsetWidth;canvas.height=canvas.offsetHeight;};resizeCanvas();window.addEventListener(\"resize\",resizeCanvas);// Calculate grid cell dimensions based on columns and rows independently\nconst cellWidth=canvas.width/columns;const cellHeight=canvas.height/rows;// Particle Class\nclass Particle{reset(){// Snap to grid intersections\nthis.x=Math.floor(Math.random()*columns)*cellWidth;this.y=Math.floor(Math.random()*rows)*cellHeight;// Pick a random cardinal direction (Up, Down, Left, or Right)\nconst dirs=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}];this.dir=dirs[Math.floor(Math.random()*dirs.length)];// Slight offset so they don't spawn all at once visually\nthis.progress=0;}update(){// Move along the current direction\nif(this.dir.x!==0){this.x+=this.dir.x*speed;}if(this.dir.y!==0){this.y+=this.dir.y*speed;}// Turn logic: If we hit a grid intersection exactly\n// We use a small tolerance because floats aren't perfect\nconst atIntersectionX=Math.abs(this.x%cellWidth)<speed;const atIntersectionY=Math.abs(this.y%cellHeight)<speed;if(atIntersectionX&&atIntersectionY){// Snap exactly to grid to prevent drifting off\nthis.x=Math.round(this.x/cellWidth)*cellWidth;this.y=Math.round(this.y/cellHeight)*cellHeight;// 10% chance to change direction at any intersection\nif(Math.random()<.1){const dirs=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}];this.dir=dirs[Math.floor(Math.random()*dirs.length)];}}// Screen Wrap (If it goes off screen, come back other side)\nif(this.x>=canvas.width)this.x=0;if(this.x<0)this.x=Math.floor(columns-1)*cellWidth;if(this.y>=canvas.height)this.y=0;if(this.y<0)this.y=Math.floor(rows-1)*cellHeight;}draw(){ctx.fillStyle=particleColor;// Draw the glowing particle\nctx.shadowBlur=10;ctx.shadowColor=particleColor;ctx.fillRect(this.x-particleSize/2,this.y-particleSize/2,particleSize,particleSize);// Reset shadow for grid\nctx.shadowBlur=0;}constructor(){this.reset();}}// Initialize Particles\nconst particles=[];for(let i=0;i<particleCount;i++){particles.push(new Particle);}// Animation Loop\nconst animate=()=>{// Clear screen\nctx.clearRect(0,0,canvas.width,canvas.height);// Save context state\nctx.save();// Translate by 0.5px to align lines with pixel grid for crisp rendering\nctx.translate(.5,.5);// 1. Draw Static Grid\nctx.beginPath();ctx.strokeStyle=gridColor;ctx.lineWidth=1;// Vertical Lines\nfor(let i=0;i<=columns;i++){let x=Math.floor(i*cellWidth);// Ensure the last line is drawn inside the canvas (closes the box)\nif(i===columns)x=canvas.width-1;ctx.moveTo(x,0);ctx.lineTo(x,canvas.height);}// Horizontal Lines\nfor(let j=0;j<=rows;j++){let y=Math.floor(j*cellHeight);// Ensure the bottom line is drawn inside the canvas (closes the box)\nif(j===rows)y=canvas.height-1;ctx.moveTo(0,y);ctx.lineTo(canvas.width,y);}ctx.stroke();// Restore context state\nctx.restore();// 2. Update and Draw Particles\nparticles.forEach(p=>{p.update();p.draw();});animationFrameId=requestAnimationFrame(animate);};animate();return()=>{window.removeEventListener(\"resize\",resizeCanvas);cancelAnimationFrame(animationFrameId);};},[props]);return /*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{width:\"100%\",height:\"100%\",background:\"transparent\"}});}// Set default size for component\nCircuitGrid.defaultProps={width:500,height:500};// Add Controls to Framer Sidebar\naddPropertyControls(CircuitGrid,{gridColor:{type:ControlType.Color,title:\"Grid Color\",defaultValue:\"rgba(100, 100, 100, 0.3)\"},particleColor:{type:ControlType.Color,title:\"Dot Color\",defaultValue:\"#00F0FF\"},columns:{type:ControlType.Number,title:\"Columns\",defaultValue:12,min:2,max:100,step:1},rows:{type:ControlType.Number,title:\"Rows\",defaultValue:12,min:2,max:100,step:1},particleCount:{type:ControlType.Number,title:\"Density\",defaultValue:20,min:1,max:200},speed:{type:ControlType.Number,title:\"Speed\",unit:\"px/frame\",defaultValue:2,min:.5,max:10,step:.5},particleSize:{type:ControlType.Number,title:\"Dot Size\",unit:\"px\",defaultValue:4,min:1,max:20}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CircuitGrid\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CircuitGrid.map"],"mappings":"0LAA2H,SAAwB,EAAY,EAAM,CAAC,IAAM,EAAUA,EAAa,KAAK,CA2BkB,OA3BjB,MAAoB,CAAC,IAAM,EAAO,EAAU,QAAc,EAAI,EAAO,WAAW,KAAK,CAAK,EAC9R,CAAC,UAAQ,OAAK,gBAAc,QAAM,YAAU,gBAAc,gBAAc,EACvE,MAAiB,CAAC,EAAO,MAAM,EAAO,YAAY,EAAO,OAAO,EAAO,cAAe,GAAc,CAAC,EAAO,iBAAiB,SAAS,EAAa,CACzJ,IAAM,EAAU,EAAO,MAAM,EAAc,EAAW,EAAO,OAAO,EACpE,MAAM,CAAQ,CAAC,OAAO,CACtB,KAAK,EAAE,KAAK,MAAM,KAAK,QAAQ,CAAC,EAAQ,CAAC,EAAU,KAAK,EAAE,KAAK,MAAM,KAAK,QAAQ,CAAC,EAAK,CAAC,EACzF,IAAM,EAAK,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,EAAK,KAAK,MAA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