// Random integer between 0 and 100const value = anime.random(0, 100);// Random decimal between 0 and 1 with 2 decimal placesconst opacity = anime.random(0, 1, 2);// Use in animation propertiesanime({ targets: '.box', translateX: () => anime.random(-250, 250), rotate: () => anime.random(-180, 180), scale: () => anime.random(0.5, 1.5, 2)});
// Create a seeded random generatorconst seededRandom = anime.createSeededRandom(42);// Will always produce the same sequenceconst val1 = seededRandom(0, 100); // Always same for seed 42const val2 = seededRandom(0, 100); // Always same for seed 42// Use in animations for reproducible random effectsconst myRandom = anime.createSeededRandom(12345, 0, 100);anime({ targets: '.box', translateX: () => myRandom(), translateY: () => myRandom()});
// Random element from arrayconst colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#FFA07A'];const randomColor = anime.randomPick(colors);// Random character from stringconst randomLetter = anime.randomPick('ABCDEFGH');// Use in animationsanime({ targets: '.box', backgroundColor: () => anime.randomPick(colors), duration: 1000});