-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tablewriter to improve printing, made main and screenshot funct…
…ions more reusable, updated readme and improved tests
- Loading branch information
Showing
9 changed files
with
251 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package pokemonbattleadvisor | ||
|
||
import ( | ||
"fmt" | ||
"github.com/kbinani/screenshot" | ||
"image" | ||
"image/png" | ||
"os" | ||
) | ||
|
||
const defaultScreenshotPath = "screenshot.png" | ||
|
||
func save(img *image.RGBA, filePath string) (err error) { | ||
var file *os.File | ||
file, err = os.Create(filePath) | ||
if err != nil { | ||
return err | ||
} | ||
defer file.Close() | ||
err = png.Encode(file, img) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func TakeScreenshot(monitorIndex int, boundaries ...int) (string, error) { | ||
var img *image.RGBA | ||
var err error | ||
|
||
if !(len(boundaries) == 4) { | ||
fmt.Printf("No correct boundaries provided, taking full screenshot\n") | ||
img, err = screenshot.CaptureDisplay(monitorIndex) | ||
} else { | ||
img, err = screenshot.CaptureRect(image.Rect(boundaries[0], boundaries[1], boundaries[2], boundaries[3])) | ||
} | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
err = save(img, defaultScreenshotPath) | ||
if err != nil { | ||
return "", err | ||
} | ||
return defaultScreenshotPath, nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.