-
Notifications
You must be signed in to change notification settings - Fork 0
/
gallery.py
57 lines (45 loc) · 1.29 KB
/
gallery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import sequenceGen
import imageio
import os
import pygame
import GUI
import time
_fps = 10
imagePath = 'images'
class Thumps():
currentPath = 0
paths = []
currentBuffer = []
gifIndex = 0
thumps = Thumps()
def setup():
print('setup')
thumps.paths = getThumpnailPaths()
thumps.currentPath = len(thumps.paths)-1
loadImage()
def loadImage():
thumps.currentBuffer = []
path = "images/" + thumps.paths[thumps.currentPath]
for image in os.listdir(path):
print(image)
ext = image.split(".")[-1] # Gather extension
if(ext == 'jpg'):
thumps.currentBuffer.append(pygame.image.load(os.path.join(path, image)))
def switchImage(direction):
thumps.currentPath += direction
thumps.currentPath = min(thumps.currentPath, len(thumps.paths)-1)
thumps.currentPath = max(thumps.currentPath, 0)
loadImage()
def draw():
zigZag = sequenceGen.zigZag(len(thumps.currentBuffer))
image = thumps.currentBuffer[zigZag[thumps.gifIndex % len(zigZag)]]
thumps.gifIndex += 1
GUI.displayImage(image, str(thumps.currentPath+1) + '/' + str(len(thumps.paths)))
pygame.time.wait(50)
def getThumpnailPaths():
gifPaths = []
for filename in os.listdir(imagePath):
currentPath = filename + '/thump/'
if(os.path.exists('images/' + currentPath + '0.jpg')):
gifPaths.append(currentPath)
return sorted(gifPaths)