-
Notifications
You must be signed in to change notification settings - Fork 13
WASM Webapp and initial support for SVG rendering #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
June 10, 2022 See the original PR comment for more specific details. This comment is meant to provide an easy way to look at my changes, so you don't only have to go digging through my super messy and unnecessarily plentiful commits. TOTAL COMMITS SO FAR: Summary of PR so far:
|
Sorry about this getting closed. I've update the repo to use |
June 14, 2022 See the original PR comment for more specific details. This comment is meant to provide an easy way to look at my changes, so you don't only have to go digging through my super messy and unnecessarily plentiful commits. TOTAL COMMITS SO FAR: Summary of PR so far (things that have changed / been added since the last summary comment):
|
WEBAPP
I have made a super rudimentary version of this project using
wasm
, and it was taken almost entirely from go-wasm-pdfcpu.To build the
nexrad.wasm
file yourself, runI struggled a while on Go 1.18 because I was getting some errors, but then I downgraded to 1.12 and it worked fine. Specifically
go version go1.12 darwin/amd64
.Then put the binary under the webapp directory I have made:
These instructions are just if you want to build it yourself. A live demo of what I (but mostly the author of go-wasm-pdfcpu) have done can be found here:
https://steepatticstairs.github.io/go-nexrad/webapp/
I plan to do a lot more cleanup.
VECTOR RENDERING
This is very scuffed code, forgive me - I mainly work with JavaScript, not Go! But this is a basic implementation of vector rendering using the
draw2d
library. By passing the-v
flag with argumentspng
orsvg
(png is default), it will generate the relevant file.However, I think there are three major issues with the code I have written. First, the file size of these svg files are extremely large, hovering around 70 MB. I have tried to reduce the DPI, the canvas size, but nothing has worked, so I would like to try and work out a solution in the future. Any suggestions on combatting this issue would be welcome.
Second issue (fixed for now I think??)
Second, the svg image has a slight problem with rendering the pixels closest to the origin. For example, when I generate an svg file from

KLZK20220607_194517_V06
by doinggo run . -f testdata/KLZK20220607_194517_V06 -p ref -v svg
, I get this error right in the middle of the image:As you can see, there is a ring of thick pixels that shouldn't be there.
This is NOT an issue with PNG rendering.
Third, the variables
canvas
andgc
have been replaced withPNGcanvas
PNGgc
andSVGcanvas
SVGgc
, and I will explain that here. I wanted to use anif
statement, basically giving these variables their proper arguments if the user passedpng
orsvg
. For example, the correctcanvas
variable for ansvg
render would bewhile the correct variable for a
png
render would beI wanted to set these dynamically with an
if
statement, ideally something like this:However, the issue with this is that each of these variables using
:=
, which obviously means that they are declared and set in the same line, where they don't require you to specify a type. This will not work here, because you need to define the variables outside of theif
statement. You could do this by writing something likebut this would mean you would have to change the types of
canvas
andgc
for the case that the user renders ansvg
.My solution to this, of course, was to create two separate
draw2d
objects that the program will draw to simultaneously, but only one will get exported to a file 😂. This, of course, is not the best way to do it, because it slows down the program and it looks quite ugly. Again, any suggestions on combatting this issue would be welcome.Andrew