import{_ as t,a as s,A as a,B as e,s as i,e as l,w as c,i as h,o as n,g as o,h as r,u as d,t as x,l as f,p as m,m as u}from"./index-ClhdN-8z.js";const g=t({data:()=>({canvasWidth:300,canvasHeight:300,scale:1,minScale:.1,maxScale:5,scaleStep:.1,ctx:null,pgmData:null}),mounted(){this.initCanvas()},methods:{initCanvas(){const t=s("pgmCanvas",this);this.ctx=t,this.drawPlaceholder()},drawPlaceholder(){if(this.ctx){this.ctx.setFillStyle("#f0f0f0"),this.ctx.fillRect(0,0,this.canvasWidth,this.canvasHeight),this.ctx.setStrokeStyle("#ddd"),this.ctx.setLineWidth(1);for(let t=0;t<=this.canvasWidth;t+=20)this.ctx.beginPath(),this.ctx.moveTo(t,0),this.ctx.lineTo(t,this.canvasHeight),this.ctx.stroke();for(let t=0;t<=this.canvasHeight;t+=20)this.ctx.beginPath(),this.ctx.moveTo(0,t),this.ctx.lineTo(this.canvasWidth,t),this.ctx.stroke();this.ctx.setFillStyle("#999"),this.ctx.setFontSize(16),this.ctx.setTextAlign("center"),this.ctx.fillText("请加载PGM文件",this.canvasWidth/2,this.canvasHeight/2),this.ctx.draw()}},loadPGMFile(){a({title:"加载中..."}),setTimeout((()=>{try{const t=this.generateMockPGMData();this.pgmData=t,this.canvasWidth=t.width,this.canvasHeight=t.height,this.drawPGM(),e(),i({title:"加载成功",icon:"success"})}catch(t){console.error("PGM文件解析失败:",t),e(),i({title:"文件解析失败",icon:"none"})}}),1500)},generateMockPGMData(){const t=300,s=300,a=new Uint8Array(9e4),e=Math.min(t,s)/2;for(let i=0;ithis.minScale&&(this.scale-=this.scaleStep)},resetScale(){this.scale=1}}},[["render",function(t,s,a,e,i,g){const v=f,M=h,p=m,_=u;return n(),l(M,{class:"container"},{default:c((()=>[o(M,{class:"header"},{default:c((()=>[o(v,{class:"title"},{default:c((()=>[r("PGM图像查看器")])),_:1})])),_:1}),o(M,{class:"canvas-container"},{default:c((()=>[o(p,{"canvas-id":"pgmCanvas",id:"pgmCanvas",class:"pgm-canvas",style:d({width:i.canvasWidth+"px",height:i.canvasHeight+"px",transform:`scale(${i.scale})`,transformOrigin:"top left"})},null,8,["style"])])),_:1}),o(M,{class:"controls"},{default:c((()=>[o(M,{class:"zoom-controls"},{default:c((()=>[o(_,{class:"control-btn",onClick:g.zoomOut},{default:c((()=>[o(v,{class:"btn-text"},{default:c((()=>[r("-")])),_:1})])),_:1},8,["onClick"]),o(v,{class:"scale-text"},{default:c((()=>[r(x(Math.round(100*i.scale))+"%",1)])),_:1}),o(_,{class:"control-btn",onClick:g.zoomIn},{default:c((()=>[o(v,{class:"btn-text"},{default:c((()=>[r("+")])),_:1})])),_:1},8,["onClick"])])),_:1}),o(_,{class:"reset-btn",onClick:g.resetScale},{default:c((()=>[r(" 重置缩放 ")])),_:1},8,["onClick"])])),_:1}),o(M,{class:"file-input"},{default:c((()=>[o(_,{onClick:g.loadPGMFile},{default:c((()=>[r("加载PGM文件")])),_:1},8,["onClick"])])),_:1})])),_:1})}],["__scopeId","data-v-22fd1586"]]);export{g as default};