Comments (7)
@mmcloughlin Thought I might chime in. With the pinhole examples I used Go's builtin image package. But I've since moved to exporting each frame as an individual PNGs and using ffmpeg for creating the gif. This can often lead to much smoother animations, and also provides a utility for generating a palette from an existing frame.
This is how I create this cities globe.
from globe.
I did try to do this with a for loop to make a stop-frame animation but cannot get the for loop to work properly: (Disclaimer: I've never used golang before, so this is the first time I've been playing with it)
package main
import (
"fmt"
"github.com/mmcloughlin/globe"
)
func main() {
g := globe.New()
g.DrawGraticule(10.0)
g.DrawLandBoundaries()
for i := -90; i <= 90; i++ {
g.CenterOn(0, float64(i))
t := fmt.Sprintf("imgs/globe-%f.png", float64(i))
g.SavePNG(t, 1000)
}
}
from globe.
Very cool @caleuanhopkins! Nothing looks wrong with your code from my perspective. I just learned that the GIF package exists. I assume it would be "easy" ( 🤞 ) to extrapolate your solution to use this library (especially the []*image.Paletted
field), if you wanted to make PR.
from globe.
@LOZORD thanks, but there is an issue as the images don't move along the lon
axis, they jump around at almost random co-ords! 😖 no idea why i
doesn't just make the CentreOn()
method run in a line.
from globe.
This would be a great feature! I'm planning to work on it. As @LOZORD has pointed out the best way is to use the image/gif package. The pinhole package has an example:
https://github.com/tidwall/pinhole/blob/86ba04e3523bd03ebff51eac8dd0865c9dc9305e/examples/earth.go
The delicate part here is selecting a good color palette. The pinhole example solves this in a very specific way, but we would need a more general solution. Probably just picking the most common colors across the frames would be a decent solution in this case. However after some searching I think there may be a gap in the market for some more sophisticated implementations of the Quantizer interface which can be used for palette selection (see gif.Options).
from globe.
@caleuanhopkins the CenterOn
behavior you mentioned is a bug. It does the wrong thing when called more than once. I've recorded this in #4. The fix is fairly easy and I will work on it this evening.
from globe.
@tidwall I was thinking the same for an animation solution as with each frame they could then be imported into a range slider html element and allow the creation of 3d rotational sliders (this is just a practical example of something I have in my head I can use Globe for).
@mmcloughlin thanks for highlighting the bug, I would love to help but I'm brand new to GoLang and I would be useless in helping to debug this one!
from globe.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from globe.