{"version":3,"file":"LedMatrix.CBN_DnAz.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/0Wh88yz8Q1Dn9E05zYpc/P1J5Dgny1mykoVfl8S3p/LedMatrix.js"],"sourcesContent":["// LED Matrix component with animated cells and configurable grid\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function LedMatrix(props){const{cellColor=\"#e816af\",trackColor=\"#000000\",frameColor=\"#111111\",backgroundColor=\"#000000\",cellCount=1200,noise=.02,cellSize=12,fps=24,borderWidth=2,overlayColor=\"#000000\",overlayHeight=50,bottomOverlayColor=\"#000000\",bottomOverlayHeight=50}=props;const containerRef=useRef(null);const canvasRef=useRef(null);const contextRef=useRef(null);const gridContextRef=useRef(null);const cellsRef=useRef([]);const gridCanvasRef=useRef(null);const hOffsetRef=useRef(0);const vOffsetRef=useRef(0);const columnsRef=useRef(0);const rowsRef=useRef(0);const animationFrameRef=useRef(null);const lastFrameTimeRef=useRef(0);const updateCells=()=>{cellsRef.current=cellsRef.current.map(([x,y])=>{return[Math.random()>1-noise?Math.floor(Math.random()*columnsRef.current):x,Math.random()>1-noise?Math.floor(Math.random()*rowsRef.current):y];});};const draw=timestamp=>{if(!contextRef.current||!canvasRef.current||!gridCanvasRef.current)return;const frameInterval=1e3/fps;const elapsed=timestamp-lastFrameTimeRef.current;if(elapsed>=frameInterval){lastFrameTimeRef.current=timestamp-elapsed%frameInterval;contextRef.current.clearRect(0,0,canvasRef.current.width,canvasRef.current.height);contextRef.current.drawImage(gridCanvasRef.current,0,0,gridCanvasRef.current.width,gridCanvasRef.current.height);updateCells();for(let i=0;i<cellsRef.current.length;i++){const[x,y]=cellsRef.current[i];contextRef.current.fillStyle=cellColor;contextRef.current.fillRect(x*cellSize+hOffsetRef.current+borderWidth,y*cellSize+vOffsetRef.current+borderWidth,cellSize-borderWidth*2,cellSize-borderWidth*2);}}animationFrameRef.current=requestAnimationFrame(draw);};const setGrid=()=>{if(!gridContextRef.current||!gridCanvasRef.current)return;gridContextRef.current.clearRect(0,0,gridCanvasRef.current.width,gridCanvasRef.current.height);// Fill background with frameColor\ngridContextRef.current.fillStyle=frameColor;gridContextRef.current.fillRect(0,0,gridCanvasRef.current.width,gridCanvasRef.current.height);gridContextRef.current.fillStyle=trackColor;columnsRef.current=Math.ceil(gridCanvasRef.current.width/cellSize);hOffsetRef.current=gridCanvasRef.current.width%cellSize*.5;for(let h=0;h<columnsRef.current;h++){gridContextRef.current.fillRect(h*cellSize+hOffsetRef.current-borderWidth,0,borderWidth*2,gridCanvasRef.current.height);}rowsRef.current=Math.ceil(gridCanvasRef.current.height/cellSize);vOffsetRef.current=gridCanvasRef.current.height%cellSize*.5;for(let v=0;v<rowsRef.current;v++){gridContextRef.current.fillRect(0,v*cellSize+vOffsetRef.current-borderWidth,gridCanvasRef.current.width,borderWidth*2);}cellsRef.current=new Array(cellCount).fill(0).map(()=>[Math.floor(Math.random()*columnsRef.current),Math.floor(Math.random()*rowsRef.current)]);};const refresh=()=>{if(!containerRef.current||!canvasRef.current||!gridCanvasRef.current)return;const width=containerRef.current.offsetWidth;const height=containerRef.current.offsetHeight;canvasRef.current.width=width;canvasRef.current.height=height;gridCanvasRef.current.width=width;gridCanvasRef.current.height=height;if(contextRef.current){contextRef.current.clearRect(0,0,canvasRef.current.width,canvasRef.current.height);}setGrid();};useEffect(()=>{if(typeof window===\"undefined\")return;gridCanvasRef.current=document.createElement(\"canvas\");if(canvasRef.current){contextRef.current=canvasRef.current.getContext(\"2d\");}if(gridCanvasRef.current){gridContextRef.current=gridCanvasRef.current.getContext(\"2d\");}const resizeObserver=new ResizeObserver(()=>{refresh();});if(containerRef.current){resizeObserver.observe(containerRef.current);}refresh();animationFrameRef.current=requestAnimationFrame(draw);return()=>{if(animationFrameRef.current){cancelAnimationFrame(animationFrameRef.current);}resizeObserver.disconnect();};},[]);useEffect(()=>{refresh();},[cellColor,trackColor,frameColor,cellCount,noise,cellSize,fps,borderWidth,overlayColor]);useEffect(()=>{if(animationFrameRef.current){cancelAnimationFrame(animationFrameRef.current);}refresh();lastFrameTimeRef.current=0;animationFrameRef.current=requestAnimationFrame(draw);},[cellSize,cellCount,noise,fps,borderWidth,cellColor]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",backgroundColor:backgroundColor,overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{width:\"100%\",height:\"100%\",display:\"block\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,background:overlayColor,mask:`linear-gradient(to bottom, white 0%, transparent ${overlayHeight}%)`,WebkitMask:`linear-gradient(to bottom, white 0%, transparent ${overlayHeight}%)`,pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,background:bottomOverlayColor,mask:`linear-gradient(to top, white 0%, transparent ${bottomOverlayHeight}%)`,WebkitMask:`linear-gradient(to top, white 0%, transparent ${bottomOverlayHeight}%)`,pointerEvents:\"none\"}})]});}addPropertyControls(LedMatrix,{cellColor:{type:ControlType.Color,title:\"Cell Color\",defaultValue:\"#e816af\"},trackColor:{type:ControlType.Color,title:\"Cell Border\",defaultValue:\"#000000\"},frameColor:{type:ControlType.Color,title:\"Cell Backdrop\",defaultValue:\"#111111\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},overlayColor:{type:ControlType.Color,title:\"Overlay Color\",defaultValue:\"#000000\"},overlayHeight:{type:ControlType.Number,title:\"Overlay Height\",defaultValue:50,min:0,max:200,step:1,unit:\"%\"},bottomOverlayColor:{type:ControlType.Color,title:\"Bottom Overlay Color\",defaultValue:\"#000000\"},bottomOverlayHeight:{type:ControlType.Number,title:\"Bottom Overlay Height\",defaultValue:50,min:0,max:200,step:1,unit:\"%\"},cellCount:{type:ControlType.Number,title:\"Cell Count\",defaultValue:1200,min:1,max:1e4,step:1},noise:{type:ControlType.Number,title:\"Noise\",defaultValue:.02,min:0,max:1,step:.01},cellSize:{type:ControlType.Number,title:\"Cell Size\",defaultValue:12,min:4,max:100,step:1,unit:\"px\"},fps:{type:ControlType.Number,title:\"FPS\",defaultValue:24,min:1,max:60,step:1},borderWidth:{type:ControlType.Number,title:\"Border\",defaultValue:2,min:0,max:10,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LedMatrix\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LedMatrix.map"],"mappings":"kMAIG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,YAAU,UAAU,aAAW,UAAU,aAAW,UAAU,kBAAgB,UAAU,YAAU,KAAK,QAAM,IAAI,WAAS,GAAG,MAAI,GAAG,cAAY,EAAE,eAAa,UAAU,gBAAc,GAAG,qBAAmB,UAAU,sBAAoB,IAAI,EAAY,EAAaA,EAAO,KAAK,CAAO,EAAUA,EAAO,KAAK,CAAO,EAAWA,EAAO,KAAK,CAAO,EAAeA,EAAO,KAAK,CAAO,EAASA,EAAO,EAAE,CAAC,CAAO,EAAcA,EAAO,KAAK,CAAO,EAAWA,EAAO,EAAE,CAAO,EAAWA,EAAO,EAAE,CAAO,EAAWA,EAAO,EAAE,CAAO,EAAQA,EAAO,EAAE,CAAO,EAAkBA,EAAO,KAAK,CAAO,EAAiBA,EAAO,EAAE,CAAO,MAAgB,CAAC,EAAS,QAAQ,EAAS,QAAQ,KAAK,CAAC,EAAE,KAAY,CAAC,KAAK,QAAQ,CAAC,EAAE,EAAM,KAAK,MAAM,KAAK,QAAQ,CAAC,EAAW,QAAQ,CAAC,EAAE,KAAK,QA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