0xac62b7b2…7b94sent to0x9f79e46a…7794·#17,848,547·view on Etherscan
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 = 104456;
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;
var cnv;
function preload() {
img = loadImage(`https://pinata.hodlers.one/ipfs/QmadfHs2ZdRwkVB7KT4UMbkqbFaAHwpVBDTBGTz5Fdy62Z/${selectedImage}.png`);
}
function setup() {
if( windowWidth / windowHeight <= (img.width / img.height) ){
cnv = createCanvas(windowWidth , windowWidth * (img.height / img.width) );
}else{
cnv = createCanvas(windowHeight * (img.width / img.height), windowHeight );
}
cnv.style('display', 'block');
}
function draw() {
background(255);
image(img, 0, 0, width, height);
}
function windowResized() {
if( windowWidth / windowHeight <= (img.width / img.height) ){
resizeCanvas(windowWidth , windowWidth * (img.height / img.width) );
}else{
resizeCanvas(windowHeight * (img.width / img.height), windowHeight );
}
}
function keyTyped() {
if (key === 's') {
img.save('Whispers of Knowledge', 'png');
}
}