simplify random img function
This commit is contained in:
parent
b7053c68aa
commit
fc1144cb1d
10
fs.go
10
fs.go
@ -51,13 +51,9 @@ func getImagesList(path string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Randomly choose x number of image from a given folder
|
// Randomly choose x number of image from a given folder
|
||||||
func getRandomImages(number int) []string {
|
func getRandomImage() string {
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
var images []string
|
|
||||||
dir := getImagesList("/home/gator/Photos/")
|
dir := getImagesList("/home/gator/Photos/")
|
||||||
for i := 0; i < number; i++ {
|
index := rand.Intn(len(dir))
|
||||||
index := rand.Intn(len(dir))
|
return dir[index]
|
||||||
images = append(images, dir[index])
|
|
||||||
}
|
|
||||||
return images
|
|
||||||
}
|
}
|
||||||
|
5
main.go
5
main.go
@ -13,9 +13,8 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// get two random images and load them
|
// get two random images and load them
|
||||||
imgs := getRandomImages(2)
|
img1 := loadImage(getRandomImage())
|
||||||
img1 := loadImage(imgs[0])
|
img2 := loadImage(getRandomImage())
|
||||||
img2 := loadImage(imgs[1])
|
|
||||||
|
|
||||||
// pool of workers unionizing, ready to blend a new picture using the power of friendship
|
// pool of workers unionizing, ready to blend a new picture using the power of friendship
|
||||||
var pool blendWorkerPool
|
var pool blendWorkerPool
|
||||||
|
Loading…
Reference in New Issue
Block a user