This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_other.go
71 lines (60 loc) · 1.78 KB
/
main_other.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) 2022 Elias Daler
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 3 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//go:build !js
package main
import (
"bytes"
"flag"
"fmt"
"os"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
func focus() {}
func parseConfig() config {
inputPath := flag.String("i", "", "input image")
configPath := flag.String("c", "", "custom config JSON")
noClose := flag.Bool("noclose", false, "if true, window doesn't close after converting an image")
flag.Usage = func() {
fmt.Fprintf(os.Stderr,
`crten v0.1, usage:
crten IMAGE_FILE - display INPUT_FILE with CRT effect
crten -i INPUT_FILE [-c CONFIG_FILE] OUTPUT_FILE - renders INPUT_FILE image with CRT effect to OUTPUT_FILE and closes the window
`)
flag.PrintDefaults()
}
flag.Parse()
var c config
c.ConfigPath = *configPath
if *inputPath == "" {
if flag.NArg() == 1 {
c.InputPath = flag.Arg(0)
}
} else {
c.InputPath = *inputPath
if flag.NArg() == 1 {
c.OutputPath = flag.Arg(0)
}
}
if *noClose {
c.NoClose = true
}
return c
}
func getImages() ([]galleryImage, error) {
img, _, err := ebitenutil.NewImageFromReader(bytes.NewReader(imgFile))
if err != nil {
return nil, err
}
return []galleryImage{{Desc: "'The Cat and the Wizard' by Elias Daler (@eliasdaler)", Image: img}}, nil
}