memoscan
← all memos

Memo 0xe812bb14…c21be6 on Ethereum

function fisherYatesShuffle(seed,array){let currentIndex=array.length;let temporaryValue,randomIndex;while(currentIndex!==0){randomIndex=(seed+currentIndex)%currentIndex;currentIndex-=1;temporaryValue=array[currentIndex];array[currentIndex]=array[randomIndex];array[randomIndex]=temporaryValue} return array} function generateIndices(seed,totalImages){const array=Array.from({length:totalImages},(_,i)=>i+1);return fisherYatesShuffle(seed,array)} function selectImage(tokenId,totalImages=100){const seed=317694;const indices=generateIndices(seed,totalImages);console.log(`tokenId: ${tokenId}`) console.log(`Selection: ${indices[tokenId % totalImages]}`) return indices[tokenId%totalImages]} const selectedImage=selectImage(tokenData.tokenId);let img;function preload(){img=loadImage(`https://pinata.brightmoments.io/ipfs/QmXQb4SMzPtgwaPiLYyTUseoBQ9ExfKCoNfEhAypcWD41k/${selectedImage}.png`)} function setup(){createCanvas(windowWidth,windowHeight)} function draw(){background(0);let imgAspectRatio=img.width/img.height;let newWidth=width;let newHeight=newWidth/imgAspectRatio;if(newHeight>height){newHeight=height;newWidth=newHeight*imgAspectRatio} let x=(width-newWidth)/2;let y=(height-newHeight)/2;image(img,x,y,newWidth,newHeight)} function windowResized(){resizeCanvas(windowWidth,windowHeight)}