import type {Asset,PlacedAsset,View} from './types.ts'; function hash(text:string){let h=2166136261;for(const c of text)h=Math.imul(h^c.charCodeAt(0),16777619);return (h>>>0)/4294967296;} export function placeAssets(assets:Asset[]):PlacedAsset[]{ let ring=0,start=0,count=1; return assets.map((asset,index)=>{ while(index>=start+count){start+=count;ring++;count=ring*6;} const angle=(index-start)/count*Math.PI*2-Math.PI*0.8+(ring%2)*0.15; const radius=ring*410+(hash(asset.id)-0.5)*38; return {asset,x:ring?Math.cos(angle)*radius:0,y:ring?Math.sin(angle)*radius*0.9:0,size:300+hash(asset.id+'size')*52}; }); } export function visibleAssets(placed:PlacedAsset[],view:View,width:number,height:number,padding=200){return placed.filter(item=>{const x=item.x*view.k+view.x,y=item.y*view.k+view.y,half=item.size*view.k/2;return x+half>-padding&&x-half-padding&&y-half0&&height>0&&dimension>0&&left0&&top0}; }