const fs=require('fs'),path=require('path'); const sharp=require('C:/Users/EDY/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/sharp'); const root=path.resolve(__dirname,'../..'),art=path.join(root,'Assets/BuffaloSiege/Art'); async function main(){ const inventory=JSON.parse(fs.readFileSync(path.join(__dirname,'asset-validation.json'))); const animations=JSON.parse(fs.readFileSync(path.join(__dirname,'animation-manifest.json'))); const files=[...inventory.filter(x=>!x.id.startsWith('illustration.')).map(x=>x.id+'.png'),...animations.flatMap(x=>x.files)]; const checks=[]; for(const file of files){ const {data,info}=await sharp(path.join(art,file)).ensureAlpha().raw().toBuffer({resolveWithObject:true});const {width:w,height:h}=info; let edge=0,l=w,t=h,r=0,b=0; for(let y=0;y=w-8||y>=h-8)&&alpha>0)edge++;if(alpha>0){l=Math.min(l,x);t=Math.min(t,y);r=Math.max(r,x);b=Math.max(b,y);}} if(edge)throw Error(file+': opaque pixels inside the 8 px safety border'); checks.push({file,width:w,height:h,edgePixels:edge,padding:[t,w-1-r,h-1-b,l]}); } fs.writeFileSync(path.join(__dirname,'alpha-validation.json'),JSON.stringify(checks,null,2)+'\n'); // Review movie uses the exact imported PNG frames, independent labels and their game frame rates. const dir=path.join(__dirname,'preview-frames');fs.mkdirSync(dir,{recursive:true}); const sprites=await Promise.all(animations.map(a=>Promise.all(a.files.map(f=>sharp(path.join(art,f)).resize(224,224).png().toBuffer())))); const labels=Buffer.from(''+animations.map((a,i)=>''+a.id.toUpperCase()+' ยท '+a.fps+' FPS').join('')+''); for(let n=0;n<72;n++){ const layers=animations.map((a,i)=>({input:sprites[i][Math.floor(n/24*a.fps)%6],left:i%3*240+8,top:Math.floor(i/3)*270+42})); await sharp({create:{width:720,height:540,channels:4,background:'#382638'}}).composite([...layers,{input:labels}]).png().toFile(path.join(dir,'frame-'+String(n).padStart(3,'0')+'.png')); } console.log('60 transparent assets passed the 8 px edge check; 72 review frames ready.'); } main().catch(e=>{console.error(e);process.exit(1);});