memoscan
← all memos

Memo 0x09418332…25e82b on Ethereum

function mulberry32(seed) { let state = seed; return function() { state |= 0; state = (state + 0x6D2B79F5) | 0; let t = Math.imul(state ^ (state >>> 15), 1 | state); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; // Normalize to [0, 1) }; } function fisherYatesShuffle(seed, array) { let currentIndex = array.length; let temporaryValue, randomIndex; const rng = mulberry32(seed); while (currentIndex !== 0) { randomIndex = Math.floor(rng() * 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 = 1058) { const seed = 57385234; const indices = generateIndices(seed, totalImages); const selection = indices[tokenId % totalImages]; console.log(`tokenId: ${tokenId}`); console.log(`Selection: ${selection}`); return selection; } let tokenId = tokenData.tokenId; const selectedImage = selectImage(tokenId); let img; let CID = "QmWp8iw8W2fkDz3NewXDWgov33ce1A1fgTXLJ22YpnpNxa"; let baseURL = "https://ipfs.brightmoments.io/ipfs" function preload() { img = loadImage(`${baseURL}/${CID}/${selectedImage}.png`); } function setup() { createCanvas(windowWidth, windowHeight); } function draw() { background(255); 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); }