Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Interactive ASCII globe generator

License

NotificationsYou must be signed in to change notification settings

adamsky/globe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Render an ASCII globe in your terminal. Make it interactive or just let itspin in the background.

Changelog

v0.2.1:

  • upgradedclap dependency to3.0.0
  • changedglobe-clitemplate argument to not be required

v0.2.0:

  • added multiple CLI arguments for setting up the scene (refresh-rate,globe-rotation,cam-rotation,cam-zoom,location,focus-speed,night,template,texture,texture-night)
  • added experimentallisting mode that supports reading coordinates fromstandard input and going through all of them, animating camera target changes(see--pipe)
  • enabled ability to display night side of the globe using an additionaltexture
  • changed default Earth texture (now includes New Zealand)
  • added vim-style navigation for the interactive mode
  • improved internal library representation ofTexture
  • improved documentation

v0.1.2

  • added clearing screen on exit
  • fixed panic when using rust version <1.45

v0.1.1

  • fixed mouse capture staying on after exit

v0.1.0

  • initial release

Install

To buildglobe-cli you will need to haveRust programming language installed on your machine.

Usecargo install:

cargo install globe-cli

Orgit clone andcargo run --release directly from the repository.

AUR

globe can be installed from availableAUR packages using anAUR helper. For example,

yay -S globe-cli

If you prefer, you can clone theAUR packages and then compile them withmakepkg. For example,

git clone https://aur.archlinux.org/globe-cli.gitcd globe-climakepkg -si

Docker

You can also use Docker to try outglobe, no Rust needed. After cloning the repo, just build and run an image from theDockerfile contained at the root of the project:

docker build -t globe.docker run -it --rm globe -s

Run

To get a full listing of available features and options, show the--helpinformation with:

globe -h

Display a globe inscreensaver mode using the-s option.

globe -s

It's kind of boring. Let's add some camera rotation to make it look morealive:

globe -sc2

Now let's also enable the night side and rotate the globe on its axis:

globe -snc2 -g10

If you want to adjust things at runtime check out theinteractive mode.Here you can pan the globe around using either the mouse or keyboard arrows:

globe -i

Use+ and- to control the globe rotation speed,, and. to controlthe camera rotation speed,PgUp andPgDown to control the camera zoom,n to toggle displaying globe's night side.

Settings we used on thescreensaver mode also work:

globe -inc2 -g10

Last but not least there is thelisting mode. It allows you to pass locationcoordinates to the program and see them shown one by one on the globe.Currently, it only supports a very basic input format. Here's an example:

echo "0,0.5;0.1,0.5;0.3,0.5;0.5,0.5;0.7,0.5" | globe -p

If you're feeling creative, you can also load custom textures, like so:

globe -in --texture ./path-to-texture --texture-night ./path-to-night-texture

Use the library

To useglobe within your Rust project, add it to your dependencies:

[dependencies]globe = "0.2.0"

First create aGlobe:

let mut globe = GlobeConfig::new()    .use_template(GlobeTemplate::Earth)    .with_camera(CameraConfig::default())    .build();

Next make a newCanvas and render theGlobe onto it:

let mut canvas = Canvas::new(250, 250, None);globe.render_on(&mut canvas);

You can now print out the canvas to the terminal:

let (size_x, size_y) = canvas.get_size();// default character size is 4 by 8for i in 0..size_y / 8 {    for j in 0..size_x / 4 {        print!("{}", canvas.matrix[i][j]);    }    println!();}

Seeglobe-cli code for examples of runtime changes to theGlobe and it'sCamera.

Credits

Rendering math based onC++ code by DinoZ1729.


[8]ページ先頭

©2009-2025 Movatter.jp