removed unused code

This commit is contained in:
Daniel Sommer 2023-11-30 16:05:35 +01:00
parent 36ef2274c5
commit 61a75b8af3
4 changed files with 0 additions and 183 deletions

View file

@ -1,105 +0,0 @@
package images
// import (
// "runtime"
// "strconv"
// "sync"
// "time"
// "git.velvettear.de/velvettear/image-frame/config"
// "git.velvettear.de/velvettear/loggo"
// )
// // cache for scaled images
// var cache []scaledImage
// // timestamp of the next cache rotation
// var NextRotation time.Time
// // get the previous image from the history and set it as the first scaled image in the cache
// func SetPreviousImage() error {
// previousImage, error := getLatestFromHistory()
// if error != nil {
// return error
// }
// var tmpCache []scaledImage
// tmpCache = append(tmpCache, previousImage)
// tmpCache = append(tmpCache, cache...)
// cache = tmpCache
// tmpCache = nil
// return nil
// }
// // get the first scaled image from the cache
// func GetCachedImage() scaledImage {
// return cache[0]
// }
// // replace the first element in the cache with the last one and add a new scaled image to the cache
// func RotateCache() {
// addToHistory(GetCachedImage())
// loggo.Debug("removing first element from image cache...")
// cacheSize := len(cache)
// if cacheSize == 1 {
// cache = nil
// cacheImages()
// return
// }
// cacheSize--
// cache[0] = cache[cacheSize]
// cache = cache[:cacheSize]
// go cacheImages()
// }
// // start the "slideshow" in a goroutine - rotate the cache based on the set interval
// func startSlideshow() {
// go func() {
// interval := time.Duration(config.GetImageSlideshowInterval()) * time.Second
// for {
// NextRotation = time.Now().Add(interval)
// time.Sleep(interval)
// RotateCache()
// }
// }()
// }
// // fill the cache with scaled images
// func cacheImages() {
// timestamp := time.Now().UnixMilli()
// imageCount := len(images)
// cacheSize := len(cache)
// cacheLimit := config.GetImageCache()
// if imageCount < cacheLimit {
// cacheLimit = imageCount
// }
// imagesToCache := cacheLimit - cacheSize
// if imagesToCache <= 0 {
// return
// }
// concurrency := runtime.NumCPU()
// if imagesToCache < concurrency {
// concurrency = imagesToCache
// }
// loggo.Debug("filling image cache with "+strconv.Itoa(imagesToCache)+" element(s)", "concurrency: "+strconv.Itoa(concurrency))
// var waitgroup sync.WaitGroup
// waitgroup.Add(imagesToCache)
// channel := make(chan struct{}, concurrency)
// var cached int
// for cached = 0; cached < imagesToCache; cached++ {
// channel <- struct{}{}
// var randomScaledImage scaledImage
// randomScaledImage.Name = getRandomImage()
// if randomScaledImage.isCached() {
// continue
// }
// go func(randomScaledImage scaledImage) {
// randomScaledImage.Data = scale(randomScaledImage.Name, config.GetImageWidth(), config.GetImageHeight())
// cache = append(cache, randomScaledImage)
// loggo.Debug("added scaled image '" + randomScaledImage.Name + "' to cache")
// <-channel
// waitgroup.Done()
// }(randomScaledImage)
// }
// waitgroup.Wait()
// loggo.DebugTimed("filled image cache with "+strconv.Itoa(cached)+" images", timestamp)
// }

View file

@ -1,40 +0,0 @@
package images
// import (
// "errors"
// "strconv"
// "time"
// "git.velvettear.de/velvettear/image-frame/config"
// "git.velvettear.de/velvettear/loggo"
// )
// // internal history of displayed images
// var history []scaledImage
// // add a image to the history
// func addToHistory(scaledImage scaledImage) {
// timestamp := time.Now().UnixMilli()
// historyLimit := config.GetImageSlideshowHistory()
// if historyLimit <= 0 {
// return
// }
// history = append(history, scaledImage)
// diff := len(history) - historyLimit
// if diff > 0 {
// history = history[diff:]
// }
// loggo.DebugTimed("added image to history", timestamp, "history size: "+strconv.Itoa(len(history)))
// }
// // get and remove the latest image from history
// func getLatestFromHistory() (scaledImage, error) {
// var scaledImage scaledImage
// if len(history) == 0 {
// return scaledImage, errors.New("history is empty")
// }
// index := len(history) - 1
// scaledImage = history[index]
// history = history[:index]
// return scaledImage, nil
// }

View file

@ -1,7 +0,0 @@
package images
// func Initialize() {
// scanForImages()
// cacheImages()
// startSlideshow()
// }

View file

@ -1,31 +0,0 @@
package images
// import (
// "math/rand"
// )
// // struct for scaled images
// type scaledImage struct {
// Name string
// Data []byte
// }
// // get a random image
// func getRandomImage() string {
// return images[rand.Intn(len(images)-1)]
// }
// // check if the scaled image is already cached
// func (scaledImage *scaledImage) isCached() bool {
// return isCached(scaledImage.Name)
// }
// // check (by name) if the scaled image is already cached
// func isCached(scaledImageName string) bool {
// for _, cachedImage := range cache {
// if cachedImage.Name == scaledImageName {
// return true
// }
// }
// return false
// }