fogleman / gg

Go Graphics - 2D rendering in Go with a simple API.
https://godoc.org/github.com/fogleman/gg
MIT License
4.4k stars 358 forks source link

Improvement to output files #184

Open WillianBR opened 1 year ago

WillianBR commented 1 year ago

@fogleman,

I have noticed many examples from "fogleman/gg" save it output image file to "out.png".

That can be tricky!

I would like to suggest two additional lines, who it'll save the PNG with the same name of executable. Changing the extension only!

outPNG := strings.ReplaceAll(filepath.Base(os.Args[0]), filepath.Ext(os.Args[0]), ".png")
dc.SavePNG(outPNG)

I have the habit of build all the samples and test it one at the time. But this litlte folks overwrite the old output file.

WillianBR commented 1 year ago

Font file issue into "scatter.go"

I also noticed you are using a Apple computer with Mac OSX. So you hard coded the font file path.

I suggest you get a free truetype font and include it into the repository. Than your code can localy load it and use!

Otherwise your code will compile on Linux and Windows, but it'll runtime panic!

panic: open /Library/Fonts/Arial.ttf: The system cannot find the path specified.

sbinet commented 1 year ago

this has been fixed in "my" fork of gg: