{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/pb3a4bQsMEdXv7v4mLlK/ex3jdDUt30vZfeUvzWwF/MousePainter.js"],
  "sourcesContent": ["\"use client\";import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";export function MousePainter(){const canvasRef=useRef(null);const[isDrawing,setIsDrawing]=useState(false);const[currentPath,setCurrentPath]=useState([]);const[allPaths,setAllPaths]=useState([]);const tailTrail=useRef([]);const isMouseMoving=useRef(false);const mousePos=useRef({x:0,y:0});const lastSampledPos=useRef(null);const currentColorRef=useRef(0);const scrollPos=useRef({x:0,y:0})// Track scroll position\n;const cycleColors=[\"#1484f4\",\"#ffff00\",\"#ff4a4a\",\"#9d52ff\",\"#0ae7ed\",\"#f45bf0\",\"#ff9b24\",\"#3ce544\"];useEffect(()=>{const canvas=canvasRef.current;const ctx=canvas?.getContext(\"2d\");if(!canvas||!ctx)return;// Get device pixel ratio\n// const dpr = window.devicePixelRatio || 1\nconst dpr=3;const resize=()=>{// Set canvas size in CSS pixels\ncanvas.style.width=window.innerWidth+\"px\";canvas.style.height=window.innerHeight+\"px\";// Set canvas size in actual pixels (accounting for DPR)\ncanvas.width=window.innerWidth*dpr;canvas.height=window.innerHeight*dpr;// Scale the context to match the DPR\nctx.scale(dpr,dpr);// Enable high-quality rendering\nctx.imageSmoothingEnabled=true;ctx.imageSmoothingQuality=\"high\";ctx.lineCap=\"round\"// Rounded line ends\n;ctx.lineJoin=\"round\"// Rounded line corners\n;};// Handle scroll events\nconst handleScroll=()=>{scrollPos.current={x:window.pageXOffset||document.documentElement.scrollLeft,y:window.pageYOffset||document.documentElement.scrollTop};};resize();window.addEventListener(\"resize\",resize);window.addEventListener(\"scroll\",handleScroll);let animationId=null;const draw=()=>{// Clear with proper dimensions\nctx.clearRect(0,0,canvas.width/dpr,canvas.height/dpr);// Apply scroll offset to the context\nctx.save();ctx.translate(-scrollPos.current.x,-scrollPos.current.y);// Draw existing paths with better quality\nallPaths.forEach(path=>{if(path.length<2)return;ctx.save();ctx.strokeStyle=path[0].color;ctx.lineWidth=2// Thicker lines for better quality\n;ctx.shadowColor=path[0].color;// ctx.shadowBlur = 1;\nctx.shadowOffsetX=0;ctx.shadowOffsetY=0;ctx.beginPath();ctx.moveTo(path[0].x,path[0].y);for(let i=1;i<path.length;i++){ctx.lineTo(path[i].x,path[i].y);}ctx.stroke();ctx.restore();});// Draw current path with better quality\nif(isDrawing&&currentPath.length>1){ctx.save();ctx.strokeStyle=currentPath[0].color;ctx.lineWidth=2// Thicker lines for better quality\n;ctx.shadowColor=currentPath[0].color;// ctx.shadowBlur = 1;\nctx.shadowOffsetX=0;ctx.shadowOffsetY=0;ctx.beginPath();ctx.moveTo(currentPath[0].x,currentPath[0].y);for(let i=1;i<currentPath.length;i++){ctx.lineTo(currentPath[i].x,currentPath[i].y);}ctx.stroke();ctx.restore();}// Draw the smooth tail trail with better quality\nif(!isDrawing&&tailTrail.current.length>2){ctx.save();ctx.lineWidth=2// Thicker lines for better quality\n;ctx.shadowColor=tailTrail.current[tailTrail.current.length-1].color;// ctx.shadowBlur = 2;\nctx.shadowOffsetX=0;ctx.shadowOffsetY=0;ctx.beginPath();const points=tailTrail.current.map(p=>({x:p.x,y:p.y,color:p.color}));ctx.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length-1;i++){const current=points[i];const next=points[i+1];const controlX=(current.x+next.x)/2;const controlY=(current.y+next.y)/2;ctx.quadraticCurveTo(current.x,current.y,controlX,controlY);}ctx.lineTo(points[points.length-1].x,points[points.length-1].y);ctx.strokeStyle=points[points.length-1].color;ctx.stroke();ctx.restore();}// Draw the head circle with better quality\nctx.save();ctx.fillStyle=cycleColors[currentColorRef.current];ctx.shadowColor=cycleColors[currentColorRef.current];// ctx.shadowBlur = 3;\nctx.shadowOffsetX=0;ctx.shadowOffsetY=0;ctx.beginPath();ctx.arc(mousePos.current.x,mousePos.current.y,7,0,Math.PI*2);ctx.fill();// Add a subtle glow effect\n// ctx.shadowBlur = 6;\n// ctx.globalAlpha = 0.4;\nctx.fill();ctx.restore();// Restore the context (removes scroll offset)\nctx.restore();// Manage trail length and decay\nconst MAX_TRAIL_LENGTH=250;const DECAY_RATE=4// Remove 2 points per frame when not moving // SPEED\n;if(!isDrawing&&tailTrail.current.length>MAX_TRAIL_LENGTH){// Remove excess points from the beginning\ntailTrail.current.splice(0,tailTrail.current.length-MAX_TRAIL_LENGTH);}else if(!isMouseMoving.current&&tailTrail.current.length>0){// Gradual decay when idle\nconst pointsToRemove=Math.min(DECAY_RATE,tailTrail.current.length);tailTrail.current.splice(0,pointsToRemove);}if(!isDrawing){isMouseMoving.current=false;}// Schedule the next frame and store the ID\nanimationId=requestAnimationFrame(draw);};// Start the animation loop\nif(window.innerWidth>768){animationId=requestAnimationFrame(draw);}// Cleanup function to cancel the animation\nreturn()=>{if(animationId!==null){cancelAnimationFrame(animationId);}window.removeEventListener(\"resize\",resize);window.removeEventListener(\"scroll\",handleScroll);};},[allPaths,currentPath,isDrawing]);useEffect(()=>{const handleMouseMove=e=>{// Account for scroll position\nconst newPos={x:e.clientX+scrollPos.current.x,y:e.clientY+scrollPos.current.y};mousePos.current=newPos;isMouseMoving.current=true;// Add new point to trail with timestamp\nconst now=Date.now();if(!lastSampledPos.current){lastSampledPos.current={...newPos};tailTrail.current.push({...newPos,timestamp:now,color:cycleColors[currentColorRef.current]});}else{const prev=lastSampledPos.current;const dx=newPos.x-prev.x;const dy=newPos.y-prev.y;const dist=Math.sqrt(dx*dx+dy*dy);// Only add interpolation points if distance is significant\nif(dist>3){const stepSize=3// 3px between points for smoother curves\n;const steps=Math.max(1,Math.floor(dist/stepSize));for(let i=1;i<=steps;i++){const t=i/steps;const interpolated={x:prev.x+dx*t,y:prev.y+dy*t,timestamp:now,color:cycleColors[currentColorRef.current]};tailTrail.current.push(interpolated);}}// Always add the final position\ntailTrail.current.push({...newPos,timestamp:now,color:cycleColors[currentColorRef.current]});lastSampledPos.current={...newPos};}if(isDrawing){setCurrentPath(path=>[...path,{...newPos,color:cycleColors[currentColorRef.current]}]);}};const handleMouseDown=e=>{// Use the current mouse event position instead of stored mousePos\nconst currentMousePos={x:e.clientX+scrollPos.current.x,y:e.clientY+scrollPos.current.y};// Update mousePos to the current position\nmousePos.current=currentMousePos;setCurrentPath([{...currentMousePos,color:cycleColors[currentColorRef.current]}]);setIsDrawing(true);};const handleMouseUp=()=>{setIsDrawing(false);currentColorRef.current=(currentColorRef.current+1)%cycleColors.length;if(currentPath.length>1){setAllPaths(paths=>[...paths,currentPath]);}setCurrentPath([]);tailTrail.current=[];lastSampledPos.current=null;// Don't clear the trail - let it continue naturally\n};window.addEventListener(\"mousemove\",handleMouseMove);window.addEventListener(\"mousedown\",handleMouseDown);window.addEventListener(\"mouseup\",handleMouseUp);return()=>{window.removeEventListener(\"mousemove\",handleMouseMove);window.removeEventListener(\"mousedown\",handleMouseDown);window.removeEventListener(\"mouseup\",handleMouseUp);};},[isDrawing,currentPath])// No dependencies - keep event listeners stable\n;return /*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{position:\"fixed\",top:0,left:0,width:\"100vw\",height:\"100vh\",zIndex:9999,pointerEvents:\"none\",userSelect:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",WebkitTouchCallout:\"none\"}});}\nexport const __FramerMetadata__ = {\"exports\":{\"MousePainter\":{\"type\":\"reactComponent\",\"name\":\"MousePainter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MousePainter.map"],
  "mappings": "uGAA4G,SAASA,GAAc,CAAC,IAAMC,EAAUC,EAAO,IAAI,EAAO,CAACC,EAAUC,CAAY,EAAEC,EAAS,EAAK,EAAO,CAACC,EAAYC,CAAc,EAAEF,EAAS,CAAC,CAAC,EAAO,CAACG,EAASC,CAAW,EAAEJ,EAAS,CAAC,CAAC,EAAQK,EAAUR,EAAO,CAAC,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ColorRef", "scrollPos", "cycleColors", "ue", "canvas", "ctx", "dpr", "resize", "window", "handleScroll", "animationId", "draw", "path", "i", "points", "p", "current", "next", "controlX", "controlY", "MAX_TRAIL_LENGTH", "DECAY_RATE", "pointsToRemove", "handleMouseMove", "e", "newPos", "now", "prev", "dx", "dy", "dist", "steps", "t", "interpolated", "handleMouseDown", "currentMousePos", "handleMouseUp", "paths"]
}
