Skip to content

Commit 1c010ed

Browse files
committed
update docker
1 parent 27f097d commit 1c010ed

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

Diff for: Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ docker-build:
55
docker build -t $(DOCKER_IMAGE_NAME) .
66

77
docker-run:
8-
docker run -it --rm -v $(PWD)/frames:/app/frames $(DOCKER_IMAGE_NAME) sh -c "make local-run"
8+
docker run -it --rm -v $(PWD)/frames:/app/frames $(DOCKER_IMAGE_NAME) sh -c "make local-build && ./main $(size)"
9+
10+
local-build:
11+
go build -o main . && chmod +x main
912

1013
local-run:
11-
go build -o main . && chmod +x main && ./main
14+
./main $(size)
1215

13-
.PHONY: docker-build docker-run local-run
16+
.PHONY: docker-build docker-run local-build local-run

Diff for: README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
1. Using docker
88

99
```bash
10-
make docker-build && make docker-run
10+
make docker-build && make docker-run size=128
1111
```
1212

13+
Note: The `size` parameter is optional. The default value is 64. Change it to resize the animation.
14+
1315
2. Using local environment
1416

1517
```bash
1618
make local-run
1719
```
1820

21+
Note: Please don't forget to resize the font size of your terminal to fit the animation.
22+
1923
## Credits
2024

2125
- [GIPHY - Be Animated](https://giphy.com/)

Diff for: assets/demo.gif

-323 KB
Loading

Diff for: main.go

+22-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import (
77
"image/gif"
88
"log"
99
"os"
10+
"strconv"
1011
"time"
1112
)
1213

1314
const (
14-
CHARS = " .:-=+*#%@"
15-
REQ_SIZE = 64
15+
CHARS = " .:-=+*#%@"
16+
// chars add more detail
17+
//CHARS = " .':-~=+*#%@"
1618
)
1719

1820
// reduce the size of the gif to 100x100
@@ -60,10 +62,10 @@ func readGif(fileName string) *gif.GIF {
6062
return gifImage
6163
}
6264

63-
func readFrames(fileName string) []*image.Paletted {
65+
func readFrames(fileName string, reqSize int) []*image.Paletted {
6466
gifImage := readGif(fileName)
6567
// resize the gif
66-
gifImage.Image = resizeFrames(gifImage.Image, REQ_SIZE, REQ_SIZE)
68+
gifImage.Image = resizeFrames(gifImage.Image, reqSize, reqSize)
6769

6870
return gifImage.Image
6971
}
@@ -83,8 +85,22 @@ func clearConsole() {
8385
}
8486

8587
func main() {
88+
reqSize := 64
89+
args := os.Args[1:]
90+
91+
if len(args) > 0 {
92+
newReqSize := 0
93+
94+
for _, arg := range args {
95+
val, _ := strconv.Atoi(arg)
96+
newReqSize += val
97+
}
98+
99+
reqSize = newReqSize
100+
}
101+
86102
fileName := "gifs/tom.gif"
87-
gifImage := readFrames(fileName)
103+
gifImage := readFrames(fileName, reqSize)
88104

89105
frameValues := make([][]int, len(gifImage))
90106

@@ -110,7 +126,7 @@ func main() {
110126

111127
fmt.Printf("\n\n")
112128

113-
time.Sleep(30 * time.Millisecond)
129+
time.Sleep(40 * time.Millisecond)
114130
clearConsole()
115131
}
116132

0 commit comments

Comments
 (0)