Skip to content

Commit

Permalink
Merge pull request #11 from taga3s/refactor
Browse files Browse the repository at this point in the history
update and refactor
  • Loading branch information
taga3s committed Aug 18, 2024
2 parents 5c96616 + aef7f55 commit 5cf11ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ build:
@go build -o ./$(PROJECT_NAME) ./main.go
@echo "Build successful!"

fmt:
@echo "Formatting the code..."
@go fmt ./...

test:
@echo "Running tests..."
@go test -v ./...
Expand Down
4 changes: 2 additions & 2 deletions internal/ascii_art/ascii_art.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
chars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
validChars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)

func selectRandomly(chars string) string {
Expand All @@ -32,7 +32,7 @@ func Generate(dest image.Image, threshold int) string {
if gray.Y < uint8(threshold) {
line.WriteString(" ")
} else {
line.WriteString(selectRandomly(chars))
line.WriteString(selectRandomly(validChars))
}
}

Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func main() {
&cli.IntFlag{
Name: "threshold",
Aliases: []string{"t"},
Usage: "threshold for ASCII art generation",
Usage: "the threshold for ASCII Art Generation",
Value: 128,
Destination: &inputs.threshold,
},
&cli.Float64Flag{
Name: "magnification",
Aliases: []string{"m"},
Usage: "magnification factor for ASCII art generation",
Value: 1,
Usage: "the magnification factor for ASCII Art Generation",
Value: 1.0,
Destination: &inputs.magnification,
},
},
Expand All @@ -42,7 +42,7 @@ func main() {
}
inputs.path = c.Args().Get(0)

run(inputs)
run(&inputs)

return nil
},
Expand All @@ -53,7 +53,7 @@ func main() {
}
}

func run(inputs Inputs) {
func run(inputs *Inputs) {
srcImg, err := img.Load(inputs.path)
if err != nil {
log.Fatalf("Error: %v", err)
Expand Down

0 comments on commit 5cf11ae

Please sign in to comment.