![]() |
|
|
|
#1
|
|||
|
|||
|
can't you:
here it is a VERY stupid C example: Code:
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
void shuffle(char *arr[], int n)
{
for (int i = n - 1; i > 0; --i)
{
int j = rand() % (i + 1);
char *tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
}
int main(void)
{
char *images[] = {
"img1.jpg",
"img2.jpg",
"img3.jpg",
"img4.jpg",
"img5.jpg"
};
int n = sizeof(images) / sizeof(images[0]);
srand((unsigned)time(NULL));
shuffle(images, n);
// show all images exactly once
for (int i = 0; i < n; ++i)
{
printf("%s\n", images[i]);
}
return 0;
}
Code:
extern crate rand;
use rand::rng;
use rand::seq::SliceRandom;
fn main() {
let mut images = vec![
"img1.jpg",
"img2.jpg",
"img3.jpg",
"img4.jpg",
"img5.jpg",
];
let mut r = rng();
// shuffle once
images.shuffle(&mut r);
// show all images exactly once
for img in images {
println!("{}", img);
}
}
Last edited by wild; 05-27-2026 at 13:31. |
| The Following User Says Thank You to wild For This Useful Post: | ||
tonyweb (05-31-2026) | ||
|
#2
|
||||
|
||||
|
good idea to keep "image preloading" valid.
I have implemented random view with your approach. https://github.com/z16166/SimpleImageViewer/releases/tag/v2.2.1 I will reconsider how to implement "Ken Burns effect". It may be an image rendering effect, instead of a transition effect to switch to the next image.
__________________
AKA Solomon/blowfish. Last edited by WhoCares; 05-28-2026 at 20:27. |
| The Following User Says Thank You to WhoCares For This Useful Post: | ||
tonyweb (05-31-2026) | ||
|
#3
|
|||
|
|||
|
You are right: it is an image rendering effect, but please keep it in mind: it gives a new life to slide shows!
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|