mmcloughlin / globe

Globe wireframe visualizations in Golang
https://pkg.go.dev/github.com/mmcloughlin/globe
ISC License
1.59k stars 51 forks source link

Overlapping points causes a turquoise noise/artefact #6

Closed JamesLMilner closed 7 years ago

JamesLMilner commented 7 years ago

Firstly thanks for the great library! Top work.

I noticed that using GeoJSON files with overlapping points sometimes produces these strange turquoise noise effects. Any way to combat/fix that behaviour?

eb41b547-aa7e-4402-a47e-1baf9b10e6c5

mmcloughlin commented 7 years ago

Well, that's not good :( Do you mind sharing code to reproduce this? I have an idea of what it might be but the code would help.

Thanks for filing the issue.

JamesLMilner commented 7 years ago

Yeah for sure, check out: https://github.com/JamesMilnerUK/globe-plotter

Sorry it's a bit of a mess.

mmcloughlin commented 7 years ago

Nice project!

Can you try using color.NRGBA instead? I certainly noticed that color.RGBA can produce this kind of problem. Here's an example:

https://gist.github.com/mmcloughlin/e824139574762169ce7f232fd76da9df

JamesLMilner commented 7 years ago

Huzzah! this was indeed the problem. Other slight issue was I hadn't been paying attention in that JavaScript / CSS takes the standard of (uint8, uint8, uint8, float64) but after some minor type conversion this was fine:

screenshot_20170727_213200

Relevant type conversion code:

    g := globe.New()
    alpha := uint8(rgbaColors.A * 255) // i.e. 0.5 * 255 
    color := color.NRGBA{rgbaColors.R, rgbaColors.G, rgbaColors.B, alpha} 

Edit: Is it worth potentially documenting this issue in the README?

mmcloughlin commented 7 years ago

Glad we could sort this out! I dropped a note in the README, because the very same issue confused me in the past. Thanks again for filing the issue.