diff --git a/.gitignore b/.gitignore index 7d13abc..b109265 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /cover day03_debug.png +go.sum diff --git a/day03.go b/day03.go index 48deae2..2dfd233 100644 --- a/day03.go +++ b/day03.go @@ -3,12 +3,13 @@ package aoc2019 import ( "image" "image/color" + "image/png" "io/ioutil" "math" + "os" "strconv" "strings" - "github.com/llgcode/draw2d/draw2dimg" "github.com/pkg/errors" ) @@ -145,9 +146,13 @@ func debugDay3DrawImage(l1, l2 day3Line) error { // Draw "home-point" in green dest.SetRGBA(0, 0, color.RGBA{0x0, 0xff, 0x0, 0xff}) - draw2dimg.SaveToPngFile("day03_debug.png", dest) + f, err := os.Create("day03_debug.png") + if err != nil { + return errors.Wrap(err, "Unable to open output file") + } + defer f.Close() - return nil + return errors.Wrap(png.Encode(f, dest), "Unable to write image") } func getDay3MinIntersectionDistance(l1, l2 day3Line, originX, originY int) int { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..fcdeec5 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/Luzifer/aoc2019 + +go 1.13 + +require github.com/pkg/errors v0.8.1