Parses graphs and other data from camelcamelcamel.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

40 lines
716 B

package main
import (
"fmt"
"image"
"image/png"
"os"
"time"
"git.geek1011.net/geek1011/camelparse/graph"
)
func main() {
maxPrice, minPrice := 59.99, 9.99
startDate, endDate := time.Date(2015, 10, 29, 0, 0, 0, 0, time.Local), time.Date(2019, 05, 15, 0, 0, 0, 0, time.Local)
img, err := loadPNG("../testdata/graph.png")
if err != nil {
panic(err)
}
parsed, err := graph.Parse(img, maxPrice, minPrice, startDate, endDate)
if err != nil {
panic(err)
}
for _, p := range parsed {
fmt.Println(p.String())
}
}
// loadPNG loads a PNG image.
func loadPNG(path string) (image.Image, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return png.Decode(f)
}