Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
taga3s committed Aug 18, 2024
1 parent 5cf11ae commit 864e758
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/ascii_art/ascii_art.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func selectRandomly(chars string) string {
return string(chars[r])
}

// Generate generates an ASCII art from an image.
// `Generate` generates an ASCII art from an image.
func Generate(dest image.Image, threshold int) string {
srcBounds := dest.Bounds()

Expand Down
6 changes: 3 additions & 3 deletions internal/img/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"golang.org/x/image/draw"
)

// Load loads an image from a file.
// `Load` loads an image from a file.
func Load(path string) (image.Image, error) {
file, err := os.Open(path)
if err != nil {
Expand All @@ -25,7 +25,7 @@ func Load(path string) (image.Image, error) {
return img, nil
}

// Resize resizes an image to a given width and height.
// `Resize` resizes an image to a given width and height.
func Resize(img image.Image, magnification float64) *image.RGBA {
rect := img.Bounds()

Expand All @@ -48,7 +48,7 @@ func Resize(img image.Image, magnification float64) *image.RGBA {
return dest
}

// UnSync unsynchronizes an image file.
// `UnSync` unsynchronizes an image file.
func UnSync(dest image.Image) error {
tmp, err := os.Create("tmp.png")
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
"github.com/urfave/cli/v2"
)

const (
DefaultThreshold = 128
DefaultMagnification = 1.0
)

type Inputs struct {
path string
threshold int
Expand All @@ -25,14 +30,14 @@ func main() {
Name: "threshold",
Aliases: []string{"t"},
Usage: "the threshold for ASCII Art Generation",
Value: 128,
Value: DefaultThreshold,
Destination: &inputs.threshold,
},
&cli.Float64Flag{
Name: "magnification",
Aliases: []string{"m"},
Usage: "the magnification factor for ASCII Art Generation",
Value: 1.0,
Value: DefaultMagnification,
Destination: &inputs.magnification,
},
},
Expand Down

0 comments on commit 864e758

Please sign in to comment.