forked from struffel/simple-deflicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogress.go
44 lines (34 loc) · 1.29 KB
/
progress.go
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
package main
import (
"fmt"
"math"
"github.com/gosuri/uiprogress"
)
type progressInfo struct {
container *uiprogress.Progress
bars map[string]*uiprogress.Bar
}
func createProgressBars(numberOfPictures int) progressInfo {
var tmpProgress progressInfo
tmpProgress.container = uiprogress.New()
tmpProgress.bars = make(map[string]*uiprogress.Bar)
tmpProgress.bars["analyze"] = tmpProgress.container.AddBar(numberOfPictures).PrependCompleted().PrependElapsed()
tmpProgress.bars["adjust"] = tmpProgress.container.AddBar(numberOfPictures).PrependCompleted().PrependElapsed()
tmpProgress.bars["analyze"].Width = 20
tmpProgress.bars["adjust"].Width = 20
progressBarFunction := func(b *uiprogress.Bar, step string) string {
//Calculate the number of digits to display
n := math.Floor(math.Log10(float64(b.Total)) + 1)
f := fmt.Sprintf("%%-15v %%-%vv/%%-%vv", n, n)
return fmt.Sprintf(f, step, b.Current(), b.Total)
}
progressBarFunctionAnalyze := func(b *uiprogress.Bar) string {
return progressBarFunction(b, "Analyzing")
}
progressBarFunctionAdjust := func(b *uiprogress.Bar) string {
return progressBarFunction(b, "Adjusting")
}
tmpProgress.bars["adjust"].AppendFunc(progressBarFunctionAdjust)
tmpProgress.bars["analyze"].AppendFunc(progressBarFunctionAnalyze)
return tmpProgress
}