ififfy / flipflip

Random slideshow of local images. Electron app for Mac/Windows/Linux
MIT License
160 stars 44 forks source link

Feature Request: Grid Anti-Duplication #313

Open HarryCordewener opened 1 year ago

HarryCordewener commented 1 year ago

I would love if there was a way if I showed the same scene twice in a Grid, or even across two scenes with a subset of images that overlap, if I could stop a Grid from showing the same picture more than times in the same grid view.

r3a1d3a1 commented 10 months ago

Not just for grid-view, but in general, the proper randomization algorithm is as follows: Have an array that contains paths of all files to be shown. Each time an item is randomly chosen from the array, swap it with the last element, and pop(). (for efficiency, o.w. it'd be O(n) to remove it from the middle of the array, as you're unfortunately doing in here) Once the array is empty (or near empty in case of grid-view), refill it with all the paths again.

r3a1d3a1 commented 4 months ago

@ififfy Also for the second condition of this line, you could use find instead to check if there's at least one element with a different src than the last item, instead of iterating over all elements (which grows to 120 by default!).