0xab368307…603fsent to0x7c3ea2b7…0b18·#18,486,314·view on Etherscan
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);
return fisherYatesShuffle(seed, array);
}
function selectImage(tokenId, totalImages = 100) {
const seed = 29614578;
const indices = generateIndices(seed, totalImages);
const selection = indices[tokenId % totalImages].toString().padStart(3, '0');
console.log(`tokenId: ${tokenId}`);
console.log(`Selection: ${selection}`);
return selection;
}
const selectedImage = selectImage(tokenData.tokenId);
let img;
let CID = "QmQbhSFfVp9oeZbWEwyPV28SyNcDdugYXS9m6eKhzk6TDi";
function preload() {
img = loadImage(`https://pinata.brightmoments.io/ipfs/${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);
}
// let tokenData = { tokenId : 19000000, tokenhash : "QmShbQd2SXzdSCjVmDu5RpLrSJ6tJy3toqP3EzQyNeKoE7" }
// function mulberry32(_0x261f6a){let _0x5a3420=_0x261f6a;return function(){_0x5a3420|=0x0,_0x5a3420=_0x5a3420+0x6d2b79f5|0x0;let _0x4e8f92=Math['imul'](_0x5a3420^_0x5a3420>>>0xf,0x1|_0x5a3420);return _0x4e8f92^=_0x4e8f92+Math['imul'](_0x4e8f92^_0x4e8f92>>>0x7,_0x4e8f92|0x3d),((_0x4e8f92^_0x4e8f92>>>0xe)>>>0x0)/0x100000000;};}function fisherYatesShuffle(_0x2421a6,_0x201d4d){let _0x54b896=_0x201d4d['length'],_0x170f40,_0x476859;const _0x36a898=mulberry32(_0x2421a6);while(_0x54b896!==0x0){_0x476859=Math['floor'](_0x36a898()*_0x54b896),_0x54b896-=0x1,_0x170f40=_0x201d4d[_0x54b896],_0x201d4d[_0x54b896]=_0x201d4d[_0x476859],_0x201d4d[_0x476859]=_0x170f40;}return _0x201d4d;}function generateIndices(_0x493300,_0x3a9b45){const _0x208627=Array['from']({'length':_0x3a9b45},(_0xbaa671,_0xa3ef79)=>_0xa3ef79+0x1);return fisherYatesShuffle(_0x493300,_0x208627);}function selectImage(_0x913b38,_0x1776f7=0x21b){const _0x30fb03=(function(){let _0x444164=!![];return function(_0x51c571,_0x5d54dc){const _0x4af36f=_0x444164?function(){if(_0x5d54dc){const _0x4289c9=_0x5d54dc['apply'](_0x51c571,arguments);return _0x5d54dc=null,_0x4289c9;}}:function(){};return _0x444164=![],_0x4af36f;};}()),_0x5a9423=_0x30fb03(this,function(){return _0x5a9423['toString']()['search']('(((.+)+)+)+$')['toString']()['constructor'](_0x5a9423)['search']('(((.+)+)+)+$');});_0x5a9423();const _0x55d6d1=0x1c3e1e9,_0x53264a=generateIndices(_0x55d6d1,_0x1776f7),_0x438918=_0x53264a[_0x913b38%_0x1776f7]['toString']()['padStart'](0x3,'0');return console['log']('tokenId:\x20'+_0x913b38),console['log']('Selection:\x20'+_0x438918),_0x438918;}const selectedImage=selectImage(tokenData['tokenId']);let img,CID='QmShbQd2SXzdSCjVmDu5RpLrSJ6tJy3toqP3EzQyNeKoE7';function preload(){img=loadImage('https://ipfs.brightmoments.io/ipfs/'+CID+'/'+selectedImage+'.png');}function setup(){createCanvas(windowWidth,windowHeight);}function draw(){background(0xff);let _0x32cd97=img['width']/ img['height'],_0x4fd0f0=width,_0x12033a=_0x4fd0f0/_0x32cd97;_0x12033a>height&&(_0x12033a=height,_0x4fd0f0=_0x12033a*_0x32cd97);let _0x37de8c=(width-_0x4fd0f0)/0x2,_0x59cb9e=(height-_0x12033a)/0x2;image(img,_0x37de8c,_0x59cb9e,_0x4fd0f0,_0x12033a);}function windowResized(){resizeCanvas(windowWidth,windowHeight);}