goseq
goseq copied to clipboard
Add native support for generating PNG images
Add an option to draw the sequence diagram as a rasterisation of PNG. This will remove the need to use ImageMagick to rasterise SVGs to PNGs.
Go SVG rasteriser example here: https://stackoverflow.com/a/63227777
Alternatively, but a much bigger job, use something like https://github.com/tdewolff/canvas or https://github.com/llgcode/draw2d that can then output to many vector and raster formats.
(ahh, now I see you have a branch for draw2d, cool)
Thanks for the tip regarding the SVG rasteriser, @TheMightyGit. That "draw2d" branch is quite old: I think I was trying to do too much in it with rewriting the code that actually generated the SVG diagram in an image agnostic way. It might be worth abandoning it and simply using the rasteriser, depending on how well it handles the generated SVG.
Now I've thought about it for a while, maybe anything other than SVG output is overscope? There are so many great SVG conversion tools out there why complicate the goseq codebase with any rasterisation code at all?
"Do one thing well" - and a diagram tool that outputs to a common open vector standard is doing its job well.
Maybe the lack of built in output formats can be mitigated with docs and help text that explains how (and what) to use to convert from SVG into other common formats?
Yeah, I know for myself I can never find a good SVG rasterising tool whenever I need it. But this issue has been open for so long and I haven't done anything to resolve it, so I'm happy to just close it with no further action.
Yes, for me the PNG build flag mentioned in the README doesn't work
$ go get -tags im github.com/lmika/goseq
go: downloading github.com/lmika/goseq v0.0.1
go: downloading github.com/howeyc/fsnotify v0.9.0
go: downloading github.com/ajstarks/svgo v0.0.0-20200725142600-7a3c8b57fecb
go: downloading github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
go: downloading github.com/quirkey/magick v0.0.0-20140324185457-b37664054620
# github.com/quirkey/magick
pkg/mod/github.com/quirkey/[email protected]/magick.go:19:10: fatal error: magick/MagickCore.h: No such file or directory
19 | #include <magick/MagickCore.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
because I don't have a MagickCore.h file, not sure where that's supposed to come from.
But like mentioned above, it's a non-issue. E.g. if you have imagemagick installed then you can just pipe the SVG to PNG, e.g. like this
goseq <<<"Client->Server: Hello" | convert svg:- hello-seq.png
results in a hello-seq.png file that looks like this:

Thanks for that, @sinisterstuf. In retrospect I kind of regret adding that feature given that it pulls in/requires ImageMagick. Maybe the fix for this is simply to drop the flag.