Giter Site home page Giter Site logo

Globe animations/GIFs? about globe HOT 7 OPEN

LOZORD avatar LOZORD commented on June 3, 2024
Globe animations/GIFs?

from globe.

Comments (7)

tidwall avatar tidwall commented on June 3, 2024 3

@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.

caleuanhopkins avatar caleuanhopkins commented on June 3, 2024 2

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.

LOZORD avatar LOZORD commented on June 3, 2024 1

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.

caleuanhopkins avatar caleuanhopkins commented on June 3, 2024

@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.

mmcloughlin avatar mmcloughlin commented on June 3, 2024

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.

mmcloughlin avatar mmcloughlin commented on June 3, 2024

@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.

caleuanhopkins avatar caleuanhopkins commented on June 3, 2024

@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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.